diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..7e1746bccdf2120b91fc93257ca762524c68ae69
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,1204 @@
+variables:
+ TESTV_DIR: "/usr/local/testv"
+ LTV_DIR: "/usr/local/ltv"
+ EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop"
+ REFERENCE_BRANCH: "ivas-float-update"
+ BUILD_OUTPUT: "build_output.txt"
+ SCRIPTS_DIR: "/usr/local/scripts"
+ EXIT_CODE_NON_BE: 123
+ EXIT_CODE_FAIL: 1
+ LONG_TEST_SUITE: "tests/codec_be_on_mr_nonselection tests/renderer --param_file scripts/config/self_test_ltv.prm --use_ltv"
+ SHORT_TEST_SUITE: "tests/codec_be_on_mr_nonselection"
+ TEST_SUITE: ""
+ DUT_ENCODER_PATH: "./IVAS_cod"
+ DUT_DECODER_PATH: "./IVAS_dec"
+ REF_ENCODER_PATH: "./IVAS_cod_ref"
+ REF_DECODER_PATH: "./IVAS_dec_ref"
+ LEVEL_SCALING: "1.0"
+ IVAS_PIPELINE_NAME: ''
+ BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch"
+ PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm"
+ TESTCASE_TIMEOUT_STV: 900
+ TESTCASE_TIMEOUT_LTV: 2400
+ TESTCASE_TIMEOUT_STV_SANITIZERS: 1800
+ CI_REGRESSION_THRESH_MLD: "0.1"
+ CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50"
+ CI_REGRESSION_THRESH_SSNR: "-1"
+ CI_REGRESSION_THRESH_ODG: "-0.05"
+ GIT_CLEAN_FLAGS: -ffdxq
+ INSTR_DIR: "scripts/c-code_instrument"
+ MANUAL_PIPELINE_TYPE:
+ description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec."
+ value: 'default'
+ options:
+ - 'default'
+ - 'pytest-compare'
+ - 'pytest-compare-long'
+ - 'pytest-saturation-smoke-test'
+ - 'evs-26444'
+ - 'sanitizer-stv'
+ - 'pytest-renderer'
+ - 'complexity'
+
+
+default:
+ interruptible: true # Make all jobs by default interruptible
+
+workflow:
+ name: '$IVAS_PIPELINE_NAME'
+ rules:
+ # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ variables:
+ IVAS_PIPELINE_NAME: 'MR pipeline: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME'
+ ### disabled for now because pipeline cd is redundant with MR pipeline with current workflow
+ # - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Pushes to main
+ # variables:
+ # IVAS_PIPELINE_NAME: 'Push pipeline: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'default' # for testing
+ variables:
+ IVAS_PIPELINE_NAME: 'Web run pipeline: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run comparison tools against float ref: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-saturation-smoke-test'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run saturation smoke-test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'evs-26444'
+ variables:
+ IVAS_PIPELINE_NAME: 'EVS 26.444 test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'sanitizer-stv'
+ variables:
+ IVAS_PIPELINE_NAME: 'Short testvectors sanitizers'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-renderer'
+ variables:
+ IVAS_PIPELINE_NAME: 'Renderer test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'complexity'
+ variables:
+ IVAS_PIPELINE_NAME: 'Complexity Measurement on $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch
+ variables:
+ IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH'
+
+
+stages:
+ - prevalidate
+ - build
+ - test
+ - deploy
+
+# ---------------------------------------------------------------
+# Generic script anchors
+# ---------------------------------------------------------------
+
+# These can be used later on to do common tasks
+
+# Prints useful information for every job and should be used at the beginning of each job
+.print-common-info: &print-common-info
+ - |
+ echo "Printing common information for build job."
+ echo "Current job is run on commit $CI_COMMIT_SHA"
+ echo "Commit time was $CI_COMMIT_TIMESTAMP"
+ date | xargs echo "System time is"
+
+.build-reference-and-dut-binaries: &build-reference-and-dut-binaries
+ - current_commit_sha=$(git rev-parse HEAD)
+ ### build reference binaries
+ - git checkout $REFERENCE_BRANCH
+ - git pull
+ - make clean
+ - make -j
+ - mv ./IVAS_cod ./$REF_ENCODER_PATH
+ - mv ./IVAS_dec ./$REF_DECODER_PATH
+ - mv ./IVAS_rend ./IVAS_rend_ref
+
+ ### build test binaries
+ - git restore .
+ - git checkout $current_commit_sha
+ - make clean
+ - make -j
+
+.build-and-create-reference-outputs: &build-and-create-reference-outputs
+ - *build-reference-and-dut-binaries
+
+ ### prepare pytest
+ # create short test vectors
+ - python3 tests/create_short_testvectors.py
+ # create references
+ - exit_code=0
+ - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$?
+
+.update-scripts-repo: &update-scripts-repo
+ - cd $SCRIPTS_DIR
+ - sed -i '/fetch/d' .git/config # Remove all fetch lines to clean out dead links
+ - git remote set-branches --add origin $BASOP_CI_BRANCH_PC_REPO # Add currently used branch
+ - git fetch
+ - git restore . # Just as a precaution
+ - git checkout $BASOP_CI_BRANCH_PC_REPO
+ - git pull
+ - cd -
+ - cp -r $SCRIPTS_DIR/ci .
+ - cp -r $SCRIPTS_DIR/scripts .
+ - cp -r $SCRIPTS_DIR/tests .
+ - cp $SCRIPTS_DIR/pytest.ini .
+
+.apply-testv-scaling: &apply-testv-scaling
+ - echo "Applying level scaling in scripts/testv using scale=$LEVEL_SCALING"
+ - tests/scale_pcm.py ./scripts/testv/ $LEVEL_SCALING
+
+.update-ltv-repo: &update-ltv-repo
+ - cd $LTV_DIR
+ - git pull
+ - cd -
+
+.copy-ltv-files-to-testv-dir: ©-ltv-files-to-testv-dir
+ - cp "$LTV_DIR"/*.wav scripts/testv/
+ - cp "$LTV_DIR"/*.met scripts/testv/
+ - cp "$LTV_DIR"/*.csv scripts/testv/
+
+.activate-Werror-linux: &activate-Werror-linux
+ - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile
+
+.rules-pytest-to-ref-short:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare"
+ - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'schedule'
+ when: never
+
+# TODO: only temporary as long the MR encoder tests should not compare to main
+.rules-pytest-to-ref-enc-short-temp:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare"
+ - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'schedule'
+ when: never
+
+.rules-pytest-to-main-short:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+
+.rules-pytest-long:
+ rules:
+ - if: $PYTEST_MLD_LONG # Set by scheduled pipeline
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long"
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ when: never
+
+.rules-pytest-saturation-smoke-test:
+ rules:
+ - if: $PYTEST_SMOKE_TEST # Set by scheduled pipeline
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-saturation-smoke-test"
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ when: never
+
+# ---------------------------------------------------------------
+# Job templates
+# ---------------------------------------------------------------
+
+# templates to define stages and platforms
+.test-job-linux:
+ tags:
+ - ivas-basop-linux
+
+.build-job-linux:
+ stage: build
+ timeout: "2 minutes"
+ needs: []
+ tags:
+ - ivas-basop-linux
+
+# template for test jobs on linux that need the TESTV_DIR
+.test-job-linux-needs-testv-dir:
+ extends: .test-job-linux
+ before_script:
+ - *update-scripts-repo
+ - if [ ! -d "$TESTV_DIR" ]; then mkdir -p $TESTV_DIR; fi
+ - cp -r scripts/testv/* $TESTV_DIR/
+
+.ivas-pytest-anchor: &ivas-pytest-anchor
+ stage: test
+ needs: ["build-codec-linux-make"]
+ timeout: "240 minutes"
+ variables:
+ # keep "mld" in artifact name for backwards compatibility reasons
+ CSV_ARTIFACT_NAME: "mld--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv"
+ MERGED_CSV_ARTIFACT_NAME: "$CI_JOB_NAME--merged_csv--$CI_JOB_ID.csv"
+ PAGES_HTML_ARTIFACT_NAME: "$CI_JOB_NAME-index.html"
+ SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html"
+ IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME"
+ script:
+ - *print-common-info
+ - *update-scripts-repo
+ - if [ $USE_LTV -eq 1 ]; then
+ - *update-ltv-repo
+ - *copy-ltv-files-to-testv-dir
+ - testcase_timeout=$TESTCASE_TIMEOUT_LTV
+ - else
+ - testcase_timeout=$TESTCASE_TIMEOUT_STV
+ - fi
+
+ - python3 ci/remove_unsupported_testcases.py $PRM_FILES
+ - if [ $LEVEL_SCALING != "1.0" ];then
+ - *apply-testv-scaling
+ - fi
+ - *build-and-create-reference-outputs
+
+ ### run pytest
+ - exit_code=0
+ - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml --mld --ssnr --odg -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$?
+ - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true
+
+ - python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME
+ - mkdir $IMAGES_ARTIFACT_NAME
+ - for MEASURE in MLD DIFF SSNR;do python3 scripts/create_histogram_summary.py $CSV_ARTIFACT_NAME $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".csv $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".png --measure $MEASURE; done
+ - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME
+
+ - if [ $USE_LTV -eq 1 ] && [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
+ - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH $CI_JOB_NAME $CI_PROJECT_ID)
+ - echo "Job ID from variables - $CI_JOB_ID, Job ID from script - $id_previous"
+ - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip
+ - unzip artifacts.zip -d previous_artifacts
+ # This wildcard thingy relies on only one csv file being present per job
+ - file_previous="previous_artifacts/mld--$CI_JOB_NAME-$id_previous--sha-*.csv"
+ - python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME
+ - else
+ # create empty file for artifacts to avoid errors
+ - touch $PAGES_HTML_ARTIFACT_NAME
+ - touch $MERGED_CSV_ARTIFACT_NAME
+ - fi
+
+ - if [ $zero_errors != 1 ]; then
+ - echo "Run errors encountered!"
+ # TODO: temporary only to not fail pipelines on crashes in encoder
+ - if [[ "$CI_JOB_NAME" =~ "ivas-pytest-compare_to_ref-short-enc" ]]; then
+ - exit $EXIT_CODE_NON_BE
+ - else
+ - exit $EXIT_CODE_FAIL
+ - fi
+ - fi
+ - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit $EXIT_CODE_NON_BE; fi
+ - exit 0
+
+ allow_failure:
+ exit_codes:
+ - 123
+ artifacts:
+ name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
+ expire_in: 1 week
+ when: always
+ paths:
+ - report-junit.xml
+ - report.html
+ - $PAGES_HTML_ARTIFACT_NAME
+ - $CSV_ARTIFACT_NAME
+ - $MERGED_CSV_ARTIFACT_NAME
+ - $SUMMARY_HTML_ARTIFACT_NAME
+ - $IMAGES_ARTIFACT_NAME
+ expose_as: "pytest compare results"
+ reports:
+ junit:
+ - report-junit.xml
+
+.ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor
+ stage: test
+ needs: ["build-codec-linux-make"]
+ timeout: "300 minutes"
+ variables:
+ XML_REPORT_BRANCH: "report-junit-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml"
+ XML_REPORT_MAIN: "report-junit-main-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml"
+ HTML_REPORT_BRANCH: "report-junit-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html"
+ HTML_REPORT_MAIN: "report-junit-main-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html"
+ CSV_BRANCH: "scores-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.csv"
+ CSV_MAIN: "scores-main-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.csv"
+ IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME"
+ SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html"
+ script:
+ - *print-common-info
+ - *update-scripts-repo
+ - if [ $USE_LTV -eq 1 ]; then
+ - *update-ltv-repo
+ - *copy-ltv-files-to-testv-dir
+ - testcase_timeout=$TESTCASE_TIMEOUT_LTV
+ - else
+ - testcase_timeout=$TESTCASE_TIMEOUT_STV
+ - fi
+
+ - python3 ci/remove_unsupported_testcases.py $PRM_FILES
+ - if [ $LEVEL_SCALING != "1.0" ];then
+ - *apply-testv-scaling
+ - fi
+
+ # check MR title for flag that allows regressions to be mergable
+ - echo $CI_MERGE_REQUEST_TITLE > tmp.txt
+ - allow_regressions_flag=$(grep -c --ignore-case "\[allow[ -]*regression\]" tmp.txt) || true
+
+ ### run branch first
+ # this per default builds the branch and the reference and creates the reference outputs
+ - *build-and-create-reference-outputs
+ - exit_code=0
+ - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || exit_code=$?
+ - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true
+ - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH
+
+ # create the summary based on the branch
+ - mkdir $IMAGES_ARTIFACT_NAME
+ - for MEASURE in MLD DIFF SSNR;do python3 scripts/create_histogram_summary.py $CSV_BRANCH $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".csv $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".png --measure $MEASURE; done
+ - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME
+
+ ### run main now
+ - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
+ - git pull
+ - make clean
+ - make -j
+ - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true
+ - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN
+
+ ### compare the two csv files for regressions
+ - regressions_found=0
+ - python3 scripts/basop_check_for_changes_in_testcases.py $CSV_BRANCH $CSV_MAIN || regressions_found=$?
+
+ - if [ $regressions_found != 0 ]; then
+ - echo "Detected regression wrt to main!"
+ - if [ $allow_regressions_flag == 0 ]; then
+ - exit $EXIT_CODE_FAIL;
+ - else
+ - exit $EXIT_CODE_NON_BE;
+ - fi
+ - fi
+ - if [ $zero_errors_branch != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_NON_BE; fi
+ - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit $EXIT_CODE_NON_BE; fi
+ - exit 0
+ after_script:
+ - rm -rf tests/dut tests/ref
+ allow_failure:
+ exit_codes:
+ - 123
+ artifacts:
+ name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
+ expire_in: 1 week
+ when: always
+ paths:
+ - $XML_REPORT_BRANCH
+ - $XML_REPORT_MAIN
+ - $HTML_REPORT_BRANCH
+ - $HTML_REPORT_MAIN
+ - $CSV_BRANCH
+ - $CSV_MAIN
+ - $SUMMARY_HTML_ARTIFACT_NAME
+ - $IMAGES_ARTIFACT_NAME
+ - changes_crashes.csv
+ - changes_MLD.csv
+ - changes_MAXIMUM_ABS_DIFF.csv
+ - changes_MIN_SSNR.csv
+ - changes_MIN_ODG.csv
+ expose_as: "pytest compare results"
+ reports:
+ junit:
+ - $XML_REPORT_BRANCH
+ - $XML_REPORT_MAIN
+
+
+.ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor
+ stage: test
+ needs: ["build-codec-linux-make"]
+ timeout: "90 minutes"
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'schedule' && $IVAS_PYTEST_MSAN
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer-stv"
+ script:
+ - *print-common-info
+ - *update-scripts-repo
+ - python3 ci/remove_unsupported_testcases.py $PRM_FILES
+ - *build-reference-and-dut-binaries
+ - make clean
+ - make -j CLANG=$CLANG_NUM
+ - if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan.supp,report_error_type=1"; fi
+ - testcase_timeout=$TESTCASE_TIMEOUT_STV_SANITIZERS
+ - python3 -m pytest $SHORT_TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH
+ artifacts:
+ name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
+ when: always
+ expire_in: "2 weeks"
+ paths:
+ - report-junit.xml
+ - report.html
+ reports:
+ junit:
+ - report-junit.xml
+
+# ---------------------------------------------------------------
+# verification jobs
+# ---------------------------------------------------------------
+
+clang-format-check:
+ extends:
+ - .test-job-linux
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'schedule'
+ when: never
+ variables:
+ ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix"
+ stage: prevalidate
+ needs: []
+ timeout: "5 minutes"
+ script:
+ - *update-scripts-repo
+ # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there
+ - PATCH_FILE_NAME="$ARTIFACT_BASE_NAME".patch
+ - >
+ INSTRUCTIONS_GITLAB="To fix formatting issues:\n
+ - download the diff patch available as artifact of this job\n
+ - unzip the artifact and place the patch file in the root directory of your local IVAS repo\n
+ - run: git apply $PATCH_FILE_NAME\n
+ - commit new changes"
+ - >
+ INSTRUCTIONS_README="To fix formatting issues:\n
+ - place the patch file in the root directory of your local IVAS repo\n
+ - run: git apply $PATCH_FILE_NAME\n
+ - commit new changes"
+
+ - format_problems=0
+ - scripts/check-format.sh -afD -p 8 || format_problems=$?
+ - if [ $format_problems == 0 ] ; then exit 0; fi
+
+ - mkdir tmp-formatting-fix
+ - git diff > "tmp-formatting-fix/$PATCH_FILE_NAME"
+
+ # Print instructions to job output
+ - echo -e "$INSTRUCTIONS_GITLAB"
+
+ # Include readme in the artifact, in case someone misses the job printout (e.g. getting the artifact via MR interface)
+ - echo -e "$INSTRUCTIONS_README" > "tmp-formatting-fix/readme.txt"
+
+ - exit $format_problems
+ artifacts:
+ expire_in: 1 day
+ paths:
+ - tmp-formatting-fix/
+ when: on_failure
+ name: "$ARTIFACT_BASE_NAME"
+ expose_as: "formatting patch"
+
+# ---------------------------------------------------------------
+# Build jobs
+# ---------------------------------------------------------------
+
+# ensure that codec builds on linux
+build-codec-linux-make:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web'
+ - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
+ - if: $CI_PIPELINE_SOURCE == 'schedule'
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ extends:
+ - .build-job-linux
+ script:
+ - *print-common-info
+ - *activate-Werror-linux
+ - make -j
+
+# ensure that codec builds on linux with instrumentation active
+build-codec-linux-instrumented-make:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web'
+ - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
+ - if: $CI_PIPELINE_SOURCE == 'schedule'
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ extends:
+ - .build-job-linux
+ timeout: "7 minutes"
+ script:
+ - *print-common-info
+ - *update-scripts-repo
+ - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP
+ - make -j -C $INSTR_DIR
+
+# ---------------------------------------------------------------
+# Short test jobs that run in merge request pipelines
+# ---------------------------------------------------------------
+
+### jobs that test fx encoder -> flt decoder
+# TODO: reenable once encoder tests shall compare to main
+# ivas-pytest-compare_to_main-short-enc:
+# extends:
+# - .rules-pytest-to-main-short
+# - .test-job-linux
+# before_script:
+# - USE_LTV=0
+# - DUT_DECODER_PATH=./IVAS_dec_ref
+# - TEST_SUITE="$SHORT_TEST_SUITE"
+# - LEVEL_SCALING=1.0
+# <<: *ivas-pytest-on-merge-request-anchor
+
+# ivas-pytest-compare_to_main-short-enc-lev-10:
+# extends:
+# - .rules-pytest-to-main-short
+# - .test-job-linux
+# before_script:
+# - USE_LTV=0
+# - DUT_DECODER_PATH=./IVAS_dec_ref
+# - TEST_SUITE="$SHORT_TEST_SUITE"
+# - LEVEL_SCALING=0.3162
+# <<: *ivas-pytest-on-merge-request-anchor
+
+# ivas-pytest-compare_to_main-short-enc-lev+10:
+# extends:
+# - .rules-pytest-to-main-short
+# - .test-job-linux
+# before_script:
+# - USE_LTV=0
+# - DUT_DECODER_PATH=./IVAS_dec_ref
+# - TEST_SUITE="$SHORT_TEST_SUITE"
+# - LEVEL_SCALING=3.162
+# <<: *ivas-pytest-on-merge-request-anchor
+
+### jobs that test flt encoder -> fx decoder
+ivas-pytest-compare_to_main-short-dec:
+ extends:
+ - .rules-pytest-to-main-short
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=1.0
+ - rm -rf tests/dut tests/ref
+ <<: *ivas-pytest-on-merge-request-anchor
+
+ivas-pytest-compare_to_main-short-dec-lev-10:
+ extends:
+ - .rules-pytest-to-main-short
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=0.3162
+ - rm -rf tests/dut tests/ref
+ <<: *ivas-pytest-on-merge-request-anchor
+
+ivas-pytest-compare_to_main-short-dec-lev+10:
+ extends:
+ - .rules-pytest-to-main-short
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=3.162
+ - rm -rf tests/dut tests/ref
+ <<: *ivas-pytest-on-merge-request-anchor
+
+# ---------------------------------------------------------------
+# Short test jobs for running from web interface or schedule
+# ---------------------------------------------------------------
+
+### jobs that test fx encoder -> flt decoder
+ivas-pytest-compare_to_ref-short-enc:
+ extends:
+ #- .rules-pytest-to-ref-short
+ - .rules-pytest-to-ref-enc-short-temp
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_to_ref-short-enc-lev-10:
+ extends:
+ #- .rules-pytest-to-ref-short
+ - .rules-pytest-to-ref-enc-short-temp
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=0.3162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_to_ref-short-enc-lev+10:
+ extends:
+ #- .rules-pytest-to-ref-short
+ - .rules-pytest-to-ref-enc-short-temp
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=3.162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-enc-msan:
+ extends:
+ - .test-job-linux
+ before_script:
+ - CLANG_NUM=1
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ <<: *ivas-pytest-sanitizers-anchor
+
+ivas-pytest-enc-asan:
+ extends:
+ - .test-job-linux
+ before_script:
+ - CLANG_NUM=2
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ <<: *ivas-pytest-sanitizers-anchor
+
+ivas-pytest-enc-usan:
+ extends:
+ - .test-job-linux
+ before_script:
+ - CLANG_NUM=3
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ <<: *ivas-pytest-sanitizers-anchor
+
+### jobs that test flt encoder -> fx decoder
+ivas-pytest-compare_to_ref-short-dec:
+ extends:
+ - .rules-pytest-to-ref-short
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_to_ref-short-lev-10:
+ extends:
+ - .rules-pytest-to-ref-short
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=0.3162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_to_ref-short-dec-lev+10:
+ extends:
+ - .rules-pytest-to-ref-short
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=3.162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-dec-msan-short:
+ extends:
+ - .test-job-linux
+ before_script:
+ - CLANG_NUM=1
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ <<: *ivas-pytest-sanitizers-anchor
+
+ivas-pytest-dec-asan-short:
+ extends:
+ - .test-job-linux
+ before_script:
+ - CLANG_NUM=2
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ <<: *ivas-pytest-sanitizers-anchor
+
+ivas-pytest-dec-usan-short:
+ extends:
+ - .test-job-linux
+ before_script:
+ - CLANG_NUM=3
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ <<: *ivas-pytest-sanitizers-anchor
+
+# ---------------------------------------------------------------
+# Long test jobs
+# ---------------------------------------------------------------
+
+ivas-pytest-compare_ref-long-enc:
+ extends:
+ - .rules-pytest-long
+ - .test-job-linux
+ before_script:
+ - USE_LTV=1
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-dec:
+ extends:
+ - .rules-pytest-long
+ - .test-job-linux
+ before_script:
+ - USE_LTV=1
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-enc-lev-10:
+ extends:
+ - .rules-pytest-long
+ - .test-job-linux
+ before_script:
+ - USE_LTV=1
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE"
+ - LEVEL_SCALING=0.3162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-dec-lev-10:
+ extends:
+ - .rules-pytest-long
+ - .test-job-linux
+ before_script:
+ - USE_LTV=1
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE"
+ - LEVEL_SCALING=0.3162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-enc-lev+10:
+ extends:
+ - .rules-pytest-long
+ - .test-job-linux
+ before_script:
+ - USE_LTV=1
+ - DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE"
+ - LEVEL_SCALING=3.162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-dec-lev+10:
+ extends:
+ - .rules-pytest-long
+ - .test-job-linux
+ before_script:
+ - USE_LTV=1
+ - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE"
+ - LEVEL_SCALING=3.162
+ <<: *ivas-pytest-anchor
+
+ivas-smoke-test-saturation:
+ extends:
+ - .rules-pytest-saturation-smoke-test
+ - .test-job-linux-needs-testv-dir
+ script:
+ - USE_LTV=1
+ - LEVEL_SCALING=32768
+
+ - *print-common-info
+ - *update-scripts-repo
+ - if [ $USE_LTV -eq 1 ]; then
+ - *update-ltv-repo
+ - *copy-ltv-files-to-testv-dir
+ - fi
+ - if [ $LEVEL_SCALING != "1.0" ];then
+ - *apply-testv-scaling
+ - fi
+ - cp -r scripts/testv/* $TESTV_DIR/
+
+ # skip prepare_mem_dryrun.py script in smoke_test.sh
+ - sed -i 's/python3 .\/scripts\/prepare_mem_dryrun.py/#python3 .\/scripts\/prepare_mem_dryrun.py/g' ci/smoke_test.sh
+
+ - bash ci/smoke_test.sh
+ ### analyze for failures
+ - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_plc.txt ] || ! [ -s smoke_test_output_jbm_noEXT.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi
+ - ret_val=0
+ - if cat smoke_test_output.txt | grep -c "failed" ; then echo "Smoke test without PLC failed"; ret_val=1; fi
+ - if cat smoke_test_output_plc.txt | grep -c "failed"; then echo "Smoke test with PLC failed"; ret_val=1; fi
+ - if cat smoke_test_output_jbm_noEXT.txt | grep -c "failed"; then echo "Smoke test JBM part failed"; ret_val=1; fi
+ - if cat smoke_test_output_hrtf.txt | grep -c "failed"; then echo "Smoke test with external hrtf files failed"; ret_val=1; fi
+ - exit $ret_val
+ artifacts:
+ name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
+ expire_in: 1 week
+ when: always
+ paths:
+ - smoke_test_output.txt
+ - smoke_test_output_plc.txt
+ - smoke_test_output_jbm_noEXT.txt
+ - smoke_test_output_hrtf.txt
+ expose_as: "saturation smoke test results"
+
+# ---------------------------------------------------------------
+# EVS 26.444 test job
+# ---------------------------------------------------------------
+
+# check bitexactness to EVS
+be-2-evs-26444:
+ extends:
+ - .test-job-linux
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "evs-26444"
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
+ tags:
+ - be-2-evs-basop
+ stage: test
+ timeout: "120 minutes" # To be revisited
+ script:
+ - *print-common-info
+ - *update-scripts-repo
+ - sed -i".bak" "s/\(#define EVS_FLOAT\)/\/\/\1/" lib_com/options.h
+ - make -j
+
+ # copy over to never change the testvector dir
+ - cp -r $EVS_BE_TEST_DIR_BASOP ./evs_be_test
+ - mkdir -p ./evs_be_test/output/decoded ./evs_be_test/output/bitstreams
+
+ - exit_code=0
+ - python3 -m pytest tests/test_26444.py -v --html=report.html --self-contained-html --junit-xml=report-junit.xml -n auto || exit_code=$?
+ - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit $EXIT_CODE_FAIL; fi
+ - exit 0
+
+ artifacts:
+ name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
+ expire_in: 1 week
+ when: always
+ paths:
+ - report-junit.xml
+ - report.html
+ expose_as: "EVS 26444 result"
+ reports:
+ junit:
+ - report-junit.xml
+
+ivas-pytest-renderer:
+ extends:
+ - .test-job-linux
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-renderer"
+ before_script:
+ - USE_LTV=0
+ - TEST_SUITE="tests/renderer"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+
+# ---------------------------------------------------------------
+# Complexity measurement jobs
+# ---------------------------------------------------------------
+
+.complexity-measurements-setup:
+ &complexity-measurements-setup # create necessary environment
+ ### 1. part: mainly same as in float repo - this is boilerplate code to make the gitlab pages presentation work
+ - mkdir -p wmops/logs
+
+ - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID)
+ - echo $job_id
+ - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts.zip
+ - unzip artifacts.zip || true # this may fail on first run, when there are no artifacts there and the zip file is actually just "404"-html
+ - ls
+ - public_dir="$CI_JOB_NAME-public"
+ # if is needed to catch case when no artifact is there (first run), similarly as above
+ - if [[ -d $public_dir ]]; then mv $public_dir/* wmops/; fi
+ - ls wmops
+ - rm artifacts.zip
+ - rm -rf $public_dir
+
+ ### 2. part: setup specific for BASOP repo
+ # hack for using the reference encoder -> need to build manually to make script use ref enc and BASOP dec
+ - mkdir COMPLEXITY
+ - cp IVAS_cod_ref COMPLEXITY/IVAS_cod
+ # build branch code aain with instrumentation
+ - make clean
+ - bash scripts/prepare_instrumentation.sh -p BASOP -m MEM_ONLY
+ - make -j -C $INSTR_DIR
+ - cp $INSTR_DIR/IVAS_dec COMPLEXITY/IVAS_dec
+
+.complexity-measurements-prepare-artifacts:
+ &complexity-measurements-prepare-artifacts # prepare artifacts -> move to public directory
+ - public_dir="$CI_JOB_NAME-public"
+ - mkdir $public_dir
+ - mv -f wmops/log_*_all.txt wmops/*.js ${public_dir}/
+ # move logfiles for links
+ - mkdir $public_dir/logs
+ # first move logs
+ - log_files=$(cat $public_dir/graphs*.js | grep logFile | sed "s/.*\(wmops_newsletter_.*\.csv\).*/\1/g")
+ - echo $log_files
+ - ls wmops/logs
+ - for f in $log_files; do [ -f wmops/logs/$f ] && mv wmops/logs/$f $public_dir/logs/$f; done
+ # copy index page blueprint
+ - cp ci/complexity_measurements/index_complexity.html ${public_dir}/index.html
+ # patch the format in the title
+ - sed -i "s/IVAS FORMAT/IVAS $in_format to $out_format/g" ${public_dir}/index.html
+ # do separately here to avoid overwrite complaints by mv
+ - mv -f ci/complexity_measurements/style.css ${public_dir}/
+ - ls $public_dir
+
+.complexity-template:
+ extends:
+ - .test-job-linux
+ timeout: 3 hours 30 minutes
+ stage: test
+ variables:
+ ret_val: 0
+ before_script:
+ - *print-common-info
+ - *update-scripts-repo
+ - *update-ltv-repo
+ - *build-reference-and-dut-binaries
+ - *complexity-measurements-setup
+ - which coan
+ artifacts:
+ name: "$CI_JOB_NAME--$CI_COMMIT_REF_NAME--sha-$CI_COMMIT_SHA"
+ when: always
+ expire_in: 1 week
+ paths:
+ - $CI_JOB_NAME-public
+
+complexity-stereo-in-stereo-out:
+ extends:
+ - .complexity-template
+ rules:
+ - if: $MEASURE_COMPLEXITY_LINUX
+ script:
+ - in_format=stereo
+ - out_format=stereo
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only || ret_val=$?
+ - *complexity-measurements-prepare-artifacts
+ - exit $ret_val
+
+# complexity-stereo-in-7_1_4-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# script:
+# - in_format=stereo
+# - out_format=7_1_4
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-ism-in-ext-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 1 hours
+# script:
+# - in_format=ISM
+# - out_format=EXT
+# - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-ism-in-binaural-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 1 hours
+# script:
+# - in_format=ISM
+# - out_format=BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB
+# - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-hoa3-in-hoa3-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=HOA3
+# - out_format=HOA3
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-hoa3-in-binaural-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=HOA3
+# - out_format=BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-osba-in-ext-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=OSBA
+# - out_format=EXT
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-osba-in-binaural-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=OSBA
+# - out_format=BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-mc-in-7_1_4-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=MC
+# - out_format=7_1_4
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-mc-in-binaural-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=MC
+# - out_format=BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-masa-in-ext-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=MASA
+# - out_format=EXT
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-masa-in-binaural-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=MASA
+# - out_format="BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB"
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-omasa-in-ext-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=OMASA
+# - out_format=EXT
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-omasa-in-binaural-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=OMASA
+# - out_format="BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB"
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+# complexity-StereoDmxEVS-stereo-in-mono-out:
+# extends:
+# - .complexity-template
+# rules:
+# - if: $MEASURE_COMPLEXITY_LINUX
+# # when: delayed:
+# # start_in: 2 hours
+# script:
+# - in_format=StereoDmxEVS
+# - out_format=mono
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" || ret_val=$?
+# - *complexity-measurements-prepare-artifacts
+# - exit $ret_val
+
+
+# job that sets up gitlab pages website
+pages:
+ stage: deploy
+ tags:
+ - ivas-basop-linux
+ rules:
+ - if: $UPDATE_PAGES
+ script:
+ - *print-common-info
+ - *update-scripts-repo
+ - python3 ci/setup_pages.py
+ - ls
+ - ls public
+ artifacts:
+ paths:
+ - public
+ expire_in: 1 day
diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj
index f54f282f05863a94d58638b16b12501e42ec4440..3960787909538c2386a53203bf8e4ef2164c0732 100644
--- a/Workspace_msvc/lib_debug.vcxproj
+++ b/Workspace_msvc/lib_debug.vcxproj
@@ -100,9 +100,14 @@
+
+
+
+
+
diff --git a/apps/decoder.c b/apps/decoder.c
index 0a4da2bdb407479538de9c506511ef2cea092bf2..7b3a5410d99128a3b9cb0614b7c0fbedf78477c7 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -43,7 +43,14 @@
#include "masa_file_writer.h"
#include "render_config_reader.h"
#include "rotation_file_reader.h"
+#ifdef VARIABLE_SPEED_DECODING
+#include "tsm_scale_file_reader.h"
+#include
+#endif
#include "vector3_pair_file_reader.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
@@ -53,7 +60,7 @@
* Local constants
*------------------------------------------------------------------------------------------*/
-#if !defined( WMOPS )
+#if !defined( DEBUGGING ) && !defined( WMOPS )
static
#endif
int32_t frame = 0; /* Counter of frames */
@@ -68,6 +75,9 @@ static
#define ORIENT_TRK_REF_VEC ( 3 )
#define ORIENT_TRK_REF_VEC_LEV ( 4 )
+#ifdef VARIABLE_SPEED_DECODING
+#define VARIABLE_SPEED_FETCH_FRAMESIZE_MS 20
+#endif
#define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20
#define HEADROTATION_FETCH_FRAMESIZE_MS 5
#define DEFAULT_FETCH_FRAMESIZE_MS 20
@@ -114,6 +124,17 @@ typedef struct
IVAS_DEC_COMPLEXITY_LEVEL complexityLevel;
bool tsmEnabled;
IVAS_RENDER_FRAMESIZE renderFramesize;
+#ifdef DEBUGGING
+ IVAS_DEC_FORCED_REND_MODE forcedRendMode;
+#ifdef DEBUG_FOA_AGC
+ FILE *agcBitstream; /* temporary */
+#endif
+#ifdef VARIABLE_SPEED_DECODING
+ bool tsmScaleFileEnabled;
+ char *tsmScaleFileName;
+ uint16_t tsmScale;
+#endif
+#endif
uint16_t acousticEnvironmentId;
int16_t Opt_dpid_on;
uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
@@ -130,6 +151,11 @@ static void usage_dec( void );
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );
+#ifdef DEBUGGING
+static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
+static int16_t app_own_random( int16_t *seed );
+static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar );
+#endif
/*------------------------------------------------------------------------------------------*
* main()
@@ -157,7 +183,17 @@ int main(
RenderConfigReader *renderConfigReader = NULL;
int16_t *pcmBuf = NULL;
IVAS_RENDER_FRAMESIZE asked_frame_size;
+#ifdef DEBUGGING
+ int32_t noClipping;
+ int32_t cnt_frames_limited;
+#ifdef DEBUG_SBA_AUDIO_DUMP
+ int16_t numOutChannels, numTransportChannels, pca_ingest_channels;
+#endif
+#endif
+#ifdef DEBUGGING
+ dbgargs( &argc, argv );
+#endif
#ifdef WMOPS
reset_wmops();
reset_mem( USE_BYTES );
@@ -398,7 +434,110 @@ int main(
}
}
+#ifdef DEBUGGING
+ /*-----------------------------------------------------------------*
+ * Preview bitstream and print config information
+ *-----------------------------------------------------------------*/
+
+ if ( arg.voipMode )
+ {
+ if ( ( error = printBitstreamInfoVoip( arg, hBsReader, hIvasDec ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "Error while previewing VoIP bitstream: %s\n", ivas_error_to_string( error ) );
+ goto cleanup;
+ }
+ }
+ else
+ {
+ uint16_t bit_stream[IVAS_MAX_BITS_PER_FRAME + 4 * 8];
+ int16_t num_bits;
+ int16_t bfi = 0;
+ do
+ {
+ if ( BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: input bitstream file %s couldn't be read\n\n", arg.inputBitstreamFilename );
+ goto cleanup;
+ }
+ } while ( bfi || num_bits < MIN_NUM_BITS_ACTIVE_FRAME || num_bits == NUM_BITS_SID_IVAS_5K2 );
+
+ BS_Reader_Rewind( hBsReader );
+
+ IVAS_DEC_PrintConfigWithBitstream( hIvasDec, arg.quietModeEnabled, bit_stream, num_bits );
+
+#ifdef VARIABLE_SPEED_DECODING
+ if ( arg.tsmEnabled )
+ {
+ if ( arg.tsmScaleFileEnabled )
+ {
+ fprintf( stdout, "Variable speed file: %s\n", arg.tsmScaleFileName );
+ }
+ else
+ {
+ fprintf( stdout, "Variable speed factor: %i\n", arg.tsmScale );
+ }
+ }
+#endif
+ }
+
+ /*------------------------------------------------------------------------------------------*
+ * Binaural rendering mode: set and print info
+ *------------------------------------------------------------------------------------------*/
+
+ if ( arg.forcedRendMode != IVAS_DEC_FORCE_REND_UNFORCED )
+ {
+ if ( ( error = IVAS_DEC_SetForcedRendMode( hIvasDec, arg.forcedRendMode ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: Forcing binaural rendering mode failed (only TDREND and CLDFBREND are expected).\n\n" );
+ goto cleanup;
+ }
+
+ if ( arg.forcedRendMode == IVAS_DEC_FORCE_REND_TD_RENDERER )
+ {
+ fprintf( stdout, "Forcing rendering to: TD renderer\n" );
+ }
+ else if ( arg.forcedRendMode == IVAS_DEC_FORCE_REND_CLDFB_RENDERER )
+ {
+ fprintf( stdout, "Forcing rendering to: CLDFB renderer\n" );
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Open Error pattern file for simulation
+ *-----------------------------------------------------------------*/
+
+ if ( arg.FEPatternFileName != NULL )
+ {
+ if ( ( FEC_pattern = fopen( arg.FEPatternFileName, "rb" ) ) == NULL )
+ {
+ fprintf( stderr, "Error: Missing or incorrect FEC filename specification\n\n" );
+ usage_dec();
+ goto cleanup;
+ }
+ }
+
+#ifdef DEBUG_SBA_AUDIO_DUMP
+ ivas_open_sba_decoder_debug_files( arg.output_Fs, 1, 1 );
+#endif
+
+ /*-----------------------------------------------------------------*
+ * Print information about FEC
+ *-----------------------------------------------------------------*/
+
+ if ( !arg.voipMode && ( arg.FEPatternFileName != NULL || arg.FER > 0 ) )
+ {
+ if ( arg.FEPatternFileName != NULL )
+ {
+ fprintf( stdout, "FEC: %s\n", arg.FEPatternFileName );
+ }
+ else
+ {
+ fprintf( stdout, "FEC: %.2f %%\n", arg.FER );
+ }
+ }
+#else
IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode );
+#endif
/*-------------------------------------------------------------------*
* Load renderer configuration from file
@@ -584,6 +723,16 @@ int main(
goto cleanup;
}
+#ifdef DEBUGGING
+ if ( ( cnt_frames_limited = IVAS_DEC_GetCntFramesLimited( hIvasDec ) ) > 0 )
+ {
+ fprintf( stdout, "Limiter applied in %d frames.\n\n", cnt_frames_limited );
+ }
+ if ( ( noClipping = IVAS_DEC_GetNoCLipping( hIvasDec ) ) > 0 )
+ {
+ fprintf( stdout, "Clipping (saturation) detected: %d samples clipped!!!\n\n", noClipping );
+ }
+#endif
/*------------------------------------------------------------------------------------------*
* Close files and deallocate resources
@@ -595,6 +744,10 @@ cleanup:
free( pcmBuf );
+#ifdef DEBUG_SBA_AUDIO_DUMP
+ IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels );
+
+#endif
if ( arg.hrtfReaderEnabled )
{
IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;
@@ -628,6 +781,12 @@ cleanup:
printf( "\n" );
}
+#ifdef DEBUGGING
+#ifdef DEBUG_SBA_AUDIO_DUMP
+ ivas_close_sba_decoder_debug_files( arg.output_Fs, numOutChannels, numTransportChannels, pca_ingest_channels );
+#endif
+ dbgclose();
+#endif
return mainFailed ? -1 : 0;
}
@@ -728,6 +887,14 @@ static bool parseCmdlIVAS_dec(
int16_t i;
char argv_to_upper[FILENAME_MAX];
+#ifdef DEBUGGING
+ float ftmp;
+
+ arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED;
+#ifdef DEBUG_FOA_AGC
+ arg->agcBitstream = NULL;
+#endif
+#endif
arg->output_Fs = 48000;
arg->outputConfig = IVAS_AUDIO_CONFIG_MONO;
arg->decMode = IVAS_DEC_MODE_IVAS;
@@ -770,6 +937,13 @@ static bool parseCmdlIVAS_dec(
arg->non_diegetic_pan_gain = 0.f;
arg->tsmEnabled = false;
arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS;
+#ifdef DEBUGGING
+#ifdef VARIABLE_SPEED_DECODING
+ arg->tsmScale = 100;
+ arg->tsmScaleFileEnabled = false;
+ arg->tsmScaleFileName = NULL;
+#endif
+#endif
arg->acousticEnvironmentId = 65535;
for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
{
@@ -864,6 +1038,75 @@ static bool parseCmdlIVAS_dec(
i++;
}
}
+#ifdef DEBUGGING
+ else if ( strcmp( argv_to_upper, "-FEC" ) == 0 )
+ {
+ ftmp = 0.0f;
+ if ( sscanf( argv[i + 1], "%f", &ftmp ) != 1 )
+ {
+ arg->FEPatternFileName = argv[i + 1];
+ }
+ else
+ {
+ arg->FER = ftmp;
+ }
+ i += 2;
+ }
+ else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 )
+ {
+ i++;
+ if ( i < argc - 3 )
+ {
+ strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 );
+ argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0';
+ arg->forcedRendMode = parseForcedRendModeDec( argv_to_upper );
+ i++;
+ }
+ }
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ /* Define additional subfolder for debug info output in ./res */
+ else if ( strcmp( argv_to_upper, "-INFO" ) == 0 )
+ {
+ extern char infoFolder[FILENAME_MAX];
+ strncpy( infoFolder, argv[i + 1], sizeof( infoFolder ) );
+ i += 2;
+ }
+#endif /* #ifdef DEBUG_MODE_INFO_TWEAK */
+#endif /* #ifdef DEBUG_MODE_INFO */
+#ifdef VARIABLE_SPEED_DECODING
+ else if ( strcmp( argv_to_upper, "-VS" ) == 0 )
+ {
+ i++;
+ int32_t tmp = 100;
+ arg->tsmEnabled = true;
+ if ( i < argc - 3 )
+ {
+ if ( !is_digits_only( argv[i] ) )
+ {
+ arg->tsmScaleFileEnabled = true;
+ arg->tsmScaleFileName = argv[i];
+ i++;
+ }
+ else
+ {
+ if ( ( sscanf( argv[i], "%d", &tmp ) > 0 ) )
+ {
+ i++;
+ }
+ }
+ arg->tsmScale = (uint16_t) tmp;
+
+ if ( arg->tsmScale < 50 || arg->tsmScale > 150 )
+ {
+ fprintf( stderr, "Error: Scaling factor value must be 50 <= fac <= 150!\n\n" );
+ usage_dec();
+ return false;
+ }
+ }
+ }
+#endif
+#endif /* #ifdef DEBUGGING */
else if ( strcmp( argv_to_upper, "-MIME" ) == 0 )
{
@@ -1248,6 +1491,12 @@ static void usage_dec( void )
fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" );
#ifdef SUPPORT_JBM_TRACEFILE
fprintf( stdout, "-Tracefile TF : VoIP mode: Generate trace file named TF\n" );
+#endif
+#ifdef DEBUGGING
+#ifdef VARIABLE_SPEED_DECODING
+ fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent.\n" );
+ fprintf( stdout, " 50 <= fac <= 150; fac<100 faster, fac>100 slower\n" );
+#endif
#endif
fprintf( stdout, "-fr L : render frame size in ms L=(5,10,20), default is 20)\n" );
fprintf( stdout, "-fec_cfg_file : Optimal channel aware configuration computed by the JBM \n" );
@@ -1271,6 +1520,14 @@ static void usage_dec( void )
fprintf( stdout, "-render_config File : Renderer configuration File\n" );
fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" );
fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" );
+#ifdef DEBUGGING
+ fprintf( stdout, "-FEC X : Insert frame erasures, X = 0-10 is the percentage\n" );
+ fprintf( stdout, " of erased frames, or X may be the name of binary file or \n" );
+ fprintf( stdout, " file with G192 headers indicating GOOD FRAME or BAD FRAME\n" );
+ fprintf( stdout, " containing FEC pattern (short values of 0 (good) or 1 (bad))\n" );
+ fprintf( stdout, " default is OFF, if this option is not used\n" );
+ fprintf( stdout, "-force R : Force specific binaural rendering mode, R = (TDREND, CLDFBREND),\n" );
+#endif
fprintf( stdout, "-exof File : External orientation File for external orientation trajectory\n" );
fprintf( stdout, "-dpid ID : Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up\n" );
fprintf( stdout, " to 4 numbers (unsigned integers) can be specified for BINAURAL and BINAURAL_ROOM_REVERB\n" );
@@ -1282,11 +1539,30 @@ static void usage_dec( void )
fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" );
fprintf( stdout, "-q : Quiet mode, no frame counter\n" );
fprintf( stdout, " default is deactivated\n" );
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ fprintf( stdout, "-info : specify subfolder name for debug output\n" );
+#endif
+#endif
fprintf( stdout, "\n" );
return;
}
+#ifdef DEBUGGING
+/*---------------------------------------------------------------------*
+ * app_own_random()
+ *
+ * Generator of random numbers
+ *---------------------------------------------------------------------*/
+
+static int16_t app_own_random( int16_t *seed )
+{
+ *seed = (int16_t) ( *seed * 31821L + 13849L );
+
+ return ( *seed );
+}
+#endif
/*---------------------------------------------------------------------*
@@ -1477,6 +1753,9 @@ static ivas_error decodeG192(
uint16_t bit_stream[IVAS_MAX_BITS_PER_FRAME + 4 * 8];
int16_t i, num_bits;
int16_t bfi = 0;
+#ifdef DEBUGGING
+ int16_t fec_seed = 12558; /* FEC_SEED */
+#endif
AudioFileWriter *afWriter = NULL;
MasaFileWriter *masaWriter = NULL;
bool decodedGoodFrame = false;
@@ -1492,6 +1771,12 @@ static ivas_error decodeG192(
uint16_t nSamplesAvailableNext;
bool needNewFrame;
int16_t nSamplesRendered, nSamplesRendered_loop, nSamplesToRender;
+#ifdef DEBUGGING
+#ifdef VARIABLE_SPEED_DECODING
+ TsmScaleFileReader *tsmScaleFileReader = NULL;
+ int16_t scale;
+#endif
+#endif
IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
int16_t vec_pos_update, vec_pos_len;
@@ -1535,6 +1820,42 @@ static ivas_error decodeG192(
return error;
}
+#ifdef DEBUGGING
+#ifdef VARIABLE_SPEED_DECODING
+ /*------------------------------------------------------------------------------------------*
+ * Open TSM scale file or set global TSM scale
+ *------------------------------------------------------------------------------------------*/
+
+ if ( arg.tsmEnabled )
+ {
+ if ( arg.tsmScaleFileEnabled )
+ {
+ if ( ( tsmScaleFileReader = TsmScaleFileReader_open( arg.tsmScaleFileName ) ) == NULL )
+ {
+ fprintf( stderr, "\nError: Can't open TSM scale file %s \n\n", arg.tsmScaleFileName );
+ goto cleanup;
+ }
+ }
+ else
+ {
+ int16_t maxScaling;
+ /* max scaling as abs diff to the normal frame size in samples */
+ maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) );
+ if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, arg.tsmScale ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+ /* set lowest possbile TSM quality to make sure it is applied as much as possible */
+ if ( ( error = IVAS_DEC_TSM_SetQuality( hIvasDec, -2.0f ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_DEC_TSM_SetQuality failed: %s \n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+#endif
+#endif
/*------------------------------------------------------------------------------------------*
* Loop for every packet (frame) of bitstream data
@@ -1645,6 +1966,26 @@ static ivas_error decodeG192(
{
if ( needNewFrame )
{
+#ifdef DEBUGGING
+#ifdef VARIABLE_SPEED_DECODING
+ if ( arg.tsmScaleFileEnabled )
+ {
+ if ( ( error = TsmScaleFileReader_readScale( tsmScaleFileReader, &scale ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename );
+ goto cleanup;
+ }
+ int16_t maxScaling;
+ /* max scaling as abs diff to the normal frame size in samples */
+ maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) );
+ if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, arg.tsmScale ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+#endif
+#endif
if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK )
{
if ( error == IVAS_ERR_END_OF_FILE )
@@ -1655,6 +1996,21 @@ static ivas_error decodeG192(
goto cleanup;
}
+#ifdef DEBUGGING
+ /* Random FEC simulation */
+ if ( arg.FER > 0.0f )
+ {
+ float ftmp = (float) app_own_random( &fec_seed ) + 32768.0f;
+ if ( ftmp <= arg.FER / 100.0f * 65535.0f )
+ {
+ bfi = 1;
+ }
+ else
+ {
+ bfi = 0;
+ }
+ }
+#endif
/* Feed into decoder */
if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK )
{
@@ -1677,6 +2033,12 @@ static ivas_error decodeG192(
if ( !arg.quietModeEnabled )
{
fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame );
+#ifdef DEBUGGING
+ if ( IVAS_DEC_GetBerDetectFlag( hIvasDec ) )
+ {
+ fprintf( stdout, "\n Decoding error: BER detected in frame %d !!!!!\n", frame - 1 );
+ }
+#endif
}
}
@@ -1911,6 +2273,12 @@ static ivas_error decodeG192(
if ( !arg.quietModeEnabled )
{
fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame );
+#ifdef DEBUGGING
+ if ( IVAS_DEC_GetBerDetectFlag( hIvasDec ) )
+ {
+ fprintf( stdout, "\n Decoding error: BER detected in frame %d !!!!!\n", frame - 1 );
+ }
+#endif
}
}
@@ -1968,6 +2336,11 @@ cleanup:
AudioFileWriter_close( &afWriter );
MasaFileWriter_close( &masaWriter );
+#ifdef DEBUGGING
+#ifdef VARIABLE_SPEED_DECODING
+ TsmScaleFileReader_close( &tsmScaleFileReader );
+#endif
+#endif
for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
{
IsmFileWriter_close( &ismWriters[i] );
@@ -1981,6 +2354,106 @@ cleanup:
return error;
}
+#ifdef DEBUGGING
+/*---------------------------------------------------------------------*
+ * printBitstreamInfoVoip()
+ *
+ * Print bitstream info of a VoIP G.192 or RTPDUMP bitstream.
+ *---------------------------------------------------------------------*/
+
+static ivas_error printBitstreamInfoVoip(
+ DecArguments arg,
+ BS_READER_HANDLE hBsReader,
+ IVAS_DEC_HANDLE hIvasDec )
+{
+ bool previewFailed = true;
+ ivas_error error = IVAS_ERR_OK;
+ FILE *f_rtpstream = NULL;
+ EVS_RTPDUMP_DEPACKER rtpdumpDepacker;
+ EVS_RTPDUMP_DEPACKER_ERROR rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_NO_ERROR;
+ uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3];
+ int16_t auSizeBits;
+ uint8_t *auPtr = NULL;
+ bool isAMRWB_IOmode;
+ uint16_t frameTypeIndex;
+ bool qBit;
+ uint32_t nextPacketRcvTime_ms = 0;
+ uint16_t rtpSequenceNumber;
+ uint32_t rtpTimeStamp;
+
+ rtpdumpDepacker.rtpdump = NULL;
+ switch ( arg.inputFormat )
+ {
+ case IVAS_DEC_INPUT_FORMAT_RTPDUMP:
+ case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF:
+ f_rtpstream = fopen( arg.inputBitstreamFilename, "r" );
+
+ if ( f_rtpstream == NULL )
+ {
+ fprintf( stderr, "could not open: %s\n", arg.inputBitstreamFilename );
+ goto cleanup;
+ }
+
+ rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_open( &rtpdumpDepacker, f_rtpstream, arg.inputFormat == IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF );
+ if ( rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR )
+ {
+ fprintf( stderr, "error in EVS_RTPDUMP_DEPACKER_open(): %d\n", rtpdumpDepackerError );
+ goto cleanup;
+ }
+ break;
+ case IVAS_DEC_INPUT_FORMAT_G192:
+ auPtr = au;
+ break;
+ default:
+ fprintf( stderr, "Unsupported format of input bitstream" );
+ goto cleanup;
+ }
+
+ /* Keep reading until full frame is found */
+ do
+ {
+ if ( arg.inputFormat == IVAS_DEC_INPUT_FORMAT_G192 )
+ {
+ error = BS_Reader_ReadVoipFrame_compact( hBsReader, au, &auSizeBits, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms );
+ qBit = 1; /* good q_bit for INPUT_FORMAT_G192 */
+ }
+ else
+ {
+ auPtr = au; /* might have been set to RTP packet in prev call */
+ rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSizeBits );
+
+ /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
+ rtpTimeStamp = rtpTimeStamp / 16;
+ }
+ if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR )
+ {
+ fprintf( stderr, "failed to read first RTP packet\n" );
+ goto cleanup;
+ }
+ } while ( !qBit || auSizeBits < MIN_NUM_BITS_ACTIVE_FRAME || auSizeBits == NUM_BITS_SID_IVAS_5K2 );
+
+ BS_Reader_Rewind( hBsReader );
+
+ IVAS_DEC_PrintConfigWithVoipBitstream( hIvasDec, arg.quietModeEnabled, au, auSizeBits );
+
+ /*------------------------------------------------------------------------------------------*
+ * Close fhandles and deallocate resources
+ *------------------------------------------------------------------------------------------*/
+
+ previewFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */
+
+cleanup:
+
+ EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker );
+
+ if ( previewFailed && error == IVAS_ERR_OK )
+ {
+ return IVAS_ERR_UNKNOWN;
+ }
+
+ return IVAS_ERR_OK;
+}
+#endif
#ifdef SUPPORT_JBM_TRACEFILE
static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer )
@@ -2516,5 +2989,28 @@ cleanup:
}
+#ifdef DEBUGGING
+
+/*---------------------------------------------------------------------*
+ * parseForcedRendModeDec()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec(
+ char *forcedRendModeChar )
+{
+ if ( ( strcmp( to_upper( forcedRendModeChar ), "TDREND" ) == 0 ) )
+ {
+ return IVAS_DEC_FORCE_REND_TD_RENDERER;
+ }
+ if ( ( strcmp( to_upper( forcedRendModeChar ), "CLDFBREND" ) == 0 ) )
+ {
+ return IVAS_DEC_FORCE_REND_CLDFB_RENDERER;
+ }
+
+ return IVAS_DEC_FORCE_REND_UNDEFINED;
+}
+#endif
#undef WMC_TOOL_SKIP
diff --git a/apps/encoder.c b/apps/encoder.c
index c255170a78fcdd028e9a76265f475db64190547d..21aa5d0b1d489552451f01b734accc94497f1e18 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -38,6 +38,9 @@
#include "ism_file_reader.h"
#include "jbm_file_reader.h"
#include "masa_file_reader.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
@@ -47,7 +50,7 @@
* Local constants, enums
*------------------------------------------------------------------------------------------*/
-#if !defined( WMOPS )
+#if !defined( DEBUGGING ) && !defined( WMOPS )
static
#endif
int32_t frame = 0; /* Counter of frames */
@@ -60,6 +63,10 @@ typedef union _EncInputFormatConfig
/* MONO details */
bool stereoToMonoDownmix;
+#ifdef DEBUGGING
+ /* STEREO details */
+ IVAS_ENC_STEREO_MODE stereoMode;
+#endif
/* ISM details */
struct EncIsmConfig
@@ -124,6 +131,19 @@ typedef struct
const char *ca_config_file;
bool mimeOutput;
IVAS_ENC_COMPLEXITY_LEVEL complexityLevel;
+#ifdef DEBUGGING
+ IVAS_ENC_FORCED_MODE forcedMode;
+ const char *forcedModeFile;
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ IVAS_ENC_AGC agc;
+#endif
+#ifdef DEBUG_FOA_AGC
+ FILE *agcBitstream; /* temporary */
+#endif
+#ifdef DEBUG_SBA
+ const char *dbg_file_tag;
+#endif
+#endif
bool pca;
bool ism_extended_metadata;
@@ -139,6 +159,10 @@ static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg );
static void usage_enc( void );
static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter );
static bool readBitrate( FILE *file, int32_t *bitrate );
+#ifdef DEBUGGING
+static ivas_error readForcedMode( FILE *file, IVAS_ENC_FORCED_MODE *forcedMode, int32_t *forceFrameCounter );
+static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar );
+#endif
/*------------------------------------------------------------------------------------------*
@@ -166,7 +190,16 @@ int main(
MasaFileReader *masaReader = NULL;
IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS] = { NULL, NULL, NULL, NULL };
int16_t *pcmBuf = NULL;
+#ifdef DEBUGGING
+ FILE *f_forcedModeProfile = NULL;
+#ifdef DEBUG_SBA
+ int16_t numTransportChannels = 1;
+#endif
+#endif
+#ifdef DEBUGGING
+ dbgargs( &argc, argv );
+#endif
#ifdef WMOPS
reset_wmops();
reset_mem( USE_BYTES );
@@ -349,7 +382,11 @@ int main(
}
break;
case IVAS_ENC_INPUT_STEREO:
+#ifdef DEBUGGING
+ if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural, arg.inputFormatConfig.stereoMode ) ) != IVAS_ERR_OK )
+#else
if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural ) ) != IVAS_ERR_OK )
+#endif
{
fprintf( stderr, "\nIVAS_ENC_ConfigureForStereo failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
goto cleanup;
@@ -364,7 +401,14 @@ int main(
break;
case IVAS_ENC_INPUT_SBA:
if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar,
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ arg.agc,
+#endif
arg.pca
+#ifdef DEBUG_SBA_AUDIO_DUMP
+ ,
+ &numTransportChannels
+#endif
) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
@@ -499,6 +543,20 @@ int main(
}
}
+#ifdef DEBUGGING
+ IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode;
+ int32_t force_profile_cnt = 0;
+
+ if ( arg.forcedModeFile )
+ {
+ if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL )
+ {
+ fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile );
+ usage_enc();
+ goto cleanup;
+ }
+ }
+#endif
/*------------------------------------------------------------------------------------------*
* Allocate input data buffer
@@ -538,6 +596,12 @@ int main(
int16_t numSamplesRead = 0;
uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME];
uint16_t numBits = 0;
+#ifdef DEBUG_SBA
+#ifdef DEBUG_AGC
+ ivas_open_agc_debug_files( (int16_t) arg.agc );
+#endif
+ ivas_open_sba_encoder_debug_files( arg.inputFs, numTransportChannels, arg.dbg_file_tag, arg.initBitrate, (int16_t) arg.dtxConfig.enabled );
+#endif
if ( !arg.quietModeEnabled )
{
@@ -633,6 +697,26 @@ int main(
}
}
+#ifdef DEBUGGING
+ if ( f_forcedModeProfile )
+ {
+ if ( ( error = readForcedMode( f_forcedModeProfile, &forcedMode, &force_profile_cnt ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError reading from file: %s\n%s\n", arg.forcedModeFile, IVAS_ENC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+
+ /* Force mode not set when configuring, set in first frame even if not reading from file */
+ if ( f_forcedModeProfile || frame == 0 )
+ {
+ if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+#endif
/* Read ISM input metadata */
for ( i = 0; i < numIsmInputs; ++i )
{
@@ -707,6 +791,9 @@ int main(
fprintf( stdout, "\n\nEncoding of %d frames finished\n", frame );
}
+#ifdef DEBUGGING
+ print_snr();
+#endif
/*------------------------------------------------------------------------------------------*
* Close files and deallocate resources
*------------------------------------------------------------------------------------------*/
@@ -758,6 +845,21 @@ cleanup:
#ifdef WMOPS
print_wmops();
print_mem( NULL );
+#endif
+#ifdef DEBUGGING
+ dbgclose();
+
+ if ( f_forcedModeProfile )
+ {
+ fclose( f_forcedModeProfile );
+ }
+
+#ifdef DEBUG_SBA
+ ivas_close_sba_encoder_debug_files();
+#ifdef DEBUG_AGC
+ ivas_close_agc_debug_files();
+#endif
+#endif
#endif
return mainFailed ? -1 : 0;
@@ -794,6 +896,19 @@ static void initArgStruct( EncArguments *arg )
arg->ism_extended_metadata = false;
arg->complexityLevel = IVAS_ENC_COMPLEXITY_LEVEL_THREE;
+#ifdef DEBUGGING
+ arg->forcedMode = IVAS_ENC_FORCE_UNFORCED;
+ arg->forcedModeFile = NULL;
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ arg->agc = IVAS_ENC_AGC_UNDEFINED;
+#endif
+#ifdef DEBUG_FOA_AGC
+ arg->agcBitstream = NULL;
+#endif
+#ifdef DEBUG_SBA
+ arg->dbg_file_tag = NULL;
+#endif
+#endif
arg->pca = false;
return;
@@ -923,6 +1038,91 @@ static bool parseCmdlIVAS_enc(
}
}
+#ifdef DEBUGGING
+ /*-----------------------------------------------------------------*
+ * Force specific mode
+ *-----------------------------------------------------------------*/
+
+ else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 )
+ {
+ strncpy( stmp, argv[i + 1], sizeof( stmp ) );
+
+ arg->forcedMode = parseForcedMode( stmp );
+
+ if ( arg->forcedMode == IVAS_ENC_FORCE_UNDEFINED )
+ {
+ arg->forcedModeFile = argv[i + 1];
+ fprintf( stdout, "Force switching file: %s\n", argv[i + 1] );
+ }
+ else
+ {
+ fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] );
+ }
+
+ i += 2;
+ }
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ /*-----------------------------------------------------------------*
+ * Define additional subfolder for debug info output in ./res
+ *-----------------------------------------------------------------*/
+ else if ( strcmp( argv_to_upper, "-INFO" ) == 0 )
+ {
+ extern char infoFolder[FILENAME_MAX];
+ strncpy( infoFolder, argv[i + 1], sizeof( infoFolder ) );
+ i += 2;
+ }
+#endif /* #ifdef DEBUG_MODE_INFO_TWEAK */
+#endif /* #ifdef DEBUG_MODE_INFO */
+
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ /*-----------------------------------------------------------------*
+ * IVAS SPAR AGC option
+ *-----------------------------------------------------------------*/
+ else if ( strcmp( argv_to_upper, "-AGC" ) == 0 )
+ {
+ i++;
+ if ( i < argc - 4 )
+ {
+ arg->agc = ( atoi( argv[i] ) ) ? IVAS_ENC_AGC_ENABLED : IVAS_ENC_AGC_DISABLED;
+ if ( argv[i] == NULL || atoi( argv[i] ) < 0 || atoi( argv[i] ) > 1 )
+ {
+ fprintf( stderr, "Error: wrong adaptive gain control option specified (%d), expected 0 or 1\n\n", (int32_t) atoi( argv[i] ) );
+ usage_enc();
+ return false;
+ }
+ i++;
+ }
+ else
+ {
+ fprintf( stderr, "Error: unspecified adaptive gain control option\n\n" );
+ usage_enc();
+ return false;
+ }
+ }
+#endif
+
+#ifdef DEBUG_SBA
+ /*-----------------------------------------------------------------*
+ * IVAS SPAR debug files tag
+ *-----------------------------------------------------------------*/
+ else if ( strcmp( argv_to_upper, "-TAG" ) == 0 )
+ {
+ i++;
+ if ( i < argc - 4 )
+ {
+ arg->dbg_file_tag = argv[i];
+ ++i;
+ }
+ else
+ {
+ fprintf( stderr, "Error: [IVAS SPAR Encoder] unspecified tag value \n\n" );
+ usage_enc();
+ return false;
+ }
+ }
+#endif
+#endif /* #ifdef DEBUGGING */
/*-----------------------------------------------------------------*
* deactivate delay compensation
@@ -1027,6 +1227,77 @@ static bool parseCmdlIVAS_enc(
i++;
arg->inputFormat = IVAS_ENC_INPUT_STEREO;
+#ifdef DEBUGGING
+ if ( ( i < argc - 4 ) && argv[i][0] != 45 ) /* note: 45 corresponds to "-" */
+ {
+ if ( sscanf( argv[i], "%d", &tmp ) > 0 )
+ {
+ if ( tmp == 1 )
+ {
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_DFT;
+ i++;
+ }
+ else if ( tmp == 2 )
+ {
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_TD;
+ i++;
+ }
+ else if ( tmp == 3 )
+ {
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_DECISION;
+#ifdef DEBUG_FORCE_MDCT_STEREO_MODE
+ i++;
+
+ /* force mdct stereo mode for debugging purposes */
+ if ( i < argc - 4 )
+ {
+ if ( sscanf( argv[i], "%d", &tmp ) > 0 )
+ {
+ if ( tmp == 0 )
+ {
+ /* keep "DECISION" */
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_DECISION;
+ i++;
+ }
+ else if ( tmp == 1 )
+ {
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_FORCE_LR;
+ i++;
+ }
+ else if ( tmp == 2 )
+ {
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_FORCE_MS;
+ i++;
+ }
+ else
+ {
+ fprintf( stderr, "Error: Incorrect mdct stereo coding method (%d) specified\n\n", tmp );
+ usage_enc();
+ return false;
+ }
+ }
+ }
+#endif
+ }
+ else
+ {
+ fprintf( stderr, "Error: Incorrect stereo mode (%d) specified\n\n", tmp );
+ usage_enc();
+ return false;
+ }
+ }
+ else
+ {
+ fprintf( stderr, "Error: Stereo mode not specified.\n\n" ); /* in the debugging stage */
+ usage_enc();
+ return false;
+ }
+ }
+ else
+ {
+ arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_UNIFIED;
+ }
+#endif /* DEBUGGING */
}
else if ( strcmp( argv_to_upper, "-BINAURAL" ) == 0 )
{
@@ -1623,6 +1894,23 @@ static void usage_enc( void )
fprintf( stdout, "-pca : activate PCA in SBA format FOA at 256 kbps \n" );
fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" );
fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" );
+#ifdef DEBUGGING
+ fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" );
+ fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" );
+#ifdef DEBUG_SBA
+ fprintf( stdout, "-tag : Tag name for intermediate debug files\n" );
+#endif
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ fprintf( stdout, "-agc op : SBA Adaptive gain control, op = (0, 1). \n" );
+ fprintf( stdout, " By default op is 1 (activated) for bitrates between 24400 and 32000,\n" );
+ fprintf( stdout, " otherwise it is 0 (deactivated) for all other bitrates\n" );
+#endif
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ fprintf( stdout, "-info : specify subfolder name for debug output\n" );
+#endif
+#endif
+#endif
fprintf( stdout, "-q : Quiet mode, no frame counters\n" );
fprintf( stdout, " default is deactivated\n" );
fprintf( stdout, "\n" );
@@ -1716,5 +2004,90 @@ static bool readBitrate(
}
+#ifdef DEBUGGING
+/*---------------------------------------------------------------------*
+ * parseForcedMode()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+static IVAS_ENC_FORCED_MODE parseForcedMode(
+ char *forcedModeChar )
+{
+ to_upper( forcedModeChar );
+
+ if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) ||
+ ( strcmp( forcedModeChar, "0" ) == 0 ) )
+ {
+ return IVAS_ENC_FORCE_SPEECH;
+ }
+ if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) )
+ {
+ return IVAS_ENC_FORCE_MUSIC;
+ }
+ if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) )
+ {
+ return IVAS_ENC_FORCE_ACELP;
+ }
+ if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) )
+ {
+ return IVAS_ENC_FORCE_GSC;
+ }
+ if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) )
+ {
+ return IVAS_ENC_FORCE_TCX;
+ }
+ if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) )
+ {
+ return IVAS_ENC_FORCE_HQ;
+ }
+
+ return IVAS_ENC_FORCE_UNDEFINED;
+}
+
+
+/*---------------------------------------------------------------------*
+ * readForcedMode()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+static ivas_error readForcedMode(
+ FILE *file,
+ IVAS_ENC_FORCED_MODE *forcedMode,
+ int32_t *forceFrameCounter )
+{
+ int16_t res;
+ char stmp[8];
+
+ if ( *forceFrameCounter == 0 )
+ {
+ /* read next force and number of frames from the profile file */
+ while ( ( res = (int16_t) fscanf( file, "%d %7s", forceFrameCounter, stmp ) ) != 2 && feof( file ) )
+ {
+ rewind( file );
+ }
+
+ *forcedMode = parseForcedMode( stmp );
+
+ if ( *forcedMode == IVAS_ENC_FORCE_UNDEFINED )
+ {
+ fprintf( stderr, "Error: incorect mode specification or the force profile file could not be opened: %s\n\n", stmp );
+ return IVAS_ERR_WRONG_PARAMS;
+ }
+
+ if ( res != 2 && !feof( file ) )
+ {
+ fprintf( stderr, "Error: incorrect format of the force profile file (please ensure that it does not contain any empty lines)\n\n" );
+ return IVAS_ERR_WRONG_PARAMS;
+ }
+ }
+
+ /* current profile still active, only decrease the counter */
+ ( *forceFrameCounter )--;
+
+ return IVAS_ERR_OK;
+}
+#endif
#undef WMC_TOOL_SKIP
diff --git a/apps/renderer.c b/apps/renderer.c
index 6ac6b0aa33c10215c038ea2fba2bdea0f173877f..24967f2cd2dabc7691cc683f4fe6e64ca1342794 100644
--- a/apps/renderer.c
+++ b/apps/renderer.c
@@ -46,6 +46,9 @@
#include "render_config_reader.h"
#include "rotation_file_reader.h"
#include "vector3_pair_file_reader.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
@@ -63,7 +66,7 @@
#define IVAS_MAX16B_FLT 32767.0f
#define IVAS_MIN16B_FLT ( -32768.0f )
-#if !defined( WMOPS )
+#if !defined( DEBUGGING ) && !defined( WMOPS )
static
#endif
int32_t frame = 0;
@@ -1545,6 +1548,17 @@ int main(
fprintf( stdout, "\n\nRendering of %d frames finished\n\n", frame );
+#ifdef DEBUGGING
+ int32_t cnt_frames_limited, noClipping;
+ if ( ( cnt_frames_limited = IVAS_REND_GetCntFramesLimited( hIvasRend ) ) > 0 )
+ {
+ fprintf( stdout, "Limiter applied in %d frames.\n\n", cnt_frames_limited );
+ }
+ if ( ( noClipping = IVAS_REND_GetNoCLipping( hIvasRend ) ) > 0 )
+ {
+ fprintf( stdout, "Clipping (saturation) detected: %d samples clipped!!!\n\n", noClipping );
+ }
+#endif
/* === Close === */
free( inpInt16Buffer );
@@ -1573,6 +1587,9 @@ int main(
IsmPositionProvider_close( positionProvider );
RenderConfigReader_close( &renderConfigReader );
+#ifdef DEBUGGING
+ dbgclose();
+#endif
#ifdef WMOPS
print_wmops();
print_mem( NULL );
diff --git a/lib_com/ACcontextMapping.c b/lib_com/ACcontextMapping.c
index 13cbe8482ba51ad3f2768d9e29d66198cd01810a..1705a3f7d353a66d075e8aedba7e096bbf8e241f 100644
--- a/lib_com/ACcontextMapping.c
+++ b/lib_com/ACcontextMapping.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c
index f27617b27828a0f54d713a99eb326e85ae4863c3..cc29c97477c0092860be5ea30582d716097fe805 100644
--- a/lib_com/arith_coder.c
+++ b/lib_com/arith_coder.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/basop_mpy.c b/lib_com/basop_mpy.c
index cb6268d6279abe7ff8e6c01bf0b9de7ee948fde2..db2a14c0b08d33792d79ebb389e3f6ac468c54e5 100644
--- a/lib_com/basop_mpy.c
+++ b/lib_com/basop_mpy.c
@@ -37,6 +37,9 @@
#include "basop_mpy.h"
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#define WMC_TOOL_SKIP
diff --git a/lib_com/basop_mpy.h b/lib_com/basop_mpy.h
index c35531fa6fcb5d4b1c6435b36d98ca76581f0c0b..4a8d4473c65b7d2df22393ac2f75de4c1479101f 100644
--- a/lib_com/basop_mpy.h
+++ b/lib_com/basop_mpy.h
@@ -40,6 +40,9 @@
#include "stl.h"
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
/**
* \brief 32*16 Bit fractional Multiplication using 40 bit OPS
diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c
index f57bf10a8b60c0f490f70d60e607772dc84cf84a..6d2c80f6b74c3cc635e40226eeb756e676faee0c 100644
--- a/lib_com/basop_tcx_utils.c
+++ b/lib_com/basop_tcx_utils.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "basop_proto_func.h"
#include "stl.h"
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index f3247f2d06246d9e0d53d1faff1077f7cbfe147e..0a168852b0a95b8cbc243a9563d19e9bf06a9907 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "basop_util.h"
#include "rom_com.h"
#include "basop_settings.h"
diff --git a/lib_com/bitalloc.c b/lib_com/bitalloc.c
index 351ab9e3a80b0334617b43c5960413fa35b42f4a..e560e300a1c7e9a94dd990010905be6f2f500a45 100644
--- a/lib_com/bitalloc.c
+++ b/lib_com/bitalloc.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/bitallocsum.c b/lib_com/bitallocsum.c
index 2daf67b731199ed05e9befb17c8c15e8d7b90e55..d3f880752d9bb05ef5a823cd574835946bdf5b42 100644
--- a/lib_com/bitallocsum.c
+++ b/lib_com/bitallocsum.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c
index 0d1611de6a28e895269dd9e15f16300274965527..cb3945a6ce41d683081b5c60a8eb523438f7b39c 100644
--- a/lib_com/bits_alloc.c
+++ b/lib_com/bits_alloc.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "rom_com.h"
#include "prot.h"
#include "ivas_cnst.h"
@@ -438,6 +441,16 @@ static ivas_error acelp_FCB_allocator(
}
}
cdbk--;
+#ifdef DEBUGGING
+ if ( cdbk < 0 && coder_type != TRANSITION )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bit-budget for fixed innovation codebook (frame = %d). Exiting! \n", frame );
+ }
+ if ( ( L_subfr == L_SUBFR && cdbk >= ACELP_FIXED_CDK_NB ) || ( L_subfr == 2 * L_SUBFR && fcb_table( cdbk, L_subfr ) == 128 /*stop value*/ ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bit-budget for fixed innovation codebook (frame = %d). Exiting! \n", frame );
+ }
+#endif
set_s( p_fixed_cdk_index, cdbk, nb_subfr );
nBits_tmp = 0;
@@ -547,6 +560,9 @@ ivas_error config_acelp1(
int16_t i, bits, nb_subfr;
int16_t flag_hardcoded, coder_type_sw, fix_first;
int32_t core_brate;
+#ifdef DEBUGGING
+ int32_t core_brate_inpI = core_brate_inp;
+#endif
ivas_error error;
error = IVAS_ERR_OK;
@@ -572,11 +588,28 @@ ivas_error config_acelp1(
{
nb_subfr = NB_SUBFR;
+#ifdef DEBUGGING
+ if ( ( ( core_brate_inp < 5900 && coder_type > UNVOICED ) && !( core_brate_inp < MIN_TC_BRATE && coder_type == TRANSITION ) ) && !( idchan > 0 && element_mode == IVAS_CPE_TD ) && !( element_mode == IVAS_SCE && tdm_low_rate_mode ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inpI, frame );
+ }
+
+ if ( core_brate_inp > ACELP_12k8_HIGH_LIMIT && core == ACELP_CORE )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inpI, frame );
+ }
+#endif
}
else /* L_frame == L_FRAME16k */
{
nb_subfr = NB_SUBFR16k;
+#ifdef DEBUGGING
+ if ( core_brate_inp < ACELP_16k_LOW_LIMIT && core == ACELP_CORE )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@16k in frame %d. Exiting!\n", core_brate_inpI, frame );
+ }
+#endif
}
coder_type_sw = coder_type;
@@ -999,6 +1032,14 @@ ivas_error config_acelp1(
}
acelp_cfg->fcb_mode = 1;
+#ifdef DEBUGGING
+ if ( bits >= 55 )
+ {
+ printf( "too much bits -> %d, LPC = %d and pitch = %d\n", bits, tdm_lp_reuse_flag, tdm_Pitch_reuse_flag );
+ acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
+ }
+ else
+#endif
if ( bits >= 16 )
{
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
@@ -1084,6 +1125,10 @@ ivas_error config_acelp1(
i--; /* must be odd */
}
i = min( i, 13 );
+#ifdef DEBUG_MODE_TD
+ if ( i < 0 )
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR::: UC negative index should not happen at frame %d\n", frame );
+#endif
i = max( i, 0 ); /* If i == 0-> random noise generator will be used as FCB */
set_s( acelp_cfg->fixed_cdk_index, i, NB_SUBFR );
bits -= ( i * NB_SUBFR );
@@ -1120,6 +1165,9 @@ ivas_error config_acelp1(
}
else /* No FCB */
{
+#ifdef DEBUGGING
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING!!!, No bit allocated to FCB, check frame %d\n", frame );
+#endif
acelp_cfg->fixed_cdk_index[0] = -1;
acelp_cfg->fixed_cdk_index[1] = -1;
acelp_cfg->fixed_cdk_index[2] = -1;
@@ -1273,6 +1321,9 @@ ivas_error config_acelp1(
}
else if ( flag_hardcoded && core == ACELP_CORE && bits != 0 )
{
+#ifdef DEBUGGING
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (int32_t) bits, frame );
+#endif
}
else if ( bits > 0 && !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) )
{
@@ -1307,6 +1358,12 @@ ivas_error config_acelp1(
bits -= allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits );
}
}
+#ifdef DEBUGGING
+ if ( idchan > 0 && bits > 0 && ( coder_type > UNVOICED || tdm_low_rate_mode == 0 ) )
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING !! Unused bits in secondary channel at frame %d\n", frame );
+ }
+#endif
}
else if ( core == ACELP_CORE && coder_type >= UNVOICED && coder_type <= GENERIC && L_frame == L_FRAME )
@@ -1331,6 +1388,9 @@ ivas_error config_acelp1(
}
else if ( bits < 0 && !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) )
{
+#ifdef DEBUGGING
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (int32_t) bits, frame );
+#endif
}
}
@@ -1400,6 +1460,9 @@ static int16_t allocate_unused(
}
else
{
+#ifdef DEBUG_MODE_TD
+ IVAS_ERROR( IVAS_ERR_WRONG_MODE, "unknown mode in bit_alloc.c" );
+#endif
}
max_bit_per_pos = min( unused_bits, max_bit_per_pos - prm_bit_mode[subfr] );
diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c
index 0aeed3040c4af49e164afc853feb42f903430095..4a24d905a89923cc381917f38b919cc9c1260d84 100644
--- a/lib_com/bitstream.c
+++ b/lib_com/bitstream.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "stat_enc.h"
@@ -48,6 +51,16 @@
#include "ivas_rom_com.h"
#include "wmc_auto.h"
+#ifdef DEBUGGING
+
+#define FEC_SEED 12558
+
+/*-------------------------------------------------------------------*
+ * Global variables
+ *--------------------------------------------------------------------*/
+
+FILE *FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */
+#endif
#define STEP_MAX_NUM_INDICES 100 /* increase the maximum number of allowed indices in the list by this amount */
@@ -830,6 +843,9 @@ ivas_error check_ind_list_limits(
/* the re-allocation can be avoided by increasing the limits in get_ivas_max_num_indices() or get_ivas_max_num_indices_metadata() */
if ( ( &hBstr->ind_list[hBstr->nb_ind_tot] - ivas_ind_list_zero ) >= *( hBstr->ivas_max_num_indices ) )
{
+#ifdef DEBUGGING
+ fprintf( stderr, "Warning: The maximum number of indices %d has been exceeded in frame %d! Increase the limits in get_ivas_max_num_indices() or get_max_num_indices_metadata().\n", *( hBstr->ivas_max_num_indices ), frame );
+#endif
/* reallocate the buffer of indices with increased limit */
if ( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
@@ -843,6 +859,9 @@ ivas_error check_ind_list_limits(
{
if ( hBstr->nb_ind_tot == 0 )
{
+#ifdef DEBUGGING
+ fprintf( stderr, "Warning: Trying to overwrite an existing indice ID = %d in frame %d!\n", hBstr->ind_list[hBstr->nb_ind_tot].id, frame );
+#endif
/* move the pointer to the next available empty slot */
ivas_ind_list_last = &ivas_ind_list_zero[*( hBstr->ivas_max_num_indices )];
while ( hBstr->ind_list[0].nb_bits > 0 && hBstr->ind_list < ivas_ind_list_last )
@@ -852,6 +871,9 @@ ivas_error check_ind_list_limits(
if ( hBstr->ind_list >= ivas_ind_list_last )
{
+#ifdef DEBUGGING
+ fprintf( stderr, "Warning: The maximum number of indices %d has been exceeded in frame %d! Increase the limits in get_ivas_max_num_indices() or get_max_num_indices_metadata().\n", *( hBstr->ivas_max_num_indices ), frame );
+#endif
/* no available empty slot -> need to re-allocate the buffer */
if ( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
@@ -876,11 +898,20 @@ ivas_error check_ind_list_limits(
* Push a new indice into the buffer
*-------------------------------------------------------------------*/
+#ifdef DEBUG_BS_READ_WRITE
+ivas_error push_indice_(
+#else
ivas_error push_indice(
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
int16_t id, /* i : ID of the indice */
uint16_t value, /* i : value of the quantized indice */
int16_t nb_bits /* i : number of bits used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
)
{
int16_t i;
@@ -889,6 +920,21 @@ ivas_error push_indice(
error = IVAS_ERR_OK;
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "%s: %d: %d: %d\n", func, line, nb_bits, value );
+#endif
+#ifdef DEBUGGING
+ if ( nb_bits < ( 32 - 1 ) && ( value >> nb_bits ) > 0 )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d with value %d exceeds the range of %d bits (frame %d) !\n", id, value, nb_bits, frame );
+ }
+
+ if ( nb_bits > 16 )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d with value %d is trying to allocate %d bits which exceeds 16 bits (frame %d) !\n", id, value, nb_bits, frame );
+ }
+
+#endif
/* check the limits of the list of indices */
if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
@@ -933,10 +979,19 @@ ivas_error push_indice(
* Push a new indice into the buffer at the next position
*-------------------------------------------------------------------*/
+#ifdef DEBUG_BS_READ_WRITE
+ivas_error push_next_indice_(
+#else
ivas_error push_next_indice(
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
uint16_t value, /* i : value of the quantized indice */
int16_t nb_bits /* i : number of bits used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
)
{
int16_t prev_id;
@@ -944,6 +999,21 @@ ivas_error push_next_indice(
error = IVAS_ERR_OK;
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "%s: %d: %d: %d\n", func, line, nb_bits, value );
+#endif
+#ifdef DEBUGGING
+ if ( nb_bits < ( 32 - 1 ) && ( value >> nb_bits ) > 0 )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice with value %d exceeds the range of %d bits (frame %d) !\n", value, nb_bits, frame );
+ }
+
+ if ( nb_bits > 16 )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice with value %d is trying to allocate %d bits which exceeds 16 bits !\n", value, nb_bits );
+ }
+
+#endif
/* check the limits of the list of indices */
if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
@@ -979,10 +1049,19 @@ ivas_error push_next_indice(
* Push a bit buffer into the buffer at the next position
*-------------------------------------------------------------------*/
+#ifdef DEBUG_BS_READ_WRITE
+ivas_error push_next_bits_(
+#else
ivas_error push_next_bits(
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const uint16_t bits[], /* i : bit buffer to pack, sequence of single bits */
const int16_t nb_bits /* i : number of bits to pack */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
)
{
uint16_t code;
@@ -992,6 +1071,9 @@ ivas_error push_next_bits(
ivas_error error;
error = IVAS_ERR_OK;
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "%s: %d: %d\n", func, line, nb_bits );
+#endif
ptr = &hBstr->ind_list[hBstr->nb_ind_tot];
@@ -1018,6 +1100,9 @@ ivas_error push_next_bits(
ptr = &hBstr->ind_list[hBstr->nb_ind_tot];
ptr->value = code;
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "code: %d\n", code );
+#endif
ptr->nb_bits = 16;
ptr->id = prev_id;
hBstr->nb_ind_tot++;
@@ -1034,6 +1119,9 @@ ivas_error push_next_bits(
ptr = &hBstr->ind_list[hBstr->nb_ind_tot];
ptr->value = bits[i];
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "value: %d\n", ptr->value );
+#endif
ptr->nb_bits = 1;
ptr->id = prev_id;
hBstr->nb_ind_tot++;
@@ -1129,9 +1217,18 @@ uint16_t delete_indice(
*-------------------------------------------------------------------*/
/*! r: value of the indice */
+#ifdef DEBUG_BS_READ_WRITE
+uint16_t get_next_indice_(
+#else
uint16_t get_next_indice(
+#endif
Decoder_State *st, /* i/o: decoder state structure */
int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
)
{
uint16_t value;
@@ -1154,6 +1251,9 @@ uint16_t get_next_indice(
value <<= 1;
value += st->bit_stream[st->next_bit_pos + i];
}
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "%s: %d: %d: %d\n", func, line, nb_bits, value );
+#endif
/* update the position in the bitstream */
st->next_bit_pos += nb_bits;
@@ -1210,10 +1310,19 @@ void get_next_indice_tmp(
*-------------------------------------------------------------------*/
/*! r: value of the indice */
+#ifdef DEBUG_BS_READ_WRITE
+uint16_t get_indice_(
+#else
uint16_t get_indice(
+#endif
Decoder_State *st, /* i/o: decoder state structure */
int16_t pos, /* i : absolute position in the bitstream (update after the read) */
int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
)
{
uint16_t value;
@@ -1237,6 +1346,9 @@ uint16_t get_indice(
value <<= 1;
value += st->bit_stream[pos + i];
}
+#ifdef DEBUG_BS_READ_WRITE
+ printf( "%s: %d: %d: %d\n", func, line, nb_bits, value );
+#endif
return value;
}
@@ -1355,6 +1467,9 @@ static int16_t write_indices_to_stream(
int16_t i, k;
int16_t value, nb_bits;
uint16_t mask;
+#ifdef ENABLE_BITRATE_VERIFICATION
+ int16_t total_nb_bits = 0;
+#endif
for ( i = 0; i < num_indices; i++ )
{
@@ -1363,6 +1478,9 @@ static int16_t write_indices_to_stream(
if ( nb_bits > 0 )
{
+#ifdef ENABLE_BITRATE_VERIFICATION
+ total_nb_bits += nb_bits;
+#endif
/* mask from MSB to LSB */
mask = 1 << ( nb_bits - 1 );
@@ -1383,8 +1501,22 @@ static int16_t write_indices_to_stream(
mask >>= 1;
}
}
+#ifdef DEBUGGING
+ else if ( nb_bits == 0 )
+ {
+ /* fprintf( stderr, "Warning: %s: nb_bits == 0!\n", __func__ ); */
+ }
+ else
+ {
+ /* fprintf( stderr, "Warning: %s: nb_bits == %d!\n", __func__, nb_bits ); */
+ }
+#endif
}
+#ifdef ENABLE_BITRATE_VERIFICATION
+ return total_nb_bits;
+#else
return 0;
+#endif
}
/*-------------------------------------------------------------------*
@@ -1410,6 +1542,9 @@ static ivas_error write_indices_element(
Indice *ind_list_metadata;
int16_t n, n_channels;
+#ifdef ENABLE_BITRATE_VERIFICATION
+ int16_t total_nb_bits;
+#endif
ivas_error error;
error = IVAS_ERR_OK;
@@ -1447,6 +1582,12 @@ static ivas_error write_indices_element(
nb_ind_tot_metadata = st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot;
}
}
+#ifdef DEBUGGING
+ else
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Bitstream writing error in frame %d. Exiting!\n", frame );
+ }
+#endif
}
n_channels = 1;
@@ -1476,15 +1617,33 @@ static ivas_error write_indices_element(
pt_stream_loc += nb_bits_tot_metadata - 1;
pt_stream_end = pt_stream_loc + 1;
+#ifdef ENABLE_BITRATE_VERIFICATION
+ total_nb_bits =
+#endif
write_indices_to_stream( ind_list_metadata, &pt_stream_loc, -1,
nb_ind_tot_metadata );
+#ifdef ENABLE_BITRATE_VERIFICATION
+ if ( total_nb_bits != nb_bits_tot_metadata )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Bitstream write size mismatch! Written bits: %d vs. Reference bits: %d\n", total_nb_bits, nb_bits_tot_metadata );
+ }
+#endif
/* restore previous pointer position */
pt_stream_loc = pt_stream_backup;
}
+#ifdef ENABLE_BITRATE_VERIFICATION
+ total_nb_bits =
+#endif
write_indices_to_stream( sts[n]->hBstr->ind_list, &pt_stream_loc, 1,
sts[n]->hBstr->nb_ind_tot );
+#ifdef ENABLE_BITRATE_VERIFICATION
+ if ( total_nb_bits != sts[n]->hBstr->nb_bits_tot )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Bitstream write size mismatch! Written bits: %d vs. Reference bits: %d\n", total_nb_bits, sts[n]->hBstr->nb_bits_tot );
+ }
+#endif
if ( pt_stream_loc > pt_stream_end )
{
pt_stream_end = pt_stream_loc;
@@ -1539,6 +1698,11 @@ ivas_error write_indices_ivas(
{
int16_t i, n;
uint16_t *pt_stream;
+#ifdef ENABLE_BITRATE_VERIFICATION
+ Encoder_State **sts;
+ int32_t ivas_total_brate;
+ int16_t ch;
+#endif
ivas_error error;
error = IVAS_ERR_OK;
@@ -1549,6 +1713,45 @@ ivas_error write_indices_ivas(
bit_stream[i] = 0;
}
+#ifdef ENABLE_BITRATE_VERIFICATION
+ i = 0;
+
+ for ( n = 0; n < st_ivas->nSCE; n++ )
+ {
+ sts = st_ivas->hSCE[n]->hCoreCoder;
+ i += sts[0]->hBstr->nb_bits_tot;
+
+ if ( st_ivas->hSCE[n]->hMetaData != NULL )
+ {
+ i += st_ivas->hSCE[n]->hMetaData->nb_bits_tot;
+ }
+ }
+
+ for ( n = 0; n < st_ivas->nCPE; n++ )
+ {
+ sts = st_ivas->hCPE[n]->hCoreCoder;
+ for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ {
+ i += sts[ch]->hBstr->nb_bits_tot;
+ }
+
+ if ( st_ivas->hCPE[n]->hMetaData != NULL )
+ {
+ i += st_ivas->hCPE[n]->hMetaData->nb_bits_tot;
+ }
+ }
+
+ ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate;
+ if ( st_ivas->hEncoderConfig->Opt_SC_VBR )
+ {
+ ivas_total_brate = st_ivas->hSCE[0]->hCoreCoder[0]->total_brate;
+ }
+
+ if ( i * FRAMES_PER_SEC != ivas_total_brate && i >= ACELP_11k60 / FRAMES_PER_SEC )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Bitstream write size mismatch! Actual bitrate: %ld vs. Reference bitrate: %d\n", i * 50L, ivas_total_brate );
+ }
+#endif
/*-----------------------------------------------------------------*
* Encode Payload
@@ -1663,6 +1866,9 @@ static void decoder_selectCodec(
st->codec_mode = MODE1;
break;
default: /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bitrates */
+#ifdef DEBUGGING
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "Error illegal total bitrate (= %d) \n", total_brate );
+#endif
st->codec_mode = st->last_codec_mode;
st->bfi = 1;
break;
@@ -1734,6 +1940,12 @@ static void dec_prm_core(
break;
}
}
+#ifdef DEBUGGING
+ if ( n == FRAME_SIZE_NB )
+ {
+ assert( !"Bitrate not supported: not part of EVS" );
+ }
+#endif
/* Get audio bandwidth info */
st->bwidth = get_next_indice( st, FrameSizeConfig[frame_size_index].bandwidth_bits );
@@ -1832,6 +2044,9 @@ static void decision_matrix_core_dec(
while ( acelp_sig_tbl[start_idx] != st->total_brate )
{
start_idx++;
+#ifdef DEBUGGING
+ assert( ( start_idx < 194 ) && "ERROR: start_idx larger than acelp_sig_tbl[].\n" );
+#endif
}
/* skip the bitrate */
@@ -1977,8 +2192,233 @@ void mdct_switching_dec(
return;
}
+#ifdef DEBUGGING
+#ifdef ALLOW_BYTE_EP
+/*-------------------------------------------------------------------*
+ * ep_type_check()
+ *
+ *
+ *-------------------------------------------------------------------*/
+static Word16 ep_type_check()
+{
+ static int16_t ep_type = -1; /* 0=G192 (0x6b21 or 0x6b20), 1=byte(0x21 or 0x20) ,
+ 2=ascii "0xa30" or "0xa31" , 3=short( 0x0000 or 0x0001) */
+ int16_t tmp;
+
+ if ( ep_type < 0 )
+ {
+ tmp = 0;
+
+ if ( fread( &tmp, sizeof( int16_t ), 1, FEC_pattern ) != 1 )
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error reading first two bytes from the FEC pattern file !" );
+ }
+ else
+ {
+ switch ( tmp )
+ {
+ case G192_SYNC_BAD_FRAME:
+ case G192_SYNC_GOOD_FRAME:
+ ep_type = 0; /* G192 */
+ break;
+ case 0x2020: /* BAD,BAD */
+ case 0x2021: /* BAD,SYNC */
+ case 0x2120: /* SYNC,BAD */
+ case 0x2121: /* SYNC,SYNC */
+ ep_type = 1; /* byte */
+ break;
+ case 0xa31:
+ case 0xa30:
+ ep_type = 2; /* ascii */
+ break;
+ case 0x0000:
+ case 0x0001:
+ ep_type = 3; /* short */
+ break;
+ default:
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error reading the FEC pattern file :: illegal format of the first two byte word=0x%02x ", tmp );
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Allowed formats are G192(0x6b20,0x6b21), byte(0x20,0x21), ASCII(\"0\n\" \"1\n\") or short(0x0000, 0x0001) \n" );
+ break;
+ }
+
+ fseek( FEC_pattern, 0L, SEEK_SET ); /* rewind */
+ }
+ }
+ return ep_type;
+}
+
+/*-------------------------------------------------------------------*
+ * ep_flag_check_apply()
+ *
+ *
+ *-------------------------------------------------------------------*/
+static Word16 ep_flag_check_apply(
+ Word16 ep_type,
+ Word16 tmp,
+ Word16 bfi_so_far )
+{
+ if ( ep_type == 0 && ( tmp == G192_SYNC_GOOD_FRAME || tmp == G192_SYNC_BAD_FRAME ) )
+ { /* g192 validity check */
+ if ( tmp == G192_SYNC_BAD_FRAME )
+ {
+ return 1;
+ }
+ }
+ else if ( ep_type == 1 && ( tmp == 0x0021 || tmp == 0x0020 ) )
+ { /* byte validity check*/
+ if ( tmp == 0x0020 )
+ {
+ return 1;
+ }
+ }
+ else if ( ep_type == 2 && ( tmp == 0x0a31 || tmp == 0x0a30 ) )
+ { /* ascii validity check */
+ if ( tmp == 0x0a31 )
+ {
+ return 1;
+ }
+ }
+ else if ( ep_type == 3 && ( tmp == 0 || tmp == 1 ) )
+ { /* short validity check */
+ if ( tmp == 0x0001 )
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error reading the FEC pattern flag 0x%02x from the type %d FEC pattern file , frame=%d", tmp, ep_type, frame );
+ }
+
+ return bfi_so_far; /* no change */
+}
+
+/*-------------------------------------------------------------------*
+ * read_error_flag ( )
+ *
+ *
+ *-------------------------------------------------------------------*/
+static Word16 read_error_flag(
+ Word16 bfi_so_far )
+{
+ Word16 tmp;
+ Word16 ep_type;
+ Word16 wrap;
+ wrap = 0;
+
+ ep_type = ep_type_check();
+ tmp = 0;
+
+ if ( ( ep_type == 1 ) ? ( fread( &tmp, sizeof( int8_t ), 1, FEC_pattern ) != 1 ) /* read byte directly stored in short variable */
+ : ( fread( &tmp, sizeof( int16_t ), 1, FEC_pattern ) != 1 ) )
+ {
+ if ( feof( FEC_pattern ) != 0 )
+ {
+ wrap = 1; /* wrap event flag */
+ fseek( FEC_pattern, 0L, SEEK_SET );
+#ifndef WRAP_AS_EIDXOR
+ /* good frame injected in wrap event */
+ switch ( ep_type )
+ {
+ case 0:
+ tmp = SYNC_GOOD_FRAME;
+ break;
+ case 1:
+ tmp = 0x21;
+ break;
+ case 2:
+ tmp = 0x0a30;
+ break;
+ default:
+ tmp = 0;
+ break; /* 4: short */
+ }
+#endif
+ }
+ else
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error reading the FEC pattern file !" );
+ }
+ }
+#ifdef WRAP_AS_EIDXOR
+ if ( wrap != 0 ) /* wrap file and read again, try to get the next flag , */
+ {
+ tmp = 0; /* needed for byte re-reading */
+ if ( ( ep_type == 1 ) ? ( fread( &tmp, sizeof( int8_t ), 1, FEC_pattern ) != 1 ) /* read byte directly stored in short variable */
+ : ( fread( &tmp, sizeof( int16_t ), 1, FEC_pattern ) != 1 ) )
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error reading the wrapped FEC pattern file !" );
+ }
+ }
+
+ return ep_flag_check_apply( ep_type, tmp, bfi_so_far );
+#else
+ if ( wrap == 0 )
+ {
+ return ep_flag_check_apply( ep_type, tmp, bfi_so_far );
+ }
+ else
+ {
+ return bfi_so_far;
+ }
+#endif
+}
+#endif
+#endif
+
+
+#ifdef DEBUGGING
+/*-------------------------------------------------------------------*
+ * file_read_FECpattern()
+ *
+ * Simulate packet losses by reading FEC pattern from external file
+ *-------------------------------------------------------------------*/
+
+static ivas_error file_read_FECpattern(
+ int16_t *bfi )
+{
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ *bfi = 0;
+
+ /* FEC pattern file provided */
+ if ( FEC_pattern != NULL )
+ {
+ int16_t tmp = 0;
+ if ( fread( &tmp, sizeof( int16_t ), 1, FEC_pattern ) != 1 )
+ {
+ if ( feof( FEC_pattern ) != 0 )
+ {
+#ifdef WRAP_AS_EIDXOR
+ fseek( FEC_pattern, 0L, SEEK_SET );
+ fread( &tmp, sizeof( int16_t ), 1, FEC_pattern );
+#else
+ tmp = 0;
+ fseek( FEC_pattern, 0L, SEEK_SET );
+#endif
+ }
+ else
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error reading the FEC pattern file !" );
+ }
+ }
+
+ if ( tmp == 2609 || tmp == 1 || tmp == (uint16_t) 0x6B20 /* == G192_SYNC_BAD_FRAME */ )
+ {
+ *bfi = 1;
+ }
+ else
+ {
+ *bfi = 0;
+ }
+ }
+
+ return error;
+}
+#endif
/*-------------------------------------------------------------------*
@@ -2060,6 +2500,277 @@ void ivas_set_bitstream_pointers(
}
+#ifdef DEBUGGING
+/*-------------------------------------------------------------------*
+ * preview_indices()
+ *
+ * Read indices from serial bitstream to the buffer to print out info
+ * about technologies.
+ *
+ * !!The read parmeters are temporary only and not used for decoding!!
+ *-------------------------------------------------------------------*/
+
+ivas_error preview_indices(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ uint16_t bit_stream[], /* i : bitstream buffer */
+ UWord16 num_bits /* i : number of bits in bitstream */
+)
+{
+ int16_t k, idx;
+ int32_t total_brate;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+
+ /* convert the frame length to total bitrate */
+ total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC );
+
+ if ( st_ivas->ivas_format != MONO_FORMAT && is_DTXrate( total_brate ) == 0 )
+ {
+ /* read IVAS format */
+ k = 0;
+ if ( bit_stream[0] == 1 )
+ {
+ k = 1;
+ }
+ k <<= 1;
+ if ( bit_stream[1] == 1 )
+ {
+ k += 1;
+ }
+
+ switch ( k )
+ {
+ case 0:
+ st_ivas->ivas_format = STEREO_FORMAT;
+ break;
+ case 1:
+ st_ivas->ivas_format = MC_FORMAT;
+ break;
+ case 2:
+ st_ivas->ivas_format = ISM_FORMAT;
+
+ if ( total_brate >= IVAS_24k4 )
+ {
+ if ( bit_stream[2] )
+ {
+ if ( bit_stream[3] )
+ {
+ st_ivas->ivas_format = SBA_ISM_FORMAT;
+ }
+ else
+ {
+ st_ivas->ivas_format = MASA_ISM_FORMAT;
+ }
+ }
+ }
+ break;
+ case 3:
+ if ( bit_stream[2] == 0 )
+ {
+ st_ivas->ivas_format = SBA_FORMAT;
+ }
+ else
+ {
+ st_ivas->ivas_format = MASA_FORMAT;
+ }
+ break;
+ }
+ }
+ else if ( total_brate == IVAS_SID_5k2 )
+ {
+ /* read SID format */
+ st_ivas->sid_format = 0;
+ if ( bit_stream[0] == 1 )
+ {
+ st_ivas->sid_format += 4;
+ }
+ if ( bit_stream[1] == 1 )
+ {
+ st_ivas->sid_format += 2;
+ }
+ if ( bit_stream[2] == 1 )
+ {
+ st_ivas->sid_format += 1;
+ }
+
+ switch ( st_ivas->sid_format )
+ {
+ case SID_DFT_STEREO:
+ st_ivas->element_mode_init = IVAS_CPE_DFT;
+ st_ivas->ivas_format = STEREO_FORMAT;
+ break;
+ case SID_MDCT_STEREO:
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ st_ivas->ivas_format = STEREO_FORMAT;
+ break;
+ case SID_ISM:
+ st_ivas->ivas_format = ISM_FORMAT;
+ break;
+ case SID_MULTICHANNEL:
+ st_ivas->ivas_format = MC_FORMAT;
+ break;
+ case SID_SBA_1TC:
+ st_ivas->ivas_format = SBA_FORMAT;
+ st_ivas->element_mode_init = IVAS_SCE;
+ break;
+ case SID_SBA_2TC:
+ st_ivas->ivas_format = SBA_FORMAT;
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ break;
+ case SID_MASA_1TC:
+ st_ivas->ivas_format = MASA_FORMAT;
+ st_ivas->element_mode_init = IVAS_SCE;
+ break;
+ case SID_MASA_2TC:
+ st_ivas->ivas_format = MASA_FORMAT;
+ if ( bit_stream[total_brate / FRAMES_PER_SEC - 1] == 1 )
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ }
+ else
+ {
+ st_ivas->element_mode_init = IVAS_CPE_DFT;
+ }
+ break;
+ default:
+ /* This should actually be impossible, since only 3 bits are read, so if this happens something is broken */
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format );
+ }
+ }
+
+ /* only read element mode from active frames */
+ if ( is_DTXrate( total_brate ) == 0 )
+ {
+ /* read element_mode - needed in init_decoder() */
+ if ( st_ivas->ivas_format == STEREO_FORMAT || st_ivas->ivas_format == MC_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
+ {
+ if ( st_ivas->ivas_format == MASA_FORMAT )
+ {
+ /* read number of MASA transport channels */
+ if ( bit_stream[num_bits - 1] == 1 )
+ {
+ st_ivas->nchan_transport = 2;
+ }
+ else
+ {
+ st_ivas->nchan_transport = 1;
+ }
+ }
+
+ if ( st_ivas->ivas_format == MC_FORMAT )
+ {
+ /* read MC configuration */
+ idx = 0;
+ for ( k = 0; k < MC_LS_SETUP_BITS; k++ )
+ {
+ if ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS + k] == 1 )
+ {
+ idx += ( 1 << ( MC_LS_SETUP_BITS - 1 - k ) );
+ }
+ }
+ st_ivas->transport_config = ivas_mc_map_ls_setup_to_output_config( (MC_LS_SETUP) idx );
+ }
+
+ if ( !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nchan_transport == 1 ) && st_ivas->ivas_format != MC_FORMAT )
+ {
+ /* read stereo technology info */
+ k = IVAS_FORMAT_SIGNALING_NBITS;
+ if ( st_ivas->ivas_format == MASA_FORMAT )
+ {
+ k = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED;
+ }
+
+ if ( total_brate < MIN_BRATE_MDCT_STEREO )
+ {
+ /* 1 bit */
+ if ( bit_stream[k] == 1 )
+ {
+ st_ivas->element_mode_init = 1 + IVAS_CPE_DFT;
+ }
+ else
+ {
+ st_ivas->element_mode_init = 0 + IVAS_CPE_DFT;
+ }
+ }
+ else
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ }
+ }
+ }
+ else if ( st_ivas->ivas_format == ISM_FORMAT )
+ {
+ /* read number of objects from the bitstream */
+ st_ivas->nchan_transport = 1;
+
+ k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 );
+ while ( bit_stream[k] == 1 && st_ivas->nchan_transport < MAX_NUM_OBJECTS )
+ {
+ st_ivas->nchan_transport++;
+ k--;
+ }
+ st_ivas->transport_config = IVAS_AUDIO_CONFIG_EXTERNAL + st_ivas->nchan_transport;
+
+ st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_transport, total_brate );
+ st_ivas->nSCE = st_ivas->nchan_transport;
+ }
+ else if ( st_ivas->ivas_format == SBA_FORMAT )
+ {
+ /* Read SBA planar flag and SBA order */
+ st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED] == 1 );
+ st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + 2] == 1 );
+ st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + 1] == 1 );
+
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order );
+
+ ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) );
+ }
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ /* read number of objects from the bitstream */
+ if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA )
+ {
+ st_ivas->nchan_ism = 2 * bit_stream[total_brate / FRAMES_PER_SEC - 1] + bit_stream[total_brate / FRAMES_PER_SEC - 2] + 1;
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ }
+
+ /* Read SBA planar flag and SBA order */
+ st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS] == 1 );
+
+ if ( total_brate >= IVAS_256k )
+ {
+ st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 2] == 1 );
+ st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 1] == 1 );
+ }
+ else
+ {
+ st_ivas->sba_order = 3;
+ }
+
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order );
+
+ ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) );
+ }
+ else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
+ {
+ /* read number of objects from the bitstream */
+ st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */
+ st_ivas->nchan_ism = 0;
+
+ if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA )
+ {
+ st_ivas->nchan_ism = 2 * bit_stream[total_brate / FRAMES_PER_SEC - 1] + bit_stream[total_brate / FRAMES_PER_SEC - 2] + 1;
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select( total_brate, st_ivas->nchan_ism );
+ }
+ }
+ }
+
+ st_ivas->hDecoderConfig->ivas_total_brate = total_brate;
+
+ return error;
+}
+#endif
/*-------------------------------------------------------------------*
@@ -2093,7 +2804,20 @@ ivas_error read_indices(
st_ivas->BER_detect = 0;
sts = reset_elements( st_ivas );
+#ifdef DEBUGGING
+ file_read_FECpattern( &st_ivas->bfi );
+ st_ivas->bfi |= bfi;
+
+ if ( bfi == FRAMEMODE_MISSING )
+ {
+ for ( k = 0; k < num_bits; k++ )
+ {
+ bit_stream[k] = 0;
+ }
+ }
+#else
st_ivas->bfi = bfi;
+#endif
/* convert the frame length to total bitrate */
total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC );
diff --git a/lib_com/calc_st_com.c b/lib_com/calc_st_com.c
index 59ceb09daf7a34f815912237997fbf61187b0d74..2f2cc56333ef7799daa532fc45d58fa77711878e 100644
--- a/lib_com/calc_st_com.c
+++ b/lib_com/calc_st_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/cb_shape.c b/lib_com/cb_shape.c
index 77f17eb236e4585282cc15725c138c325b163f3f..364ed639f323b294b764f924d7c69f572d1695f1 100644
--- a/lib_com/cb_shape.c
+++ b/lib_com/cb_shape.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c
index 716dff7a3aba197abf85610ed5c734a3ec8b9d99..1490703aeed53e88f6c690fa27b9118425d87ca0 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "stat_dec.h"
#include "prot.h"
diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c
index 8fdc68921b1a5080204f0a7b48790f986184e945..9f0a22320e8732322a1d2580499534d0dbca8544 100644
--- a/lib_com/cng_exc.c
+++ b/lib_com/cng_exc.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/cnst.h b/lib_com/cnst.h
index 1fb76df31cd216dbf43d0be5c96505132d3a316b..40f8437895e69633a5c5563a5b6eb3b186fac3c4 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -76,6 +76,16 @@
#define DEC_IVAS 2 /* Index for IVAS decoder */
+#ifdef DEBUGGING
+#define FORCE_SPEECH 100 /* debugging - force speech on the command line */
+#define FORCE_MUSIC 101 /* debugging - force music on the command line */
+#define FORCE_ACELP 102 /* debugging - force ACELP core on the command line */
+#define FORCE_GSC 103 /* debugging - force GSC core on the command line */
+#define FORCE_TCX 104 /* debugging - force TCX core on the command line */
+#define FORCE_HQ 105 /* debugging - force HQ core on the command line */
+#define FORCE_TD_RENDERER 201
+#define FORCE_CLDFB_RENDERER 202
+#endif
enum{
NB = 0, /* Indicator of 4 kHz bandwidth */
diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c
index 2375ef387e807bc38396b7be5eba3dbd0cba6ebe..7bb6dac40bb4b5d40bc869e53047fbcbc55e5db9 100644
--- a/lib_com/codec_tcx_common.c
+++ b/lib_com/codec_tcx_common.c
@@ -38,6 +38,9 @@
#include "options.h"
#include
#include "prot.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
/*-------------------------------------------------------------------*
diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h
index c4454fd625372836e004c5b6ebf486d1f1f1928e..4870ff5d097e6ddd4e1adb40dacc2fe4c6883c37 100644
--- a/lib_com/common_api_types.h
+++ b/lib_com/common_api_types.h
@@ -200,6 +200,15 @@ typedef struct _IVAS_JBM_TRACE_DATA
* Renderer API structures and enums
*----------------------------------------------------------------------------------*/
+#ifdef DEBUGGING
+typedef enum
+{
+ IVAS_RENDER_TYPE_OVERRIDE_NONE,
+ IVAS_RENDER_TYPE_OVERRIDE_CREND,
+ IVAS_RENDER_TYPE_OVERRIDE_FASTCONV
+
+} IVAS_RENDER_TYPE_OVERRIDE;
+#endif
typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
{
@@ -222,6 +231,9 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
typedef struct _IVAS_RENDER_CONFIG
{
+#ifdef DEBUGGING
+ IVAS_RENDER_TYPE_OVERRIDE renderer_type_override;
+#endif
IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcoustics;
float directivity[IVAS_MAX_NUM_OBJECTS * 3];
diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c
index 13fe05bbb161c1b6776506dfe5858e8143a3256a..0ee9b40ae09e458616a1d87ab84898f087ca08e4 100644
--- a/lib_com/core_com_config.c
+++ b/lib_com/core_com_config.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "rom_com.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/deemph.c b/lib_com/deemph.c
index 26baccd04a492255c048cabe6d0dcaea5cc7e252..9f4463d6a820cb6ebeb4a170b3e7ab56008c20c6 100644
--- a/lib_com/deemph.c
+++ b/lib_com/deemph.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c
index 66c81d440c3c880a2c7cf4706a7ce51bbe5d9a74..73d9db9f4a527ba074b4b7185a0148f722ee075a 100644
--- a/lib_com/delay_comp.c
+++ b/lib_com/delay_comp.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c
index f8af72f54117a1a9f442daee4094c3b86e06d580..10a31d94c079da17168d2a3c79591fadc728f47b 100644
--- a/lib_com/disclaimer.c
+++ b/lib_com/disclaimer.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#define WMC_TOOL_SKIP
diff --git a/lib_com/dlpc_bfi.c b/lib_com/dlpc_bfi.c
index ea701a3fed4315e755b6055a9769d3b1e5458a08..b894b845f803c57392987fba058d2d1b74d74b68 100644
--- a/lib_com/dlpc_bfi.c
+++ b/lib_com/dlpc_bfi.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/edct.c b/lib_com/edct.c
index a265794f3690159fb9b78e9860613d0a6bab8ee7..6f6d6c32b65d0d7c5c671865cf8aeb419852676b 100644
--- a/lib_com/edct.c
+++ b/lib_com/edct.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
@@ -98,6 +101,10 @@ static ivas_error get_edct_table(
case 80:
*edct_table = edct_table_40;
break;
+#ifdef DEBUGGING
+ default:
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "edct/edst(): length is not in table!" );
+#endif
}
return error;
diff --git a/lib_com/enhancer.c b/lib_com/enhancer.c
index 407588bc3f090b07430bec7148d9921d9afb621c..d0eeeb76c73ca4e185eafd8b6edd34006d66ee69 100644
--- a/lib_com/enhancer.c
+++ b/lib_com/enhancer.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c
index 800fa185c69af3cf748388ea8ecadcbce8119942..2b66a14d726bc263dd8feea5a484faeb81c1efe1 100644
--- a/lib_com/enr_1_az.c
+++ b/lib_com/enr_1_az.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c
index 459c40338d4b24df07208f2c5e1e2c986ba72029..03b7d6cef61c1c070a52ec6141ba51ca3d0f2b6c 100644
--- a/lib_com/env_adj.c
+++ b/lib_com/env_adj.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c
index ee07218f9b14f61c9302ebe037e54fcb20c54f82..a1957566b0f6dd21bc58b9b5a64c512617dfa977 100644
--- a/lib_com/env_stab.c
+++ b/lib_com/env_stab.c
@@ -36,12 +36,18 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
#include "stl.h"
+#ifdef DEBUGGING
+#include "assert.h"
+#endif
/*--------------------------------------------------------------------------*
* Local constants
@@ -102,6 +108,9 @@ float env_stability(
mem_norm[i] = ynrm[i];
}
+#ifdef DEBUGGING
+ assert( nb_sfm == 27 || nb_sfm == 26 );
+#endif
inv_nb_sfm = 19418; /* Q19 */
if ( nb_sfm == 26 )
{
diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c
index 1850ed48ba9f5b50302762b321bb0d85ec0d8ae1..a2d4492b3f4288ed3d707b824092d26b19fad166 100644
--- a/lib_com/env_stab_trans.c
+++ b/lib_com/env_stab_trans.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/est_tilt.c b/lib_com/est_tilt.c
index 2f5b5bbac8db7fe540a45bb85f410c5b1fa7af44..8073e39dfb19833c1ae9d6e7fe1db21f6e38b029 100644
--- a/lib_com/est_tilt.c
+++ b/lib_com/est_tilt.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c
index a6029e1059691a66da43ba419d7d0ff503b5a899..dd82c4f06b11ae4a06c0286b3c0c22351abd14da 100644
--- a/lib_com/fd_cng_com.c
+++ b/lib_com/fd_cng_com.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/fft.c b/lib_com/fft.c
index e5607dcc3aeb35a9dae5706e4b7bd0f1b693646a..a36712b8e0ab60cb277bb7f1b1fc90149fcf76eb 100644
--- a/lib_com/fft.c
+++ b/lib_com/fft.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c
index e45736be8c0144dd9f84f22a3bd83ea9b8ac169d..46ee5e9434de472f4f967ecb2e8049e37c9ea617 100644
--- a/lib_com/fft_rel.c
+++ b/lib_com/fft_rel.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c
index 93d4cd572dccee762a71807a0d10d5d2442524e2..6694824879aa5bcc6060d3cd6cb9d88a5479447d 100644
--- a/lib_com/fill_spectrum.c
+++ b/lib_com/fill_spectrum.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c
index 3f8321160888350bc6dc7e977d4612aa1941a8dc..3383397bcf939edd9426f6a5446c768c3e7e840a 100644
--- a/lib_com/findpulse.c
+++ b/lib_com/findpulse.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "cnst.h"
diff --git a/lib_com/fine_gain_bits.c b/lib_com/fine_gain_bits.c
index 5e65b12e4f74787d30e303fdca684e9130c53b73..9f10bcd7065bcb43129bbde11205fc352e6bb286 100644
--- a/lib_com/fine_gain_bits.c
+++ b/lib_com/fine_gain_bits.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "rom_com.h"
#include "prot.h"
#include
diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c
index 1592c6e9f19f9e89fb5c63365e021d6fbf660da6..f44cb099ce8c2e66a70d680c3488ab9b401b1517 100644
--- a/lib_com/frame_ener.c
+++ b/lib_com/frame_ener.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c
index 94e23a1c6d69e0a6b17b1ba64484e47b1de6315f..e3457128fe5c314636d81380d742a9d5a67e1595 100644
--- a/lib_com/get_gain.c
+++ b/lib_com/get_gain.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/gs_bitallocation.c b/lib_com/gs_bitallocation.c
index a742f719170483c6f06c2db272f6fb80d464279b..e30cf842ea5ba8425b99c825932cef8256134313 100644
--- a/lib_com/gs_bitallocation.c
+++ b/lib_com/gs_bitallocation.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
@@ -951,6 +954,9 @@ static float Find_bit_frac(
else
{
inv_bandQ15 = (int16_t) ( ( 1.0f / nb_band ) * 32678 + 0.5f );
+#ifdef DEBUGGING
+ printf( "1/%d NOT DEFINED in Find_bit_frac\n", nb_band );
+#endif
}
L_num = inv_bandQ15 * remaining_bits;
diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c
index 72b1ccf357320cf7fbec5a40a0324fb0359302bc..40626468b65089c0eb8a84e209615bd55464a31b 100644
--- a/lib_com/gs_gains.c
+++ b/lib_com/gs_gains.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/gs_inact_switching.c b/lib_com/gs_inact_switching.c
index 04ad8a3ebbfb855848491864963473326b7bf971..cd380e86e01e4776259663a806c235b331b60bfc 100644
--- a/lib_com/gs_inact_switching.c
+++ b/lib_com/gs_inact_switching.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/gs_noisefill.c b/lib_com/gs_noisefill.c
index f452dab7a5cfb719a5d3470f75650799f219b4ba..a92aec07515888a5f48888eb667fe210c7496297 100644
--- a/lib_com/gs_noisefill.c
+++ b/lib_com/gs_noisefill.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c
index ae2bbf6f53a4fa78ec79ef8149eb010a0ebf97e5..5a98f409369c0a19f0983496d8963323c09e294d 100644
--- a/lib_com/gs_preech.c
+++ b/lib_com/gs_preech.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/hp50.c b/lib_com/hp50.c
index b9268c8f99451b230edb1a74a78fa70af12fc581..3624fabb449fd153e55b2c3ed0fb44b00e19bbc1 100644
--- a/lib_com/hp50.c
+++ b/lib_com/hp50.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/hq2_bit_alloc.c b/lib_com/hq2_bit_alloc.c
index d471b170e60439d6d3f2e7c1632a31479ffed207..34c37babd3481d74a4d8a06fd97905517b456659 100644
--- a/lib_com/hq2_bit_alloc.c
+++ b/lib_com/hq2_bit_alloc.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c
index 280d492ae6b121107e41e2ea1d2a1ee341f98543..22a596a75fad2822ae3ff4a6e19c2991a3a665dd 100644
--- a/lib_com/hq2_core_com.c
+++ b/lib_com/hq2_core_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/hq2_noise_inject.c b/lib_com/hq2_noise_inject.c
index ed48dab7b908ac6e257549f5396e3a23f565996c..0404056dd1ff41587e88825f5ead51872e9ad0d3 100644
--- a/lib_com/hq2_noise_inject.c
+++ b/lib_com/hq2_noise_inject.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/hq_bit_allocation.c b/lib_com/hq_bit_allocation.c
index 7556ed505a072a6abf0d2a06c10b43ba50684ca2..faba9f8da9ac3e180010436fc99ae163b5f1ad36 100644
--- a/lib_com/hq_bit_allocation.c
+++ b/lib_com/hq_bit_allocation.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c
index d0f7939210c00e523e6231d7e9675e855d8a4373..ac9298159358bd297456c9fbee4046a305e83250 100644
--- a/lib_com/hq_conf.c
+++ b/lib_com/hq_conf.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/hq_tools.c b/lib_com/hq_tools.c
index df59ac1721cb59ba94585ca522ff05c842e02724..4ad78fc904bb097a3def5e4d8d1373e4ad712794 100644
--- a/lib_com/hq_tools.c
+++ b/lib_com/hq_tools.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/hvq_pvq_bitalloc.c b/lib_com/hvq_pvq_bitalloc.c
index 5ff0d3344c0f805295cb3983955190c528492bb8..2808030ae6715e74a318805fa8aaea01a603f2f3 100644
--- a/lib_com/hvq_pvq_bitalloc.c
+++ b/lib_com/hvq_pvq_bitalloc.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c
index 597a5d1734f916e6aacaeac7f6098f1ff1486e71..28334b06db85cba527d725e8b48b75065f4ca566 100644
--- a/lib_com/ifft_rel.c
+++ b/lib_com/ifft_rel.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c
index 73f7228d0d278b9bbd9eb8472649c1f4863f33e4..ac196510091b86a46c00022395b6520d55d93e48 100644
--- a/lib_com/igf_base.c
+++ b/lib_com/igf_base.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/index_pvq_opt.c b/lib_com/index_pvq_opt.c
index b14fd8fa37980476b6f18e4bc68d687fdc6ded25..097732442b6dd081701f5db2facb856415925507 100644
--- a/lib_com/index_pvq_opt.c
+++ b/lib_com/index_pvq_opt.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c
index 448a97e33284950b24351e05e924532d8a143e83..ff1c9cace4f66b4bcfca0ccb00ef672fec98b867 100644
--- a/lib_com/int_lsp.c
+++ b/lib_com/int_lsp.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c
index 300295355adaa5cfad5980fb1da5301738ded0d1..6046bf8f20959d616b33498e6c37edb6a48ca2c3 100644
--- a/lib_com/interleave_spectrum.c
+++ b/lib_com/interleave_spectrum.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/interpol.c b/lib_com/interpol.c
index 332f34d5444ee0069cbd4bae59f791a12d10051a..4172c4acf7367433db573ef0d1d3c615bdc920b3 100644
--- a/lib_com/interpol.c
+++ b/lib_com/interpol.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/isf_dec_amr_wb.c b/lib_com/isf_dec_amr_wb.c
index 49afd071fb5ac301dc5b7e02bf8dc6f54fc98aa7..d51731d1c005195f68a932df57fce09dd2d4e4dc 100644
--- a/lib_com/isf_dec_amr_wb.c
+++ b/lib_com/isf_dec_amr_wb.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/ivas_agc_com.c b/lib_com/ivas_agc_com.c
index 3bb4bdea2e9547843b30b6b42c14cf0b719b165c..e39b8df82d38b2e87b7b046e4b1dd9d5db121265 100644
--- a/lib_com/ivas_agc_com.c
+++ b/lib_com/ivas_agc_com.c
@@ -35,6 +35,9 @@
#include "cnst.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "wmc_auto.h"
#include "prot.h"
@@ -110,3 +113,24 @@ void ivas_agc_calcGainParams(
return;
}
+#ifdef DEBUG_AGC
+/*-----------------------------------------------------------------------------------------*
+ * Function ivas_agc_debug_inout()
+ *
+ *
+ *-----------------------------------------------------------------------------------------*/
+int16_t ivas_agc_debug_inout( FILE *inStream, float **in, int16_t n_channels, int16_t frame_len )
+{
+ if ( inStream == NULL )
+ {
+ return TRUE;
+ }
+
+ for ( int16_t i = 0; i < n_channels; i++ )
+ {
+ fwrite( &in[i][0], sizeof( float ), frame_len, inStream );
+ }
+
+ return FALSE;
+}
+#endif
diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c
index 98243b0f4addacfbc7d4efb5277ac8568c96cb37..0957d4ae5063e7641ce22503dc51f49738e60e88 100644
--- a/lib_com/ivas_arith.c
+++ b/lib_com/ivas_arith.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
#include "prot.h"
#include "ivas_prot.h"
diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c
index 015a3988f7ba326abebc023c471b032c9c0bd402..c75d20533b4dcf37357fbf252d19ccfb0e8500e3 100644
--- a/lib_com/ivas_avq_pos_reorder_com.c
+++ b/lib_com/ivas_avq_pos_reorder_com.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index fdb19fb37dc87d4d45ac5b6b1fd3c70605ee4331..e88f540752a0cd5888c57ca4cb4f0b61f841b7ad 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -460,6 +460,9 @@ enum
#define STEREO_DFT32MS_OVL_NS 3125000L /* 3.125ms - Overlap for the outer edges of windows on decoder */
#define STEREO_DFT32MS_OVL2_NS 9375000L /* 9.375ms - Overlap for the inner edges of windows on decoder */
#define STEREO_DFT32MS_WIN_CENTER_NS ( int32_t )( ( FRAME_SIZE_NS + STEREO_DFT32MS_OVL_NS ) * 0.5f ) /* 11.5625ms - mid point of the two windows wrt the left edge of overlap */
+#if defined( DEBUG_MODE_DFT ) || defined( DEBUG_STEREO_DFT_NOCORE )
+#define STEREO_DFT32MS_HOP_NS 10000000L /* 10ms */
+#endif
#define STEREO_DFT32MS_ZP_NS ( int32_t )( 0.5f * ( STEREO_DFT32MS_N_NS - STEREO_DFT32MS_WIN_CENTER_NS - ( STEREO_DFT32MS_OVL2_NS * 0.5f ) ) ) /* 2 sided zp calculated such that window size is satisfied */
#define STEREO_DFT32MS_OVL_MAX NS2SA( 48000, STEREO_DFT32MS_OVL_NS )
@@ -804,6 +807,10 @@ enum fea_names
/* MDCT stereo modes */
#define SMDCT_MS_DECISION 0
+#ifdef DEBUG_FORCE_MDCT_STEREO_MODE
+#define SMDCT_FORCE_LR 1
+#define SMDCT_FORCE_MS 2
+#endif
#define MAX_SFB 70 /* Maximum number of stereo frequency bands = 64 + 6 for TCX after ACELP */
diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c
index f15b21d7900d30d0a28348d1dba62d95bc6a22b1..54d0d5f8dabac2d0948abe985e577eaf77f53686 100644
--- a/lib_com/ivas_cov_smooth.c
+++ b/lib_com/ivas_cov_smooth.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "ivas_prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c
index 7696932cb033e3cc78967ac444a04d6c61efcdc9..a2fa26cad9f53c6a8f50eaf139331277e3f95f8a 100644
--- a/lib_com/ivas_entropy_coder_common.c
+++ b/lib_com/ivas_entropy_coder_common.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "math.h"
diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h
index fbb18cf9ff5d7fc6d67c511b0457d9972a2744d1..b61819ea3d9500e14ad6e1ab8098c84d29b4b0f8 100644
--- a/lib_com/ivas_error.h
+++ b/lib_com/ivas_error.h
@@ -89,6 +89,15 @@ typedef enum
IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED,
IVAS_ERR_TSM_NOT_ENABLED,
IVAS_ERR_FETCH_SIZE_NO_MULTIPLE_OF_5MS,
+#ifdef DEBUGGING
+ IVAS_ERR_INVALID_FORCE_MODE,
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ IVAS_ERR_INVALID_AGC,
+#endif
+#ifdef VARIABLE_SPEED_DECODING
+ IVAS_ERR_VS_FRAME_NEEDED,
+#endif
+#endif
/*----------------------------------------*
* input data errors *
@@ -210,6 +219,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
return "Unexpected NULL pointer";
case IVAS_ERR_METADATA_NOT_EXPECTED:
return "Metadata input not expected for current configuration";
+#ifdef DEBUGGING
+ case IVAS_ERR_INVALID_FORCE_MODE:
+ return "Invalid force mode";
+#endif
case IVAS_ERR_NOT_IMPLEMENTED:
return "Not implemented";
case IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT:
diff --git a/lib_com/ivas_error_utils.h b/lib_com/ivas_error_utils.h
index 204acc40e876ac6feee771e3778a615437ec4f76..b9a6b3f872443e35368c4d802054d6f47eaafc42 100644
--- a/lib_com/ivas_error_utils.h
+++ b/lib_com/ivas_error_utils.h
@@ -38,6 +38,9 @@
#include "ivas_error.h"
+#ifdef DEBUGGING
+#include
+#endif
#ifndef IVAS_ERROR_UTILS_H
#define IVAS_ERROR_UTILS_H
@@ -63,11 +66,32 @@
* If unexpected values are printed or the macro causes a crash, double check that the
* format specifiers are correct.
*/
+#ifdef DEBUGGING
+#define IVAS_ERROR( error_code, ... ) ivas_error_wrapper( error_code, __func__, __FILE__, __LINE__, __VA_ARGS__ )
+#else
#define IVAS_ERROR( error_code, ... ) ivas_error_wrapper( error_code )
+#endif
+#ifdef DEBUGGING
+static inline ivas_error ivas_error_wrapper( const ivas_error error_code, const char *function, const char *file, int32_t line, const char *description, ... )
+{
+ fprintf( stderr, "\n%s: ", ivas_error_to_string( error_code ) );
+
+ va_list args;
+ va_start( args, description );
+ vfprintf( stderr, description, args );
+ va_end( args );
+
+ fprintf( stderr, "\n\nIn function: %s(), %s:%d\n\n", function, file, line );
+ // assert( 0 );
+
+ return error_code;
+}
+#else
static inline ivas_error ivas_error_wrapper( const ivas_error error_code )
{
return error_code;
}
+#endif
#endif /* IVAS_ERROR_UTILS_H */
diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c
index f914d4e75160f1b5af8f9c44976f10b6cb471c9e..9772f2e8dd81ccb15f8ae034d6b8ff7eecf36a62 100644
--- a/lib_com/ivas_fb_mixer.c
+++ b/lib_com/ivas_fb_mixer.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "ivas_prot.h"
diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c
index 8344fe33f71ee1eff5a0ae036f7bfc77423a2abf..579e9d17c6f3dfd444407559bb1d39d593fe4272 100644
--- a/lib_com/ivas_filters.c
+++ b/lib_com/ivas_filters.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "ivas_prot.h"
#include "ivas_cnst.h"
#include "ivas_stat_com.h"
diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c
index d8cb958cc4d6384e51d48bbce84526b1aaee2c18..3ec4656a9e7e922abfc43db2b6a0365745205447 100644
--- a/lib_com/ivas_ism_com.c
+++ b/lib_com/ivas_ism_com.c
@@ -39,6 +39,9 @@
#include "ivas_prot.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
@@ -338,6 +341,12 @@ ivas_error ivas_ism_config(
else
{
bits_CoreCoder[ch] += diff;
+#ifdef DEBUGGING
+ if ( bits_CoreCoder[ch] == SID_2k40 / FRAMES_PER_SEC )
+ {
+ printf( "\nWarning: ISM bitbudget equal to SID!\n" );
+ }
+#endif
if ( combined_format_flag )
{
@@ -375,6 +384,17 @@ ivas_error ivas_ism_config(
bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms );
}
+#ifdef DEBUGGING
+ if ( nb_bits_metadata != NULL )
+ {
+ int32_t tmpL;
+ tmpL = sum_l( total_brate, n_ISms ) + bits_side * FRAMES_PER_SEC;
+ if ( ism_total_brate != tmpL )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: Mismatch in ISM bit-budget distribution. Exiting!\n" );
+ }
+ }
+#endif
return error;
}
diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c
index 6b323a13c45df500df31f23e9a6d02091c94e96a..45dcae7c07a16f87259decd40f4bc1886422fe11 100644
--- a/lib_com/ivas_lfe_com.c
+++ b/lib_com/ivas_lfe_com.c
@@ -33,6 +33,9 @@
#include
#include "math.h"
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "ivas_stat_com.h"
#include "prot.h"
#include "ivas_prot.h"
diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c
index abb4dbd552c9c4ed956ce146329474da464e679b..17e4b477314b3023a41dac3b0755fe9fd38347a2 100644
--- a/lib_com/ivas_masa_com.c
+++ b/lib_com/ivas_masa_com.c
@@ -39,6 +39,9 @@
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "ivas_stat_dec.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
/*---------------------------------------------------------------
@@ -290,6 +293,9 @@ void ivas_masa_set_coding_config(
config->numCodingBands = nbands;
config->numTwoDirBands = nTwoDirBands;
+#ifdef DEBUGGING
+ assert( nbands > 0 );
+#endif
if ( config->joinedSubframes == TRUE )
{
config->mergeRatiosOverSubframes = FALSE;
diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c
index 664dd3a703d981489eabb484850f40f49821086b..966fd21a57ce0b2aed9bfbf31f74b9d4daddc724 100644
--- a/lib_com/ivas_mc_com.c
+++ b/lib_com/ivas_mc_com.c
@@ -33,6 +33,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "ivas_prot.h"
diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c
index e8160527021164c336145a677fdb13f3db36cb9e..44efdebe2e96b2dde1a05432811eda965bd8c867 100644
--- a/lib_com/ivas_mc_param_com.c
+++ b/lib_com/ivas_mc_param_com.c
@@ -39,6 +39,9 @@
#include "ivas_prot.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
@@ -69,6 +72,9 @@ uint16_t ivas_param_mc_get_configuration_index(
return cur_idx;
}
}
+#ifdef DEBUGGING
+ assert( 0 && "No Parametric MC configuration for this bitrate/channel setup!" );
+#endif
return PARAM_MC_NUM_CONFIGS;
}
diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c
index 34196431960ff0c06977c3703a7cb0632965f3d8..7e81e1fd1cd8317beeb8c359c34433a113896e02 100644
--- a/lib_com/ivas_mcmasa_com.c
+++ b/lib_com/ivas_mcmasa_com.c
@@ -33,6 +33,9 @@
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
diff --git a/lib_com/ivas_mdct_imdct.c b/lib_com/ivas_mdct_imdct.c
index 656788717ed7323962a01849ddc46434abdd0cef..5dcd850c2ee1bbc4a42b48e252c9248c5e9b93a0 100644
--- a/lib_com/ivas_mdct_imdct.c
+++ b/lib_com/ivas_mdct_imdct.c
@@ -35,6 +35,9 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "ivas_stat_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c
index 73a73231690d3c2509d0a477703951f14b72b89b..0b03f63d90cb7cec236bc42b69d92eeae430b5ef 100644
--- a/lib_com/ivas_mdft_imdft.c
+++ b/lib_com/ivas_mdft_imdft.c
@@ -34,6 +34,9 @@
#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "ivas_rom_com.h"
#include
#include "wmc_auto.h"
diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c
index 31874a7b52b295b9224516cb327b3ee778d4d607..7416dad119d0a016ea35f669e9e2e94ed77ca5f1 100644
--- a/lib_com/ivas_omasa_com.c
+++ b/lib_com/ivas_omasa_com.c
@@ -37,6 +37,9 @@
#include "prot.h"
#include "ivas_rom_com.h"
#include
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
/*---------------------------------------------------------------
* Local constants
diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools.c
index a9dcffd1e69f6319c49145ad9d3282787bd0b634..a1f8efd6298aeb66beab96d8f1a289a7cb060cda 100644
--- a/lib_com/ivas_pca_tools.c
+++ b/lib_com/ivas_pca_tools.c
@@ -34,6 +34,9 @@
#include "options.h"
#include "ivas_prot.h"
#include "ivas_cnst.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include
#include "ivas_rom_com.h"
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
index 0ffed78211ad6ad04d258b6f6c4824c00ed11416..15985be5781eac5d52186298f6bf8a1d9021aac2 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -688,6 +688,14 @@ void smooth_dft2td_transition(
const int16_t output_frame /* i : output frame length */
);
+#ifdef DEBUG_MODE_INFO
+void output_debug_mode_info_dec(
+ Decoder_State **sts,
+ const int16_t n_channels,
+ const int16_t output_frame,
+ float pitch_buf[CPE_CHANNELS][NB_SUBFR16k]
+);
+#endif
/*! r: flag indicating a valid bitrate */
int16_t is_IVAS_bitrate(
@@ -1628,6 +1636,9 @@ void stereo_td_itd(
ITD_DATA *hITD, /* i/o: ITD data structure */
float input_mem_itd[CPE_CHANNELS][STEREO_DFT_OVL_MAX], /* o : ITD memory (only used in DFT Stereo) */
const int16_t hybrid_itd_flag, /* i : flag for hybrid TD/FD ITD processing */
+#ifdef DEBUG_MODE_DFT
+ const int16_t itd_mode, /* i : main ITD processing flag */
+#endif
const int16_t dft_ovl, /* i : size of DFT overlap */
Encoder_State **sts, /* i/o: Encoder state structure */
const int16_t input_frame, /* i : input frame length */
@@ -4107,6 +4118,9 @@ void ivas_sba_mix_matrix_determiner(
/* AGC */
/*! r: AGC enable flag */
int16_t ivas_agc_enc_get_flag(
+#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
+ const int16_t agc_configuration, /* i : AGC configuration from command-line */
+#endif
const int16_t nchan_transport /* i : number of transport channels */
);
@@ -5132,11 +5146,27 @@ ivas_error ivas_allocate_binaural_hrtf(
const int16_t allocate_init_flag /* i : Memory allocation flag */
);
+#ifdef DEBUGGING
+void ivas_binaural_cldfb(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */
+);
+
+void ivas_binaural_cldfb_sf(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const int16_t n_samples_to_render, /* i : output frame length per channel */
+ const int16_t slot_size, /* i : JBM slot size */
+ float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */
+);
+#endif
void ivas_binRenderer(
BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */
COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */
const int16_t numTimeSlots, /* i : number of time slots to process */
+#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
+ HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData,
+#endif
float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */
float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */
float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */
@@ -5612,6 +5642,10 @@ void ivas_omasa_enc(
void ivas_set_surplus_brate_enc(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+#ifdef DEBUG_MODE_INFO
+ ,
+ const int16_t *nb_bits_metadata /* i : number of metadata bits */
+#endif
);
void ivas_set_surplus_brate_dec(
diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c
index 57adf7c6aae2048cad144afefbaffe5e418b4cb8..d3b11da6d86ec630c2d3efb0d90712c8d91e301c 100644
--- a/lib_com/ivas_qmetadata_com.c
+++ b/lib_com/ivas_qmetadata_com.c
@@ -101,6 +101,9 @@ ivas_error ivas_qmetadata_allocate_memory(
int16_t j, dir;
uint8_t do_realloc;
+#ifdef DEBUGGING
+ assert( hQMetaData != NULL );
+#endif
/* Check if we need to reallocate memory or do we need to do the first time allocation. */
if ( hQMetaData->q_direction != NULL )
@@ -337,6 +340,12 @@ ivas_error only_reduce_bits_direction(
while ( n < rem )
{
max_nb = 0;
+#ifdef DEBUGGING
+ if ( delta > MASA_MIN_BITS_TF )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Not enough bits for MASA param." );
+ }
+#endif
for ( j = 0; j < coding_subbands; j++ )
{
bits_dir0 = (int16_t *) q_direction->band_data[j].bits_sph_idx;
@@ -574,6 +583,10 @@ void ivas_qmetadata_azimuth_elevation_to_direction_vector(
{
float radius_length;
+#ifdef DEBUGGING
+ assert( fabsf( el ) <= 90.0f );
+ /*assert((0.0f <= az) && (az <= 360.0f)); */
+#endif
dv[2] = sinf( el * PI_OVER_180 );
radius_length = cosf( el * PI_OVER_180 );
diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c
index e754fb692bbd3ab149ffcf930c7931c3115e930d..874f66d05910606c7197034c36e8aef9491c628b 100644
--- a/lib_com/ivas_qspherical_com.c
+++ b/lib_com/ivas_qspherical_com.c
@@ -101,10 +101,18 @@ int16_t ivas_dirac_project_elevation_index(
)
{
int16_t el_idx_proj;
+#ifdef DEBUGGING
+ assert( ( el_idx >= 0 ) && ( el_idx < el_alph ) );
+ assert( el_alph == 2 * ( el_alph >> 1 ) + 1 ); /* el_alph of the form 2 * n_points + 1 */
+ assert( el_alph_proj == 2 * ( el_alph_proj >> 1 ) + 1 );
+#endif
/* evaluate floor((el_idx / (el_alph - 1)) * (el_alph_proj - 1) + 0.5) using only integer */
el_idx_proj = ( 2 * el_idx * ( el_alph_proj - 1 ) + ( el_alph - 1 ) ) / ( 2 * ( el_alph - 1 ) );
+#ifdef DEBUGGING
+ assert( ( 0 <= el_idx_proj ) && ( el_idx_proj < el_alph_proj ) );
+#endif
return el_idx_proj;
}
@@ -123,6 +131,9 @@ int16_t ivas_chan_project_elevation_index(
)
{
int16_t el_idx_proj;
+#ifdef DEBUGGING
+ assert( ( el_idx >= 0 ) && ( el_idx < el_alph ) );
+#endif
/* evaluate floor((el_idx / (el_alph - 1)) * (el_alph_proj - 1) + 0.5) using only integer */
if ( el_idx == el_alph - 1 )
@@ -134,6 +145,9 @@ int16_t ivas_chan_project_elevation_index(
el_idx_proj = ( 2 * el_idx * el_alph_proj + el_alph ) / ( 2 * el_alph );
}
+#ifdef DEBUGGING
+ assert( ( 0 <= el_idx_proj ) && ( el_idx_proj < el_alph_proj ) );
+#endif
return el_idx_proj;
}
@@ -152,6 +166,9 @@ int16_t ivas_dirac_project_azimuth_index(
)
{
int16_t az_idx_proj;
+#ifdef DEBUGGING
+ assert( ( az_idx >= 0 ) && ( az_idx < az_alph ) );
+#endif
if ( az_alph_proj == 1 )
{
@@ -166,6 +183,9 @@ int16_t ivas_dirac_project_azimuth_index(
az_idx_proj = 0;
}
+#ifdef DEBUGGING
+ assert( ( 0 <= az_idx_proj ) && ( az_idx_proj < az_alph_proj ) );
+#endif
return az_idx_proj;
}
@@ -226,6 +246,9 @@ int16_t quantize_phi(
float dd;
float delta_phi;
+#ifdef DEBUGGING
+ assert( ( phi >= 0.f ) && ( phi <= 360.f ) );
+#endif
delta_phi = 360.0f / (float) n;
@@ -387,6 +410,10 @@ int16_t quantize_phi_chan_lbr(
{
int16_t id_phi;
+#ifdef DEBUGGING
+ assert( ( phi >= -180.f ) && ( phi <= 180.f ) );
+ assert( n <= 9 );
+#endif
if ( n <= 1 )
{
@@ -430,6 +457,9 @@ int16_t quantize_phi_chan_compand(
int16_t id_phi;
float delta_phi;
+#ifdef DEBUGGING
+ assert( ( phi >= 0.f ) && ( phi <= 360.f ) );
+#endif
if ( n <= 1 )
{
diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c
index fe97aea47070cf2a9df5f34cd1df2ed82f658880..58dc6dc974063e216325393cf6d9a68149c5e306 100644
--- a/lib_com/ivas_rom_com.c
+++ b/lib_com/ivas_rom_com.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "ivas_cnst.h"
diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h
index c88b698c0b43dd0d4031f969488295938282eb06..f597fe8b90efcd7d98788e61c8840f90a1a192af 100644
--- a/lib_com/ivas_rom_com.h
+++ b/lib_com/ivas_rom_com.h
@@ -39,6 +39,9 @@
#include "ivas_cnst.h"
#include "stat_com.h"
#include "ivas_stat_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
/*----------------------------------------------------------------------------------*
diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c
index fd1bb70fdce6bc28348aa623761bc08a79a86988..778a7bb90dff68229e7fc15b099e5e0ae9063f86 100644
--- a/lib_com/ivas_sba_config.c
+++ b/lib_com/ivas_sba_config.c
@@ -41,6 +41,9 @@
#include "ivas_prot.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
diff --git a/lib_com/ivas_sns_com.c b/lib_com/ivas_sns_com.c
index 4708b32c29434a5abde573b7ddb6e099cbcb0997..da7b37e8c55f2ecfecc5f0439968cf315b39772e 100644
--- a/lib_com/ivas_sns_com.c
+++ b/lib_com/ivas_sns_com.c
@@ -39,6 +39,9 @@
#include "ivas_rom_com.h"
#include
#include
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c
index e80dbf42890c77812cc9c7740db25185dd94edd9..f519ffec13a175a79850ee18d8469b6f1a0f66f0 100644
--- a/lib_com/ivas_spar_com.c
+++ b/lib_com/ivas_spar_com.c
@@ -33,6 +33,9 @@
#include
#include "math.h"
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "ivas_stat_com.h"
#include "prot.h"
#include "ivas_prot.h"
@@ -1383,6 +1386,27 @@ void ivas_compute_spar_params(
{
ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1, dyn_active_w_flag );
+#ifdef SPAR_HOA_DBG
+ /* if (b == 0) */
+ {
+ fprintf( stdout, "\n\nUnquantised C, P coeffs -- band %d:\n", b );
+
+ for ( int16_t ii = 0; ii < num_ch; ii++ )
+ {
+ fprintf( stdout, "%f |", hSparMd->band_coeffs[b].pred_re[ii] );
+
+ if ( ii < num_ch - ndm )
+ {
+ for ( int16_t jj = 0; jj < ndm - 1; jj++ )
+ {
+ fprintf( stdout, "%f,\t", hSparMd->band_coeffs[b].C_re[ii][jj] );
+ }
+ fprintf( stdout, "| %f", hSparMd->band_coeffs[b].P_re[ii] );
+ }
+ fprintf( stdout, "\n" );
+ }
+ }
+#endif
}
}
@@ -1655,6 +1679,29 @@ void ivas_get_spar_md_from_dirac(
}
}
+#ifdef DEBUG_SBA_MD_DUMP
+ {
+ static FILE *fid = 0;
+ int16_t k = 0;
+ float tmp_buf[10];
+ if ( !fid )
+ {
+ fid = fopen( "cov_real_dirac.txt", "wt" );
+ }
+
+ for ( i = 0; i < num_ch; i++ )
+ {
+ for ( j = 0; j < num_ch; j++ )
+ {
+ for ( k = start_band; k < end_band; k++ )
+ {
+ fprintf( fid, "%.6f\n", cov_real_dirac[i][j][k] );
+ }
+ }
+ }
+ fprintf( fid, "\n" );
+ }
+#endif
active_w = ( dyn_active_w_flag == 1 ) || ( hSpar_md_cfg->active_w == 1 );
diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c
index c01f95d1edbbce812a426566fd3e9c6a94120ac2..977f36e37458e2c1aa267c703815fc344db53092 100644
--- a/lib_com/ivas_spar_com_quant_util.c
+++ b/lib_com/ivas_spar_com_quant_util.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "math.h"
#include "prot.h"
#include "ivas_prot.h"
diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h
index f34610c11e8424edc109164767f24f46011ca7be..566abcb443e1a588b4592db94fdbe7e939c04cc2 100644
--- a/lib_com/ivas_stat_com.h
+++ b/lib_com/ivas_stat_com.h
@@ -99,6 +99,10 @@ typedef struct stereo_dft_config_data_struct
int16_t dmx_active;
int16_t band_res;
int16_t prm_res; /* Send prm every # DFT frames */
+#ifdef DEBUG_MODE_DFT
+ int16_t gipd_mode; /* mode : from 0 (off) to 1 (on) */
+ int16_t itd_mode; /* mode : from 0 (off) to 1 (on) */
+#endif
int16_t res_pred_mode; /* mode : from 0 (off) to 1 (on) */
int16_t res_cod_mode; /* mode : from 0 (off) to 3 */
int16_t hybrid_itd_flag;
diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com.c
index 541f90a120484b76fec7bc29abc3b6ebf704000d..ae6b772a30f99050ce1311d5c45a52c92e4a41a2 100644
--- a/lib_com/ivas_stereo_dft_com.c
+++ b/lib_com/ivas_stereo_dft_com.c
@@ -57,7 +57,11 @@ void stereo_dft_config(
{
hConfig->band_res = STEREO_DFT_BAND_RES_HIGH;
hConfig->prm_res = 2;
+#ifndef DEBUG_STEREO_DFT_NOSTEREO
hConfig->dmx_active = STEREO_DFT_DMX_ACTIVE;
+#else
+ hConfig->dmx_active = 0;
+#endif
hConfig->ada_wb_res_cod_mode = 0;
}
@@ -69,6 +73,10 @@ void stereo_dft_config(
*bits_frame_nominal = FRAME_NO_DATA;
if ( hConfig != NULL )
{
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_OFF;
hConfig->band_res = STEREO_DFT_BAND_RES_LOW;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_OFF;
@@ -79,6 +87,10 @@ void stereo_dft_config(
*bits_frame_nominal = SID_2k40 / FRAMES_PER_SEC;
if ( hConfig != NULL )
{
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_OFF;
hConfig->band_res = STEREO_DFT_BAND_RES_LOW;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_OFF;
@@ -89,6 +101,10 @@ void stereo_dft_config(
*bits_frame_nominal = ACELP_9k60 / FRAMES_PER_SEC;
if ( hConfig != NULL )
{
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_ESF;
hConfig->band_res = STEREO_DFT_BAND_RES_LOW;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_OFF;
@@ -99,6 +115,10 @@ void stereo_dft_config(
*bits_frame_nominal = ACELP_13k20 / FRAMES_PER_SEC;
if ( hConfig != NULL )
{
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_ESF;
hConfig->band_res = STEREO_DFT_BAND_RES_LOW;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_OFF;
@@ -109,6 +129,10 @@ void stereo_dft_config(
*bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC;
if ( hConfig != NULL )
{
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_ESF;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_OFF;
}
@@ -119,6 +143,10 @@ void stereo_dft_config(
if ( hConfig != NULL )
{
hConfig->ada_wb_res_cod_mode = 1;
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_STEFI;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_1kHz;
}
@@ -128,6 +156,10 @@ void stereo_dft_config(
*bits_frame_nominal = ACELP_32k / FRAMES_PER_SEC;
if ( hConfig != NULL )
{
+#ifdef DEBUG_MODE_DFT
+ hConfig->itd_mode = 1;
+ hConfig->gipd_mode = 1;
+#endif
hConfig->res_pred_mode = STEREO_DFT_RESPRED_STEFI;
hConfig->res_cod_mode = STEREO_DFT_RES_COD_1_6kHz;
}
diff --git a/lib_com/ivas_stereo_eclvq_com.c b/lib_com/ivas_stereo_eclvq_com.c
index f3b4e51fee66330bf5279ea6899df5de1a1c9653..ff78a66eba27d9972f2a72ddb29ed072418d6d3f 100644
--- a/lib_com/ivas_stereo_eclvq_com.c
+++ b/lib_com/ivas_stereo_eclvq_com.c
@@ -70,6 +70,9 @@ float ECSQ_dequantize_gain(
const int16_t index )
{
float global_gain;
+#ifdef DEBUGGING
+ assert( ( index >= 0 ) && ( index <= 126 ) );
+#endif
global_gain = powf( 10.0f, (float) index * ECLVQ_INV_GLOBAL_GAIN_FACTOR );
@@ -89,6 +92,10 @@ void ECSQ_dequantize_vector(
float *output )
{
int16_t i;
+#ifdef DEBUGGING
+ assert( N > 0 );
+ assert( global_gain > 0.0f );
+#endif
for ( i = 0; i < N; ++i )
{
diff --git a/lib_com/ivas_stereo_ica_com.c b/lib_com/ivas_stereo_ica_com.c
index 31f9447a577376798e8977cd8c9a134819e33594..a68a9a709acc072f801cc669b1e33eae02617a42 100644
--- a/lib_com/ivas_stereo_ica_com.c
+++ b/lib_com/ivas_stereo_ica_com.c
@@ -37,6 +37,9 @@
#include "ivas_cnst.h"
#include "prot.h"
#include "ivas_prot.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "wmc_auto.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c
index 35524a20a1a5c6c16675e86f1a869866e718a395..19a1295f2de1c68ac3819f9a031e474b97218f6f 100644
--- a/lib_com/ivas_stereo_mdct_bands_com.c
+++ b/lib_com/ivas_stereo_mdct_bands_com.c
@@ -225,6 +225,9 @@ void stereo_mdct_init_igf_start_band(
{
int16_t i, bitRateIndex, igfStartLine;
const int16_t *swb_offset;
+#ifdef DEBUGGING
+ stbParams->sfbIgfStart = 0;
+#endif
bitRateIndex = IGF_MapBitRateToIndex( element_brate, bwidth, IVAS_CPE_MDCT, 0 );
swb_offset = &swb_offset_LB_new[bitRateIndex][1];
@@ -241,6 +244,9 @@ void stereo_mdct_init_igf_start_band(
stbParams->nBandsStereoCore = stbParams->sfbIgfStart;
+#ifdef DEBUGGING
+ assert( stbParams->sfbIgfStart > 0 );
+#endif
return;
}
diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c
index 35bfe904628c37ea236a8ceb49e63eaf599babe7..ce3a5f20feaa61a683c779e1405aeeb32c02e9ca 100644
--- a/lib_com/ivas_stereo_td_bit_alloc.c
+++ b/lib_com/ivas_stereo_td_bit_alloc.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "stat_enc.h"
#include "rom_com.h"
diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c
index 4e28892da362cd8c38dfeb1569b759c366158438..ee7a06ca7d9b7300b7fd00eff316ef8ccf6ed775 100644
--- a/lib_com/ivas_tools.c
+++ b/lib_com/ivas_tools.c
@@ -33,6 +33,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "ivas_prot.h"
@@ -129,6 +132,12 @@ uint32_t ivas_syn_output(
{
noClipping += mvr2s( synth[n], synth_loc, output_frame );
+#ifdef DEBUG_MODE_LFE
+ if ( n == LFE_CHANNEL )
+ {
+ dbgwrite( synth_loc, sizeof( int16_t ), output_frame, 1, "./lfe_out.raw" );
+ }
+#endif
for ( i = 0; i < output_frame; i++ )
{
synth_out[i * n_channels + n] = synth_loc[i];
diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c
index 7e38f8ce6788a08cb1980984e546c4f32325ce66..54c12e916f97a49fda4a5a70eba6617000eaa2b3 100644
--- a/lib_com/ivas_transient_det.c
+++ b/lib_com/ivas_transient_det.c
@@ -32,6 +32,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "math.h"
#include "wmc_auto.h"
#include "prot.h"
diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c
index fdaa4a7a7c4d6560bcfde0820a9a264d67479915..c4c5e803beedaf2433793bce428f329326f7978e 100644
--- a/lib_com/lag_wind.c
+++ b/lib_com/lag_wind.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/limit_t0.c b/lib_com/limit_t0.c
index 1176a81327346e47cc8de90872fd86a57215aecf..0a844bbc5d72755f841126249cc52eeb5bb78682 100644
--- a/lib_com/limit_t0.c
+++ b/lib_com/limit_t0.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/logqnorm.c b/lib_com/logqnorm.c
index 04b822a14cfe39a742ab43253658b41120315c3c..c8185dd5a20322a4be7941cecf359a6e91d647b8 100644
--- a/lib_com/logqnorm.c
+++ b/lib_com/logqnorm.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/low_rate_band_att.c b/lib_com/low_rate_band_att.c
index c715e0ac570682d5d54f6b163c85491dfdb9b483..393cae5ff24ba1eab58e016dc99736ad53d2e87b 100644
--- a/lib_com/low_rate_band_att.c
+++ b/lib_com/low_rate_band_att.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/lpc_tools.c b/lib_com/lpc_tools.c
index 2af9f407c0f36c6c4622bd7e929afd2a5ec1e7e2..df36ad2b0ee4d025d4080b39d135bbd2441d831c 100644
--- a/lib_com/lpc_tools.c
+++ b/lib_com/lpc_tools.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/lsf_msvq_ma.c b/lib_com/lsf_msvq_ma.c
index 940233e4c3bdc8849597dc33d3323348c9c97f87..3396e9fde2ea604d13600ab510207d73dd1ebe71 100644
--- a/lib_com/lsf_msvq_ma.c
+++ b/lib_com/lsf_msvq_ma.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c
index 32df7a35e093308e7a3a1e00047fe92f4282d9f0..b99f72d27a237743a8a23733a64180abb4ef4874 100644
--- a/lib_com/lsf_tools.c
+++ b/lib_com/lsf_tools.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
@@ -182,6 +185,12 @@ void a2isp(
{
xint -= ylow * ( xhigh - xlow ) / ( ymid );
}
+#ifdef DEBUGGING
+ else if ( ymid == 0 && ylow != 0 )
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "issue in a2lsp_stab()" );
+ }
+#endif
isp[nf] = xint; /* new root */
nf++;
@@ -667,6 +676,12 @@ void a2lsp_stab(
{
xint -= ylow * ( xhigh - xlow ) / ( ymid );
}
+#ifdef DEBUGGING
+ else if ( ymid == 0 && ylow != 0 )
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "issue in a2lsp_stab()" );
+ }
+#endif
lsp[nf] = xint; /* new root */
nf++;
ip = 1 - ip; /* flag to other polynomial */
@@ -1182,6 +1197,12 @@ ivas_error lsf_allocate(
levels1[0] = bits_lvq;
}
}
+#ifdef DEBUGGING
+ else
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "lsf_allocate(): invalid number of bits in used predictive mode\n" );
+ }
+#endif
}
return error;
@@ -1259,6 +1280,12 @@ ivas_error find_pred_mode(
}
}
+#ifdef DEBUGGING
+ if ( *predmode == -1 )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nfind_pred_mode(): incorrect coder_type specification: %d\n", coder_type );
+ }
+#endif
return error;
}
diff --git a/lib_com/lsp_conv_poly.c b/lib_com/lsp_conv_poly.c
index ee567b3e8053341d6b5e319d00b3bac6a4edc0e3..d43d74fb5a8c73e6520a0a48fe1f6b34daa0d118 100644
--- a/lib_com/lsp_conv_poly.c
+++ b/lib_com/lsp_conv_poly.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c
index c0f3c56ce37faa9c270429681f8a6a0b68e2fa7b..f1ae7c61d4571334e597980e53ff09970f80db54 100644
--- a/lib_com/modif_fs.c
+++ b/lib_com/modif_fs.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/options.h b/lib_com/options.h
index 5f48e70b3645da36f2ac07783f0e5c3c92c3e575..cfb09c3ba13affaf9f490f87bf11a2269e82adea 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -47,12 +47,97 @@
/* ################### Start DEBUGGING switches ########################### */
+#ifndef RELEASE
+#define DEBUGGING /* Activate debugging part of the code */
+#endif
/*#define WMOPS*/ /* Activate complexity and memory counters */
/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */
/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */
/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
+#ifdef DEBUGGING
+
+#define DISABLE_DFT_STEREO_ASSERT /* This assert is hit for -10 dB tests/codec_be_on_mr_nonselection/test_param_file.py::test_param_file_tests[stv-stereo at 32 kbps, 48kHz in, 48kHz out, DTX on, random FER at 5%, bandwidth switching] */
+
+
+/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */
+#ifdef DEBUG_MODE_INFO
+/*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */
+/*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */
+/*#define DEBUG_MODE_DFT*/ /* output most important DFT stereo parameters to the subdirectory "res/" */
+/*#define DEBUG_MODE_TD*/ /* output most important TD stereo parameters to the subdirectory "res/ */
+/*#define DEBUG_MODE_DIRAC*/ /* output most important DIRAC parameters to the subdirectory "res/" */
+/*#define DEBUG_MODE_MDCT*/ /* output most important MDCT parameters to the subdirectory "res/" */
+/*#define DEBUG_MODE_PARAM_MC*/ /* output Parametric MC paramters to the subdirectory "res/" */
+/*#define DEBUG_MODE_PARAM_ISM*/ /* output Parametric ISM paramters to the subdirectory "res/" */
+/*#define DEBUG_MODE_INFO_TWEAK*/ /* enable command line switch to specify subdirectory for debug info output inside "./res/" */
+/*#define DEBUG_MODE_INFO_PLC */ /* define to output PLC related parameters */
+/*#define DEBUG_MODE_INFO_ALLRAD*/ /* define to output generated HOA decoding mtx */
+/*#define DEBUG_MODE_LFE */ /* define to output LFE relevant parameters */
+#endif
+
+#ifdef DEBUG_MODE_MDCT
+#define DEBUG_PLOT_BITS
+#endif
+
+#define ENABLE_BITRATE_VERIFICATION /* Enable bitrate verification - use when playing with bit budget */
+/*#define DEBUG_PLOT*/
+/*#define ALLOW_BYTE_EP*/ /* allow byte fer pattern files and check fer pattern file validity */
+#define WRAP_AS_EIDXOR /* wraps FER file (as in STL_eid-xor.c/softbit.c) */
+
+/*#define DEBUG_FORCE_MDCT_STEREO_MODE*/ /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */
+/*#define DEBUG_STEREO_DFT_NOCORE*/ /* DFT stereo: by-pass core coder at decoder side*/
+/*#define DEBUG_STEREO_DFT_NOSTEREO*/ /* DFT stereo: by-pass stereo processing at encoder and decoder side*/
+/*#define DEBUG_STEREO_DFT_NOQRES*/
+/*#define DEBUG_STEREO_DFT_OUTRESPRED*/ /* output residual prediction signal instead of L/R*/
+
+/*DirAC Debug switches*/
+/*#define DEBUG_DISABLE_DIRAC_DELAY_COMP */ /* temporarily disable delay compensation on DirAC encoder */
+/*#define DEBUG_BS_READ_WRITE*/
+/*#define DEBUG_MODE_DIRAC_NOCORE*/
+/*#define DEBUG_MODE_QMETADATA*/ /* output q_metadata parameters */
+
+/*MCT Debug switches*/
+/*#define DEBUG_FORCE_MCT_CP*/ /* force MCT Stereo pairs for verification with SPAR */
+#ifdef DEBUG_FORCE_MCT_CP
+/*#define DEBUG_SINGLE_CODE_OMNI*/ /* force 3 TC SBA always code W channel separately */
+#endif
+
+/*PLC Debug switches*/
+/*#define DEBUG_NO_TONAL_PLC*/
+/*#define DEBUG_NO_TD_TCX_PLC */
+/*#define DEBUG_FORCE_TD_TCX_CONCEALMENT*/
+/*#define DEBUG_PLC_INFO*/
+
+/*#define DEBUG_EFAP_POLY_TOFILE*/ /* Write poly_select values to file in EFAP, used for generating ROM LUTs */
+/*#define TDREND_HRTF_TABLE_METHODS*/ /* Enable HRTF lookup from tables, for testing & evaluation. Supply file in table format to use. Note that a suitable HR filter lookup method should be written if the filters sample point grids are not in the formats. */
+/*#define TDREND_STANDALONE*/ /* Used when renderer is built in standalone form, without IVAS encoding/decoding (see scripts/object_renderer_standalone). This is just here to ensure this is cleaned out by prepare_instrumentation.sh */
+
+/*#define DEBUG_SBA*/ /* debug DIRAC/SPAR in-out */
+#ifdef DEBUG_SBA
+/*#define DEBUG_LBR_SBA*/ /* debug low bitrate SBA (SPAR+DirAC) */
+/*#define DEBUG_SBA_AUDIO_DUMP*/ /* SBA intermediate audio wav file dumping */
+/*#define DEBUG_SBA_MD_DUMP*/ /* SBA metadata and variable file dumping */
+/*#define DEBUG_SPAR_MD_TARGET_TUNING*/ /* SPAR MD target bitrate tuning debug code */
+/*#define DEBUG_SPAR_BYPASS_EVS_CODEC*/ /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */
+/*#define DEBUG_SPAR_WRITE_OUT_COV*/ /* write covariance per frame into a text file for verification */
+/*#define DEBUG_SPAR_DIRAC_WRITE_OUT_PRED_PARS*//* Log SPAR Prediction coefficients to a text file for verification */
+/*#define DEBUG_AGC*/ /* debug SPAR AGC in-out */
+#endif
+/*#define SPAR_HOA_DBG*/ /* SPAR HOA debug statements */
+/* #define DEBUG_OSBA */
+/*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */
+/*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */
+/*#define DEBUG_JBM_CMD_OPTION*/ /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */
+/*#define VARIABLE_SPEED_DECODING*/ /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */
+
+/*Split Rendering Debug switches*/
+/*#define DBG_WAV_WRITER*/ /* add debugging function dbgwrite_wav() */
+/*#define SPLIT_POSE_CORRECTION_DEBUG*/ /* debugging switch for split rendering pose correction */
+/*#define SPLIT_MD_CODING_DEBUG*/ /* debugging switch for split rendering metadata coding */
+
+#endif /* DEBUGGING */
/* #################### End DEBUGGING switches ############################ */
diff --git a/lib_com/parameter_bitmaping.c b/lib_com/parameter_bitmaping.c
index 720324b1e9175388b5a39dfc87e781be7226820b..d722c8a3b326deedd3cde800baf021908ecb55f5 100644
--- a/lib_com/parameter_bitmaping.c
+++ b/lib_com/parameter_bitmaping.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "stat_com.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/phase_dispersion.c b/lib_com/phase_dispersion.c
index eeecc7aaa0d8b61882138313c33ae775fb059811..a89b98c152e7c2abc13d180b4377189b25c4a60c 100644
--- a/lib_com/phase_dispersion.c
+++ b/lib_com/phase_dispersion.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/ppp.c b/lib_com/ppp.c
index d9e553124ec3b9b9827fde1043dd16bc23ff0e03..882c94b6964bbb67b53875a5f8d0ac2502ac44ac 100644
--- a/lib_com/ppp.c
+++ b/lib_com/ppp.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/pred_lt4.c b/lib_com/pred_lt4.c
index 51a0227eae04e88b45dac4792b0b6fd516580857..832c7d0dc5353604cdb85bf97c7613020ec18ea1 100644
--- a/lib_com/pred_lt4.c
+++ b/lib_com/pred_lt4.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/preemph.c b/lib_com/preemph.c
index 024ad379c2a476d069def064c7a3182f7765194f..5e5eb23416f8c62988a2b24d22c6e3c138f305e1 100644
--- a/lib_com/preemph.c
+++ b/lib_com/preemph.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/prot.h b/lib_com/prot.h
index c15223c292f486fa1c9a76d759ed33f8086cd213..f4114fd9a67780b8a5bc09c63031e74799924a8d 100644
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -41,6 +41,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "typedef.h"
#include "stat_enc.h"
#include "stat_dec.h"
@@ -463,23 +466,53 @@ void delay_signal(
const int16_t delay /* i : delay in samples */
);
+#ifdef DEBUG_BS_READ_WRITE
+#define push_indice( ... ) push_indice_( __VA_ARGS__, __LINE__, __func__ )
+ivas_error push_indice_(
+#else
ivas_error push_indice(
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
int16_t id, /* i : ID of the indice */
uint16_t value, /* i : value of the quantized indice */
int16_t nb_bits /* i : number of bits used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
);
+#ifdef DEBUG_BS_READ_WRITE
+#define push_next_indice( ... ) push_next_indice_( __VA_ARGS__, __LINE__, __func__ )
+ivas_error push_next_indice_(
+#else
ivas_error push_next_indice(
+#endif
BSTR_ENC_HANDLE hBstr,
uint16_t value, /* i : value of the quantized indice */
int16_t nb_bits /* i : number of bits used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
);
+#ifdef DEBUG_BS_READ_WRITE
+#define push_next_bits( ... ) push_next_bits_( __VA_ARGS__, __LINE__, __func__ )
+ivas_error push_next_bits_(
+#else
ivas_error push_next_bits(
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const uint16_t bits[], /* i : bit buffer to pack, sequence of single bits */
const int16_t nb_bits /* i : number of bits to pack */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
);
/*! r: maximum number of indices */
@@ -530,9 +563,19 @@ uint16_t delete_indice(
);
/*! r: value of the indice */
+#ifdef DEBUG_BS_READ_WRITE
+#define get_next_indice( ... ) get_next_indice_( __VA_ARGS__, __LINE__, __func__ )
+uint16_t get_next_indice_(
+#else
uint16_t get_next_indice(
+#endif
Decoder_State *st, /* i/o: decoder state structure */
int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
);
/*! r: value of the indice */
@@ -546,10 +589,20 @@ void get_next_indice_tmp(
);
/*! r: value of the indice */
+#ifdef DEBUG_BS_READ_WRITE
+#define get_indice( ... ) get_indice_( __VA_ARGS__, __LINE__, __func__ )
+uint16_t get_indice_(
+#else
uint16_t get_indice(
+#endif
Decoder_State *st, /* i/o: decoder state structure */
int16_t pos, /* i : absolute position in the bitstream */
int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+#ifdef DEBUG_BS_READ_WRITE
+ ,
+ int16_t line,
+ const char *func
+#endif
);
/*! r: value of the indice */
@@ -589,6 +642,14 @@ ivas_error read_indices(
int16_t bfi /* i : bad frame indicator */
);
+#ifdef DEBUGGING
+/*! r: 1 = reading OK, 0 = problem */
+ivas_error preview_indices(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ uint16_t bit_stream[], /* i : bitstream buffer */
+ UWord16 num_bits /* i : number of bits in bitstream */
+);
+#endif
void ivas_set_bitstream_pointers(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
@@ -1695,6 +1756,9 @@ void hq_configure(
int16_t hvq_enc(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const int16_t bwidth, /* i : audio bandwidth */
+#ifdef DEBUGGING
+ const int16_t idchan, /* i : channel ID */
+#endif
const int32_t core_brate, /* i : core bitrate */
const int16_t hvq_bits, /* i : HVQ bit budget */
const int16_t Npeaks, /* i : Number of peaks */
@@ -2060,6 +2124,9 @@ Word32 encode_magnitude_usq_fx(
ivas_error tcq_core_LR_enc(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+#ifdef DEBUGGING
+ const int16_t idchan,
+#endif
int32_t inp_vector[],
const float coefs_norm[],
float coefs_quant[],
@@ -2152,6 +2219,9 @@ void io_ini_enc(
FILE **f_rate, /* o : bitrate switching profile (0 if N/A) */
FILE **f_bwidth, /* o : bandwidth switching profile (0 if N/A) */
FILE **f_metadata, /* o : metadata files (NULL if N/A) */
+#ifdef DEBUGGING
+ FILE **f_force, /* o : force switching profile (0 if N/A) */
+#endif
FILE **f_rf, /* o : channel aware configuration file */
int16_t *quietMode, /* o : limit printouts */
int16_t *noDelayCmp, /* o : turn off delay compensation */
@@ -2182,6 +2252,13 @@ void read_next_bwidth(
int32_t input_Fs /* i : input sampling rate */
);
+#ifdef DEBUGGING
+void read_next_force(
+ int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/
+ FILE *f_force, /* i : force switching profile (0 if N/A) */
+ int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */
+);
+#endif
ivas_error init_encoder(
Encoder_State *st, /* i/o: state structure */
@@ -6119,6 +6196,9 @@ void reverse_transient_frame_energies(
int16_t peak_vq_enc(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const int16_t bwidth, /* i : audio bandwidth */
+#ifdef DEBUGGING
+ const int16_t idchan, /* i : channel ID */
+#endif
const float *coefs, /* i : Input coefficient vector */
float *coefs_out, /* o : Quantized output vector */
const int32_t core_brate, /* i : Core bitrate */
diff --git a/lib_com/pvq_com.c b/lib_com/pvq_com.c
index 7a13fe3f55197ed9710edcc694b2a62e24e35a7d..2368f8436830d2e36068170df8ddc47c5d2e9d38 100644
--- a/lib_com/pvq_com.c
+++ b/lib_com/pvq_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/range_com.c b/lib_com/range_com.c
index 7b3ca8d5e00c0eae3177125eabf6d7d5fe9387fa..b01dc7156e972acaeed28c5dc20c8092f9f1b82c 100644
--- a/lib_com/range_com.c
+++ b/lib_com/range_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/re8_ppv.c b/lib_com/re8_ppv.c
index 75e78ebec228235bb4448d141ac18443f2d77e70..f6c5ab6814fd7adb4791161132f666ee2b9b3e55 100644
--- a/lib_com/re8_ppv.c
+++ b/lib_com/re8_ppv.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/re8_util.c b/lib_com/re8_util.c
index d0737c9d91dc49fcf0fa12f96b2320951c917401..d23ae1c0cd7848b92fb9cbc928d4e51296690aa2 100644
--- a/lib_com/re8_util.c
+++ b/lib_com/re8_util.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include /* for ldexp() */
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/realft.c b/lib_com/realft.c
index 10a08fbf8c93493b62288d215a1a4823558b649c..b7a3fef0d9db4561a1456b336c79522ef99b9457 100644
--- a/lib_com/realft.c
+++ b/lib_com/realft.c
@@ -37,6 +37,9 @@
#include "cnst.h"
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/recovernorm.c b/lib_com/recovernorm.c
index 5b02843c033567012345324cf7db422e5d645680..52e9edcd2a0c02c9249a8139441eb6791582d446 100644
--- a/lib_com/recovernorm.c
+++ b/lib_com/recovernorm.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/reordvct.c b/lib_com/reordvct.c
index 7655220d50cf486239269833e2a0452b51e89dd8..182050bfb65a2449045a887e88171454d5d8181a 100644
--- a/lib_com/reordvct.c
+++ b/lib_com/reordvct.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/residu.c b/lib_com/residu.c
index a46001c26376ca2b9dd33026a6862852ca5d8a6e..e220d81c01d2b60118d0b0186a47d6a6104ebe17 100644
--- a/lib_com/residu.c
+++ b/lib_com/residu.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c
index 2282b0b3de353a99347370b6f298c79daff96732..f08f41a1df98eeb46a454f40d21a09ed61aad5e3 100644
--- a/lib_com/rom_com.c
+++ b/lib_com/rom_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h
index f5e2eef1d018c50a190428f62d11c0beaf76f117..ad234e26d437c082c9cc11e0625220f0aa2a5275 100644
--- a/lib_com/rom_com.h
+++ b/lib_com/rom_com.h
@@ -39,6 +39,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "stat_enc.h"
#include "stat_dec.h"
#include "stl.h"
diff --git a/lib_com/stab_est.c b/lib_com/stab_est.c
index 2b11c7f5f5d09221df925716835aaa48f9c7cc3c..63466220c68c882d71e6834c3b3e749a62166c39 100644
--- a/lib_com/stab_est.c
+++ b/lib_com/stab_est.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index a3e139c187da29094733b0e99a86c1552aac2473..90203dc4700abd848353e13423f3ab42c2386895 100644
--- a/lib_com/stat_com.h
+++ b/lib_com/stat_com.h
@@ -42,6 +42,9 @@
#include "options.h"
#include "typedef.h"
#include "cnst.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
/* Forward declaration of Decoder_State */
struct Decoder_State;
diff --git a/lib_com/stat_noise_uv_mod.c b/lib_com/stat_noise_uv_mod.c
index b269b3fb09d0404c8aa68e4658a64fc604808e15..83c2d321cc584155851be33d275dc97ab459eb33 100644
--- a/lib_com/stat_noise_uv_mod.c
+++ b/lib_com/stat_noise_uv_mod.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/swb_bwe_com.c b/lib_com/swb_bwe_com.c
index f879d274ba8831c44d97ce9798c5732acb5a72ad..4efbaa735d22eaa1acb8748e6c77c154c380e68f 100644
--- a/lib_com/swb_bwe_com.c
+++ b/lib_com/swb_bwe_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/swb_bwe_com_hr.c b/lib_com/swb_bwe_com_hr.c
index 937660f234421fff30db87749558b61b0980e555..fbdcf70b93b600faa5e949ec6e0776375d2d1337 100644
--- a/lib_com/swb_bwe_com_hr.c
+++ b/lib_com/swb_bwe_com_hr.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/swb_bwe_com_lr.c b/lib_com/swb_bwe_com_lr.c
index ef3af7ae33e904184b4ad7d230a5bbf64832a7b6..daa7d167376ba9e5c2ef88de1601d8448af83935 100644
--- a/lib_com/swb_bwe_com_lr.c
+++ b/lib_com/swb_bwe_com_lr.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c
index fb1382ae4a94e16715dd226f3ff4199e3919d632..768078e27ff0795b792bf88d8ff96c4b091be9af 100644
--- a/lib_com/swb_tbe_com.c
+++ b/lib_com/swb_tbe_com.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/syn_12k8.c b/lib_com/syn_12k8.c
index 7d670e1a3fff4bcee8d991f784d8e1248557a19a..15892f62c615bcdae800ca87e2ee9960a0d2293e 100644
--- a/lib_com/syn_12k8.c
+++ b/lib_com/syn_12k8.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/syn_filt.c b/lib_com/syn_filt.c
index 9b766c1bc0cd2efb0e86105a7ba762c105e3849a..08e687c12cdbe5fa7084314b2a387b856a213d99 100644
--- a/lib_com/syn_filt.c
+++ b/lib_com/syn_filt.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/tcq_position_arith.c b/lib_com/tcq_position_arith.c
index a1a2d39ab3060fcb2bce6c9494205389e7841e09..306f29a60b6cecbe071f6bc9a22d9c7389bd5517 100644
--- a/lib_com/tcq_position_arith.c
+++ b/lib_com/tcq_position_arith.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/tcx_ltp.c b/lib_com/tcx_ltp.c
index b92c0b6073e1c9c92074a60b650c2763dd242e31..1711ad24b35e3219360d3ef0cce3e602aeb5d3ce 100644
--- a/lib_com/tcx_ltp.c
+++ b/lib_com/tcx_ltp.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c
index 05a70cdc908d1d9158d01339ed96565852d07916..0ef69587a8a690b4ee5917a5f6e12bace8317394 100644
--- a/lib_com/tcx_mdct_window.c
+++ b/lib_com/tcx_mdct_window.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c
index a96c19e11784c3c251b8e540bae2861d3b9e92ac..ec219456b089e0c7a44d09f42e2f1a6a8498f980 100644
--- a/lib_com/tcx_utils.c
+++ b/lib_com/tcx_utils.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/tools.c b/lib_com/tools.c
index a30895bac38c3fb3d044cb10217b34a227f77964..ecd2fdbfa4335d846d5eba766498779445adb374 100644
--- a/lib_com/tools.c
+++ b/lib_com/tools.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/trans_direct.c b/lib_com/trans_direct.c
index cc63ce39faa0fab1beb1ad875eff2a9daa44cd10..964ba36f76cb531d2dee5a5b7e750a42374f38c4 100644
--- a/lib_com/trans_direct.c
+++ b/lib_com/trans_direct.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_com/trans_inv.c b/lib_com/trans_inv.c
index 5b4d485afffec820309db3ecce84eb1bf0e1b477..1eea807b2ffe951fcb9df0598f8135a5a333ccc4 100644
--- a/lib_com/trans_inv.c
+++ b/lib_com/trans_inv.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/weight.c b/lib_com/weight.c
index 61985717838b0e60599f924636b15603be63d4fb..6c2e1c291af10340e0883d603fbb559fc1b5b309 100644
--- a/lib_com/weight.c
+++ b/lib_com/weight.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_com/weight_a.c b/lib_com/weight_a.c
index 5b5619eec5e89edb8876f89694a02a624b5854f5..96b8014e41ceb31bed1edbd4067e1fe2f628d509 100644
--- a/lib_com/weight_a.c
+++ b/lib_com/weight_a.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_com/window.c b/lib_com/window.c
index a54cb7c0771d149e6eb3392a5d4c143f2eaddd30..093dbd4fc62342b2d96d2706ef31a04c1a36a201 100644
--- a/lib_com/window.c
+++ b/lib_com/window.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "prot.h"
#define WMC_TOOL_SKIP
diff --git a/lib_com/window_ola.c b/lib_com/window_ola.c
index 8d1b98e38e566416d0ff2793c63b678ca2f76945..07798af16ed4fcdadbe7dfbfb90251c0c9235d04 100644
--- a/lib_com/window_ola.c
+++ b/lib_com/window_ola.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/wtda.c b/lib_com/wtda.c
index ec7bc080a243f79a3a2c930a9e5c0425f2fd6390..3bd839e5ac4f9b28121f77ad819a2f59cc7ef316 100644
--- a/lib_com/wtda.c
+++ b/lib_com/wtda.c
@@ -36,11 +36,17 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
#include
#include "wmc_auto.h"
+#ifdef DEBUG_PLOT
+#include "deb_out.h"
+#endif
/*--------------------------------------------------------------------------*
* mvr2r_inv()
@@ -284,6 +290,9 @@ void wtda(
{
allsig_r = new_audio + n;
allsig_l = new_audio + n - L;
+#ifdef DEBUG_PLOT
+ sendDebout( "tcx_mdct", 2 * L, 1, "mdct_sig", MTV_FLOAT, allsig_l );
+#endif
}
else
{
diff --git a/lib_debug/debug.c b/lib_debug/debug.c
new file mode 100644
index 0000000000000000000000000000000000000000..736f35d43d3b41ca29428063ff654f396e18e3e1
--- /dev/null
+++ b/lib_debug/debug.c
@@ -0,0 +1,978 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+#include
+#include
+#endif
+#endif
+#endif
+#include "cnst.h"
+#include
+#include
+#include
+#ifdef _WIN32
+#include
+#else
+#endif
+#ifdef DBG_WAV_WRITER
+#include "tinywaveout_c.h"
+#endif
+#include "wmc_auto.h"
+
+
+/*-------------------------------------------------------------------*
+ * Global variables used for debugging but not under DEBUGGING flag
+ *--------------------------------------------------------------------*/
+
+#ifdef DEBUGGING
+uint16_t g_nPrintedLines = 0;
+
+int16_t g_verbose = 0; /* global variable for debugging */
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+char infoFolder[FILENAME_MAX];
+#endif
+#endif
+#endif
+
+FILE *DJB_delay = NULL; /* per-frame de-jitter buffer delay dump out file */
+
+#ifdef DEBUGGING
+int16_t debug_level = 0;
+#endif
+
+/*-------------------------------------------------------------------*
+ * Read/write I/O tool
+ *--------------------------------------------------------------------*/
+
+#ifdef DEBUGGING
+#define N_FILEPTR 500
+#define N_DBGFLAG 100
+#define N_DBGVAL 100
+#define N_TYPES 6
+
+static FILE *in_fileptr[N_FILEPTR];
+static FILE *out_fileptr[N_FILEPTR];
+#ifdef DBG_WAV_WRITER
+static WAVEFILEOUT *out_wavfileptr[N_FILEPTR];
+#endif
+static char *in_filename[N_FILEPTR];
+static char *out_filename[N_FILEPTR];
+#ifdef DBG_WAV_WRITER
+static char *out_wavfilename[N_FILEPTR];
+#endif
+static int16_t in_count = 0;
+static int16_t out_count = 0;
+#ifdef DBG_WAV_WRITER
+static int16_t out_wav_count = 0;
+#endif
+
+static int16_t flag_count = 0;
+static char *flag_name[N_DBGFLAG];
+static int16_t val_count = 0;
+static char *val_name[N_DBGVAL];
+static char *val[N_DBGVAL];
+
+static char *type_list[N_TYPES] = { "char", "short", "int", "long", "float", "double" };
+
+static void setvalue(
+ const char *value_name, /* i : Value name */
+ const char *value /* i : Value as string */
+);
+
+static int16_t make_dirs( const char *const pathname );
+
+/*-------------------------------------------------------------------*
+ * dbgwrite()
+ *
+ * Writes the buffer content to the specified file. If the file is not in the
+ * debug file list, it is opened before write.
+ *--------------------------------------------------------------------*/
+
+int16_t dbgwrite(
+ const void *const buffer, /* i : Write buffer */
+ const int16_t size, /* i : Element size */
+ const int16_t count, /* i : Number of elements */
+ const int16_t repeat, /* i : Number of times the elements are repeated */
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename /* i : Output file name */
+#else
+ const char *const filename
+#endif
+)
+{
+ int16_t index, i;
+ void *tmp_buf;
+
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ char filename_mod[FILENAME_MAX];
+ int16_t textmode = 0;
+ int16_t x = *(const int16_t *const) buffer; /* currently the textmode is only defined with "short" as input */
+ memset( filename_mod, 0, FILENAME_MAX );
+ tweakdbgfolder( filename, filename_mod, &textmode );
+ if ( filename_mod[0] != 0 )
+ {
+ filename = filename_mod;
+ }
+#endif
+#endif
+
+ index = lookup( filename, (const char *const *) out_filename, out_count );
+
+ if ( index == -1 )
+ {
+ if ( make_dirs( filename ) != 0 )
+ {
+ fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ index = out_count;
+ out_fileptr[index] = fopen( filename, "wb" );
+ out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
+ strcpy( out_filename[index], filename );
+ out_count++;
+ }
+
+ if ( out_fileptr[index] != NULL )
+ {
+ tmp_buf = calloc( count * repeat, size );
+ if ( buffer != NULL )
+ {
+ for ( i = 0; i < repeat; i++ )
+ {
+ memcpy( (char *) tmp_buf + i * size * count, buffer, size * count );
+ }
+ }
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ if ( 1 == textmode && 2 == size )
+ { /* currently the textmode is only defined with "short" as input */
+ fprintf( out_fileptr[index], "%d\n", x );
+ }
+ else
+ {
+#endif
+#endif
+ fwrite( tmp_buf, size * count * repeat, 1, out_fileptr[index] );
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ }
+#endif
+#endif
+ free( tmp_buf );
+ }
+ else
+ {
+ fprintf( stderr, "dbgwrite: Could not write to file: %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------*
+ * dbgwrite_mat_repeat()
+ *
+ * Writes buffer a buffer containing a column-wise ordered matrix
+ * to the specified file. If the file is not in the
+ * debug file list, it is opened before write.
+ *--------------------------------------------------------------------*/
+
+void dbgwrite_mat_repeat( float *buffer, /* i : write buffer */
+ int16_t nRow, /* i : matrix size (rows) */
+ int16_t mCol, /* i : matrix size (columns) */
+ int16_t row_repeat, /* i : number of times rows are repeated */
+ int16_t col_repeat, /* i : number of times columns are repeated */
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename /* i : Output file name */
+#else
+ const char *const filename
+#endif
+)
+{
+ float *copy_buffer = calloc( nRow * row_repeat * mCol * col_repeat, sizeof( float ) );
+ int16_t r, c, rr, cc;
+ float *cp = ©_buffer[0];
+ float *colp;
+ for ( c = 0; c < mCol; c++ )
+ {
+ for ( cc = 0; cc < col_repeat; cc++ )
+ {
+ colp = buffer + c * nRow;
+ for ( r = 0; r < nRow; r++ )
+ {
+ for ( rr = 0; rr < row_repeat; rr++ )
+ {
+ *( cp++ ) = *colp;
+ }
+ colp++;
+ }
+ }
+ }
+
+ dbgwrite( copy_buffer, sizeof( float ), nRow * row_repeat * mCol * col_repeat, 1, filename );
+ free( copy_buffer );
+}
+
+
+/*-------------------------------------------------------------------*
+ * dbgappend()
+ *
+ * Appends the buffer content to the specified file. If the file is not in the
+ * debug file list, it is opened before first write.
+ *--------------------------------------------------------------------*/
+
+int16_t dbgappend(
+ const void *const buffer, /* i : Append buffer */
+ const int16_t size, /* i : Element size */
+ const int16_t count, /* i : Number of elements */
+ const int16_t repeat, /* i : Number of times the elements are repeated */
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename /* i : Output file name */
+#else
+ const char *const filename
+#endif
+)
+{
+ int16_t index, i;
+
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ char filename_mod[FILENAME_MAX];
+ int16_t textmode = 0; /* textmode is only implemented in dbgwrite() currently */
+ memset( filename_mod, 0, FILENAME_MAX );
+ tweakdbgfolder( filename, filename_mod, &textmode );
+ if ( filename_mod[0] != 0 )
+ {
+ filename = filename_mod;
+ }
+#endif
+#endif
+ index = lookup( filename, (const char *const *) out_filename, out_count );
+
+ if ( index == -1 )
+ {
+ if ( make_dirs( filename ) != 0 )
+ {
+ fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ index = out_count;
+ out_fileptr[index] = fopen( filename, "ab" );
+ out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
+ strcpy( out_filename[index], filename );
+ out_count++;
+ }
+
+ if ( out_fileptr[index] != NULL )
+ {
+ for ( i = 0; i < repeat; i++ )
+ {
+ fwrite( buffer, size, count, out_fileptr[index] );
+ }
+ }
+ else
+ {
+ fprintf( stderr, "dbgappend: Could not write to file: %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ return 0;
+}
+
+/*-------------------------------------------------------------------*
+ * dbgread()
+ *
+ * Reads data from the specified file. If the file is not open, it will be
+ * opened.
+ *--------------------------------------------------------------------*/
+
+int16_t dbgread(
+ void *const buffer, /* o : Read buffer */
+ const int16_t size, /* i : Element size */
+ const int16_t count, /* i : Number of elements */
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename /* i : Input file name */
+#else
+ const char *const filename
+#endif
+)
+{
+ int16_t index;
+
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+ char filename_mod[FILENAME_MAX];
+ int16_t textmode = 0; /* textmode is only implemented in dbgwrite() currently */
+ memset( filename_mod, 0, FILENAME_MAX );
+ tweakdbgfolder( filename, filename_mod, &textmode );
+ if ( filename_mod[0] != 0 )
+ {
+ filename = filename_mod;
+ }
+#endif
+#endif
+
+ index = lookup( filename, (const char *const *) in_filename, in_count );
+
+ if ( index == -1 )
+ {
+ index = in_count;
+ in_fileptr[index] = fopen( filename, "rb" );
+ in_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
+ strcpy( in_filename[index], filename );
+ in_count++;
+ }
+
+ if ( in_fileptr[index] != NULL )
+ {
+ fread( buffer, size, count, in_fileptr[index] );
+ }
+ else
+ {
+ fprintf( stderr, "dbgread: Could not read from file: %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ return 0;
+}
+
+/*-------------------------------------------------------------------*
+ * dbgclose()
+ *
+ * Closes opened files and frees allocated memory
+ *--------------------------------------------------------------------*/
+
+void dbgclose( void )
+{
+ int16_t i;
+
+ for ( i = 0; i < in_count; i++ )
+ {
+ fclose( in_fileptr[i] );
+ free( in_filename[i] );
+ }
+
+ for ( i = 0; i < out_count; i++ )
+ {
+ fclose( out_fileptr[i] );
+ free( out_filename[i] );
+ }
+
+#ifdef DBG_WAV_WRITER
+ for ( i = 0; i < out_wav_count; i++ )
+ {
+ CloseWav( out_wavfileptr[i] );
+ free( out_wavfilename[i] );
+ }
+#endif
+ for ( i = 0; i < snr_count; i++ )
+ {
+ free( snr_name[i] );
+ }
+
+ for ( i = 0; i < flag_count; i++ )
+ {
+ free( flag_name[i] );
+ }
+
+ for ( i = 0; i < val_count; i++ )
+ {
+ free( val_name[i] );
+ free( val[i] );
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * dbgflag()
+ *
+ * Checks if a debug flag is set. The flag is identified with a string.
+ *--------------------------------------------------------------------*/
+
+int16_t dbgflag(
+ const char *flagname /* i : Flag name */
+)
+{
+ int16_t result;
+
+ result = lookup( flagname, (const char *const *) flag_name, flag_count );
+
+ return ( result != -1 );
+}
+
+/*-------------------------------------------------------------------*
+ * setflag()
+ *
+ * Sets the flag with the specified string
+ *--------------------------------------------------------------------*/
+
+void setflag(
+ const char *flagname /* i : Flag name */
+)
+{
+ int16_t result;
+
+ result = lookup( flagname, (const char *const *) flag_name, flag_count );
+
+ if ( result == -1 )
+ {
+ flag_name[flag_count] = malloc( sizeof( char ) * ( strlen( flagname ) + 1 ) );
+ strcpy( flag_name[flag_count], flagname );
+ flag_count++;
+ }
+
+ return;
+}
+
+/*----------------------------------------------------------------------------*
+ * dbgargs()
+ *
+ * N.B. Should be run before existing command line interpretation
+ *
+ * Command line interpreter for debug arguments. Removes the debug
+ * arguments after interpretation so that existing command line interpretation
+ * may be run afterwards.
+ *
+ * Arguments:
+ * -D flag_name Sets the debug flag labelled flag_name.
+ * The function dbgflag("flag_name") will return 1.
+ *
+ * -V val_name val Sets the debug value labelled val_name to val.
+ * dbgvalue("type","val_name",&value) will retrieve the value
+ *
+ *-----------------------------------------------------------------------------*/
+
+/*! r: No. debug arguments */
+int16_t dbgargs(
+ int32_t *argc, /* i/o: No. input arguments / No. arguments without dbg arguments */
+ char *argv[] /* i/o: Input arguments / Input arguments without dbg arguments */
+)
+{
+ int16_t i, j, dbgargs;
+
+ i = 0;
+ dbgargs = 0;
+ while ( i < *argc )
+ {
+ if ( strcmp( argv[i], "-D" ) == 0 )
+ {
+ j = i;
+ dbgargs++;
+ i++;
+ setflag( argv[i] );
+ for ( ; j < *argc - 2; j++ )
+ {
+ argv[j] = argv[j + 2];
+ }
+ *argc -= 2;
+ i -= 2;
+ }
+
+ if ( strcmp( argv[i], "-V" ) == 0 )
+ {
+ j = i;
+ dbgargs++;
+ i++;
+ setvalue( argv[i], argv[i + 1] );
+ for ( ; j < *argc - 3; j++ )
+ {
+ argv[j] = argv[j + 3];
+ }
+ *argc -= 3;
+ i -= 3;
+ }
+ i++;
+ }
+
+ return dbgargs;
+}
+
+/*-------------------------------------------------------------------*
+ * dbgvalue()
+ *
+ * Lookup a debug value
+ *
+ * Allowed typestr values:
+ * "char","short","int","long","float","double"
+ *
+ * If the value is not set, the output value is not assigned
+ *
+ *-------------------------------------------------------------------*/
+
+/*! r: Returns 1 if value is assigned, otherwise 0 */
+int16_t dbgvalue(
+ const char *typestr, /* i : Type as string:"int","char",... */
+ const char *value_name, /* i : Value tag name given on command line */
+ ... /* o : Output variable, type: pointer to "typestr" */
+)
+{
+ int16_t index;
+ char *value;
+ int16_t assigned;
+ char *c;
+ int16_t *sh;
+ int *i;
+ int32_t *l;
+ float *f;
+ double *d;
+ va_list ap;
+ va_start( ap, value_name );
+
+ index = lookup( value_name, (const char *const *) val_name, val_count );
+
+ if ( index != -1 )
+ {
+ value = val[index];
+ index = lookup( typestr, (const char *const *) type_list, N_TYPES );
+ switch ( index )
+ {
+ case 0:
+ c = va_arg( ap, char * );
+ sscanf( value, "%c", c );
+ break;
+ case 1:
+ sh = va_arg( ap, int16_t * );
+ sscanf( value, "%hi", sh );
+ break;
+ case 2:
+ i = va_arg( ap, int * );
+ sscanf( value, "%i", i );
+ break;
+ case 3:
+ l = va_arg( ap, int32_t * );
+ sscanf( value, "%i", l );
+ break;
+ case 4:
+ f = va_arg( ap, float * );
+ sscanf( value, "%f", f );
+ break;
+ case 5:
+ d = va_arg( ap, double * );
+ sscanf( value, "%lf", d );
+ break;
+ default:
+ fprintf( stderr, "dbgvalue::Unsupported type string %s. Exiting...\n", typestr );
+ exit( -1 );
+ }
+ assigned = 1;
+ }
+ else
+ {
+ assigned = 0;
+ }
+
+ va_end( ap );
+
+ return assigned;
+}
+
+/*-------------------------------------------------------------------*
+ * lookup()
+ *
+ * Returns the index of the given string, or -1 if not found
+ *--------------------------------------------------------------------*/
+
+/*! r: Index of string, -1 if not found */
+int16_t lookup(
+ const char *const str, /* i : String to lookup */
+ const char *const *const list, /* i : List of strings */
+ const int16_t n_elem /* i : Number of elements */
+)
+{
+ int16_t i, result;
+
+ result = -1;
+ i = 0;
+ while ( i < n_elem && result == -1 )
+ {
+ if ( strcmp( str, list[i] ) == 0 )
+ {
+ result = i;
+ }
+ i++;
+ }
+
+ return result;
+}
+
+/*-------------------------------------------------------------------*
+ * setvalue()
+ *
+ * Sets the debug name value pair
+ *--------------------------------------------------------------------*/
+
+static void setvalue(
+ const char *value_name, /* i : Value name */
+ const char *value ) /* i : Value as string */
+
+{
+ int16_t result;
+
+ result = lookup( value_name, (const char *const *) val_name, val_count );
+
+ if ( result == -1 )
+ {
+ val_name[val_count] = malloc( sizeof( char ) * ( strlen( value_name ) + 1 ) );
+ strcpy( val_name[val_count], value_name );
+ val[val_count] = malloc( sizeof( char ) * ( strlen( value ) + 1 ) );
+ strcpy( val[val_count], value );
+ val_count++;
+ fprintf( stdout, "\nDebug value set: %s = %s\n", value_name, value );
+ }
+ else
+ {
+ fprintf( stdout, "\n*** Value %s already set: %s\n", value_name, val[result] );
+ }
+
+ return;
+}
+
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+/*-------------------------------------------------------------------*
+ * tweakdbgfolder()
+ *
+ * in: filename
+ * out: filename_mod
+ *
+ * returns modified path to debug files for reading and writing functions.
+ * creates in "./res" if given on command line
+ * with switch -info .
+ *
+ *--------------------------------------------------------------------*/
+
+int16_t tweakdbgfolder( const char *filename, char *filename_mod, int16_t *textmode )
+{
+ int16_t i, j;
+ char *p_infoFolder = infoFolder;
+ char *p_filename_mod = filename_mod;
+ int16_t n_prefix = 0;
+ char *suffix;
+
+ /* if debug folder name given on command line, write debug info to sub folder */
+ if ( infoFolder[0] != 0 )
+ {
+ if ( filename[0] == '.' )
+ {
+ n_prefix = 5;
+ }
+ else if ( filename[0] == 'r' )
+ {
+ n_prefix = 3;
+ }
+ else
+ {
+ fprintf( stderr, "tweakdbgfolder: Unexpected debug folder. Exiting..\n" );
+ exit( -1 );
+ }
+ for ( i = 0; i <= n_prefix; i++ )
+ {
+ p_filename_mod[i] = filename[i];
+ }
+ j = i;
+ while ( *p_infoFolder != 0 )
+ {
+ p_filename_mod[i] = *p_infoFolder;
+ i++;
+ p_infoFolder++;
+ }
+ p_filename_mod[i] = '/';
+ i++;
+
+ while ( filename[j] != 0 )
+ {
+ p_filename_mod[i] = filename[j];
+ i++;
+ j++;
+ }
+ /* detect textmode, only working with given debug folder name, otherwise no counter available for length of filename */
+ suffix = &p_filename_mod[i - 4];
+ if ( strncmp( suffix, ".txt", 4 ) == 0 )
+ {
+ *textmode = 1;
+ }
+ else
+ {
+ *textmode = 0;
+ }
+ }
+
+
+ return 0;
+}
+#endif
+#endif
+
+
+#ifdef DEBUG_MODE_INFO
+/*-------------------------------------------------------------------*
+ * fname()
+ *
+ * returns file name (string) that identifies - parameter/signal to be outputted
+ - channel ID (0 or 1)
+ - element ID (0, 1, etc.)
+ *--------------------------------------------------------------------*/
+
+char debug_dir[6] = "res/";
+
+char tmp_fname[FILENAME_MAX];
+
+char *fname(
+ char *dir,
+ char *file,
+ const int16_t n,
+ const int16_t id,
+ const int16_t enc_dec )
+{
+ char idd[5] = ".idX";
+ idd[3] = (char) ( id + '0' );
+
+ strcpy( tmp_fname, dir );
+ strcat( tmp_fname, file );
+
+ if ( enc_dec == DEC )
+ strcat( tmp_fname, ".dec" );
+ if ( id > 0 )
+ strcat( tmp_fname, idd );
+ if ( n > 0 )
+ strcat( tmp_fname, ".ch2" );
+
+ return tmp_fname;
+}
+#endif
+
+
+/*-------------------------------------------------------------------*
+ * make_dirs()
+ *
+ * extract path(s) form the pathname and create them if not existing
+ *--------------------------------------------------------------------*/
+
+int16_t make_dirs( const char *const pathname )
+{
+ const char *p;
+ char *temp;
+ char sep = 0;
+#ifdef _WIN32
+ struct _stat s = { 0 };
+#else
+ struct stat s = { 0 };
+#endif
+ /* find path separator */
+ if ( strchr( pathname, '\\' ) != NULL )
+ {
+ sep = '\\';
+ }
+ else if ( strchr( pathname, '/' ) != NULL )
+ {
+ sep = '/';
+ }
+
+ if ( sep != 0 )
+ {
+ temp = calloc( 1, strlen( pathname ) + 1 );
+ p = pathname;
+ while ( ( p = strchr( p, sep ) ) != NULL )
+ {
+ /* skip consecutive separators and '.', '..' symbols */
+ if ( p != pathname && ( *( p - 1 ) == sep || *( p - 1 ) == '.' ) )
+ {
+ p++;
+ continue;
+ }
+
+ /* put the path up to this point into a temp dir */
+ memcpy( temp, pathname, p - pathname );
+ temp[p - pathname] = '\0';
+ p++;
+
+ /* check if path exists and create it with mkdir() if not */
+#ifdef _WIN32
+ if ( _stat( temp, &s ) == -1 )
+ {
+ if ( _mkdir( temp ) != 0 )
+ {
+ if ( errno != 0 )
+ {
+ return 1;
+ }
+ }
+ }
+#else
+ if ( stat( temp, &s ) == -1 )
+ {
+ if ( mkdir( temp, 0755 ) != 0 )
+ {
+ if ( errno != 0 )
+ {
+ return 1;
+ }
+ }
+ }
+#endif
+ }
+
+ free( temp );
+ }
+
+ return 0;
+}
+
+#ifdef DBG_WAV_WRITER
+int16_t dbgwrite_wav(
+ const float *buffer[], /* i : Write buffer */
+ const int16_t count_per_ch, /* i : Number of elements */
+ const char *const filename,
+ int32_t fs,
+ int16_t num_chs )
+{
+ int16_t index, i;
+ int16_t *tmp_buf;
+
+ index = lookup( filename, (const char *const *) out_wavfilename, out_wav_count );
+
+ if ( index == -1 )
+ {
+ if ( make_dirs( filename ) != 0 )
+ {
+ fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ index = out_wav_count;
+ out_wavfileptr[index] = CreateWav( (const char *) filename, fs, num_chs, 16 /* const uint32_t writeWaveExt */ );
+ out_wavfilename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
+ strcpy( out_wavfilename[index], filename );
+ out_wav_count++;
+ }
+
+ if ( out_wavfileptr[index] != NULL )
+ {
+ int16_t j, k;
+ float tmp;
+ tmp_buf = (int16_t *) calloc( count_per_ch * num_chs, sizeof( int16_t ) );
+ k = 0;
+ for ( j = 0; j < count_per_ch; j++ )
+ {
+ for ( i = 0; i < num_chs; i++, k++ )
+ {
+ tmp = roundf( buffer[i][j] );
+ tmp_buf[k] = ( tmp > MAX16B_FLT ) ? MAX16B : ( tmp < MIN16B_FLT ) ? MIN16B
+ : (short) tmp;
+ }
+ }
+ WriteWavShort( out_wavfileptr[index], tmp_buf, count_per_ch * num_chs );
+ free( tmp_buf );
+ }
+ else
+ {
+ fprintf( stderr, "dbgwrite_wav: Could not write to file: %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ return 0;
+}
+
+
+int16_t dbgwrite_txt(
+ const float *buffer, /* i : Write buffer */
+ const int16_t count, /* i : Number of elements */
+ const char *const filename,
+ const char *const msg_opt )
+{
+ int16_t index, i;
+
+ index = lookup( filename, (const char *const *) out_filename, out_count );
+
+ if ( index == -1 )
+ {
+ if ( make_dirs( filename ) != 0 )
+ {
+ fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ index = out_count;
+ out_fileptr[index] = fopen( filename, "w" );
+ out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
+ strcpy( out_filename[index], filename );
+ out_count++;
+ }
+
+ if ( out_fileptr[index] != NULL )
+ {
+ if ( buffer != NULL )
+ {
+ if ( msg_opt == NULL )
+ {
+ for ( i = 0; i < count; i++ )
+ {
+ fprintf( out_fileptr[index], "%f\n", buffer[i] );
+ }
+ }
+ else
+ {
+ for ( i = 0; i < count; i++ )
+ {
+ fprintf( out_fileptr[index], "%s %f\n", msg_opt, buffer[i] );
+ }
+ }
+ }
+ }
+ else
+ {
+ fprintf( stderr, "dbgwrite_txt: Could not write to file: %s. Exiting..\n", filename );
+ exit( -1 );
+ }
+
+ return 0;
+}
+#endif
+#endif /* DEBUGGING */
diff --git a/lib_debug/debug.h b/lib_debug/debug.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac2ac689b8a5fe768b5629c07239f41364995761
--- /dev/null
+++ b/lib_debug/debug.h
@@ -0,0 +1,257 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+#include "options.h"
+#include
+#include
+#ifdef DEBUG_SBA
+#include "sba_debug.h"
+#endif
+
+/*------------------------------------------------------------------------------------------*
+ * Global variables used for debugging
+ *------------------------------------------------------------------------------------------*/
+
+#ifdef DEBUGGING
+extern int32_t frame;
+#endif
+
+#ifdef DEBUGGING
+extern uint16_t g_nPrintedLines;
+extern int16_t g_verbose;
+#endif
+
+#ifdef DEBUGGING
+extern int16_t debug_level;
+#define DEBUG_LINE( level ) if ( ( level ) <= debug_level )
+#else
+#define DEBUG_LINE( level ) if ( 0 )
+#endif
+
+#ifdef DEBUG_MODE_INFO
+extern char tmp_fname[];
+extern char debug_dir[6];
+char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec );
+#endif
+
+/*------------------------------------------------------------------------------------------*
+ * Read/write I/O tool
+ *------------------------------------------------------------------------------------------*/
+
+#ifdef DEBUGGING
+
+int16_t lookup(
+ const char *const str,
+ const char *const *const list,
+ const int16_t n_elem );
+
+#ifdef DEBUG_MODE_INFO
+#ifdef DEBUG_MODE_INFO_TWEAK
+int16_t tweakdbgfolder(
+ const char *filename,
+ char *filename_mod,
+ int16_t *textmode );
+#endif
+#endif
+
+int16_t dbgwrite(
+ const void *const buffer,
+ const int16_t size,
+ const int16_t count,
+ const int16_t repeat,
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename
+#else
+ const char *const filename
+#endif
+);
+
+#ifdef DBG_WAV_WRITER
+int16_t dbgwrite_wav(
+ const float *buffer[], /* i : Write buffer */
+ const int16_t count_per_ch, /* i : Number of elements */
+ const char *const filename,
+ int32_t fs,
+ int16_t num_chs );
+int16_t dbgwrite_txt(
+ const float *buffer, /* i : Write buffer */
+ const int16_t count, /* i : Number of elements */
+ const char *const filename,
+ const char *const msg_opt );
+#endif
+void dbgwrite_mat_repeat(
+ float *buffer, /* i : write buffer */
+ int16_t nRow, /* i : matrix size (rows) */
+ int16_t mCol, /* i : matrix size (columns) */
+ int16_t row_repeat, /* i : number of times rows are repeated */
+ int16_t col_repeat, /* i : number of times columns are repeated */
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename /* i : Output file name */
+#else
+ const char *const filename
+#endif
+);
+
+int16_t dbgappend(
+ const void *const buffer,
+ const int16_t size,
+ const int16_t count,
+ const int16_t repeat,
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename
+#else
+ const char *const filename
+#endif
+);
+
+int16_t dbgread(
+ void *const buffer,
+ const int16_t size,
+ const int16_t count,
+#ifdef DEBUG_MODE_INFO_TWEAK
+ const char *filename
+#else
+ const char *const filename
+#endif
+);
+
+void dbgclose( void );
+
+int16_t dbgflag(
+ const char *flagname );
+
+void setflag(
+ const char *flagname );
+
+int16_t dbgargs(
+ int32_t *argc,
+ char *argv[] );
+
+int16_t dbgvalue(
+ const char *typestr,
+ const char *value_name,
+ ... );
+
+extern FILE *DJB_delay;
+
+extern FILE *FEC_pattern;
+
+#endif /* DEBUGGING */
+
+/*------------------------------------------------------------------------------------------*
+ * SNR measurement tool
+ *------------------------------------------------------------------------------------------*/
+
+#ifdef DEBUGGING
+
+extern int16_t snr_count;
+extern char *snr_name[];
+
+void snr(
+ const float *const signal,
+ const float *const noise,
+ const int16_t length,
+ const char *const name );
+
+void snr_diff(
+ const float *const clean,
+ const float *const degraded,
+ const int16_t length,
+ const int16_t delay,
+ const char *const name );
+
+void snr_celp(
+ const int16_t L_frame,
+ const int16_t L_subfr,
+ const float gamma,
+ const float tilt_fac,
+ const int16_t vad_flag,
+ const int16_t coder_type,
+ const float *input,
+ const float *output,
+ const float *A,
+ const int16_t idchan,
+ const char *name );
+
+void print_snr( void );
+
+#else
+
+#define print_snr( void )
+
+#endif
+
+/*------------------------------------------------------------------------------------------*
+ * SD analysis tool
+ *------------------------------------------------------------------------------------------*/
+
+#ifdef DEBUGGING
+
+/*! r: SD in a given frequency range */
+float sd_range(
+ const float lsf[], /* i : vector of unquantized LSF values */
+ const float lsf_q[], /* i : vector of quantized LSF values */
+ const int16_t order, /* i : dimension of the vectors */
+ const int32_t fs, /* i : sampling frequency */
+ const float min_freq, /* i : minimum frequency of interest */
+ const float max_freq, /* i : maximum frequency of interest */
+ const char *const name, /* i : string for SD entry in the global table */
+ const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+);
+
+/*! r: SD respecting critical bands */
+float sd_crit(
+ const float lsf[], /* i : vector of unquantized LSF values */
+ const float lsf_q[], /* i : vector of quantized LSF values */
+ const int16_t order, /* i : dimension of the vectors */
+ const int32_t fs, /* i : sampling frequency */
+ const float min_freq, /* i : minimal frequency */
+ const float max_freq, /* i : maximal frequency */
+ int16_t *min_band, /* o : minimal critical band */
+ int16_t *max_band, /* o : maximal critical band */
+ float sd_bands[], /* i/o: SD in critical bands */
+ const char *const name, /* i : string for SD entry in the global table */
+ const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+);
+
+void print_sd( void );
+
+#else
+
+#define print_sd( void )
+
+#endif
+
+#endif /* DEBUG_H */
diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c
new file mode 100644
index 0000000000000000000000000000000000000000..de4b549aacb5150c0010871700add2d0f9245043
--- /dev/null
+++ b/lib_debug/sba_debug.c
@@ -0,0 +1,431 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include "options.h"
+#include "ivas_cnst.h"
+#include "sba_debug.h"
+#include
+#include "wmc_auto.h"
+#ifdef DEBUG_SBA
+#include
+#include "tinywaveout_c.h"
+
+/*-------------------------------------------------------------------*
+ * Global variables used for debugging but not under DEBUGGING flag
+ *--------------------------------------------------------------------*/
+
+#define MAX_IN_FILE_LEN ( 1000 )
+#define MAX_PLUG_IN_FILE_LEN ( MAX_IN_FILE_LEN )
+#define MAX_DEBUG_TAG_LEN ( 50 )
+#define NUM_DEBUG_FILES ( 5 )
+#define MAX_TAG_LEN ( 200 )
+
+WAVEFILEOUT *spar_foa_enc_wav[3];
+WAVEFILEOUT *spar_foa_dec_wav[NUM_DEBUG_FILES];
+float max_diff = 0;
+int32_t dbg_frm_num;
+int32_t dbg_band;
+int32_t dbg_type;
+int32_t iter_max = 0;
+FILE *fFb_pcm = NULL;
+int8_t file_names[NUM_DEBUG_FILES][MAX_TAG_LEN + MAX_DEBUG_TAG_LEN];
+
+
+#ifdef DEBUG_AGC
+FILE *agcOut = NULL; /* temporary AGC bitstream */
+#endif
+
+/*-----------------------------------------------------------------------------------------*
+ * Function description
+ * cstrcpy() - Custom implementation of strcpy
+ *
+ * Inputs:
+ * const char* _Source -> Source buffer
+ * _SizeInBytes -> Destination buffer size in bytes
+ *
+ * Outputs:
+ * char* _Destination -> Destination buffer
+ *-----------------------------------------------------------------------------------------*/
+
+static void cstrcpy( char *_Destination, size_t _SizeInBytes, const char *_Source )
+{
+ size_t SourceSizeInBytes = strlen( _Source );
+ if ( _SizeInBytes > SourceSizeInBytes )
+ {
+ strcpy( _Destination, _Source );
+ }
+ else
+ {
+ assert( 0 );
+ }
+
+ return;
+}
+
+
+/*-----------------------------------------------------------------------------------------*
+ * Function description
+ * cstrcat() - Custom implementation of strcat
+ *
+ * Inputs:
+ * const char* _Source -> Source buffer
+ * _SizeInBytes -> Destination buffer size in bytes
+ *
+ * Outputs:
+ * char* _Destination -> Destination buffer
+ *-----------------------------------------------------------------------------------------*/
+
+static void cstrcat( char *_Destination, size_t _SizeInBytes, const char *_Source )
+{
+ size_t SourceSizeInBytes = strlen( _Source );
+ size_t DestSizeInBytes = _SizeInBytes - strlen( _Destination );
+ if ( DestSizeInBytes > SourceSizeInBytes )
+ {
+ strcat( _Destination, _Source );
+ }
+ else
+ {
+ assert( 0 );
+ }
+
+ return;
+}
+
+
+#ifdef DEBUG_AGC
+void ivas_close_agc_debug_files( void )
+{
+ if ( agcOut != NULL )
+ {
+ fclose( agcOut );
+ agcOut = NULL;
+ }
+
+ return;
+}
+
+void ivas_open_agc_debug_files( int16_t agc )
+{
+ /* Temporary AGC file */
+ if ( agc > 0 )
+ {
+ char agcFilename[50] = "agcBitstream.bin";
+ if ( ( agcOut = fopen( agcFilename, "wb" ) ) == NULL )
+ {
+ fprintf( stderr, "Error: Gain Control bitstream file %s could not be opened\n\n", agcFilename );
+ exit( -1 );
+ }
+ fprintf( stdout, "Temporary gain control bitstream file %s is opened\n", agcFilename );
+ }
+
+ return;
+}
+#endif
+
+static void UpdateWave(
+ const uint32_t sampleRate,
+ const uint32_t numChannels,
+ const uint32_t bps,
+ WAVEFILEOUT *spar_wav )
+{
+ uint32_t blockAlignment = 0;
+ uint16_t writeValue16;
+ uint32_t writeValue32;
+
+ writeValue16 = LittleEndian16( (int16_t) numChannels );
+ /*Fseek to number of channel writing position*/
+ fseek( spar_wav->theFile, 22, SEEK_SET );
+ fwrite( &writeValue16, sizeof( writeValue16 ), 1, spar_wav->theFile );
+ blockAlignment = numChannels * ( bps >> 3 );
+ writeValue16 = LittleEndian16( (int16_t) blockAlignment );
+ fseek( spar_wav->theFile, 4, SEEK_CUR );
+ writeValue32 = LittleEndian32( sampleRate * blockAlignment );
+ fwrite( &writeValue32, sizeof( writeValue32 ), 1, spar_wav->theFile );
+ fwrite( &writeValue16, sizeof( writeValue16 ), 1, spar_wav->theFile );
+
+ return;
+}
+
+
+void ivas_spar_dump_signal_wav(
+ const int16_t input_frame,
+ float **ppPcm,
+ float pcm_array[IVAS_SPAR_MAX_CH][L_FRAME48k],
+ const int16_t no_channel,
+ WAVEFILEOUT *wave_file,
+ char *location )
+{
+ float tmp_value;
+ int16_t pcm_value, i, j, k;
+ int16_t debug_tmp[IVAS_SPAR_MAX_CH * L_FRAME48k * 2];
+
+ k = 0;
+ int16_t Clipping = 0;
+ float largest_value = 0;
+ float db_value = 0;
+
+ for ( j = 0; j < input_frame; j++ )
+ {
+ for ( i = 0; i < no_channel; i++, k++ )
+ {
+ if ( ppPcm )
+ {
+ tmp_value = roundf( ppPcm[i][j] );
+ }
+ else
+ {
+ tmp_value = roundf( pcm_array[i][j] );
+ }
+
+ if ( tmp_value > MAX16B_FLT )
+ {
+ largest_value = (float) fabs( tmp_value ) > largest_value ? (float) fabs( tmp_value ) : largest_value;
+ tmp_value = MAX16B;
+ Clipping++;
+ }
+ else if ( tmp_value < MIN16B_FLT )
+ {
+ largest_value = (float) fabs( tmp_value ) > largest_value ? (float) fabs( tmp_value ) : largest_value;
+ tmp_value = MIN16B;
+ Clipping++;
+ }
+ pcm_value = (int16_t) tmp_value;
+ /*pcm_value = (tmp_value > MAX16B_FLT) ? MAX16B : (tmp_value < MIN16B_FLT) ? MIN16B
+ : (short)tmp_value;*/
+ debug_tmp[k] = pcm_value;
+ }
+ }
+ if ( Clipping )
+ {
+ db_value = 20.f * (float) log( largest_value );
+ fprintf( stderr, "%d\t Clipping detected ", Clipping );
+ }
+
+ WriteWavShort( wave_file, debug_tmp, ( no_channel * input_frame ) );
+
+ if ( db_value )
+ {
+ fprintf( stderr, "\t In %s largest clipped sample in dB %f \n", location, db_value );
+ }
+
+ return;
+}
+
+
+void ivas_close_sba_decoder_debug_files(
+ const int32_t fs,
+ const int16_t n_ch,
+ const int16_t n_transport,
+ const int16_t pca_ingest_channels )
+{
+ if ( spar_foa_dec_wav[0] != NULL )
+ {
+ UpdateWave( fs, n_transport, 32, spar_foa_dec_wav[0] );
+ CloseWav( spar_foa_dec_wav[0] );
+ }
+ if ( spar_foa_dec_wav[1] != NULL )
+ {
+ UpdateWave( fs, n_transport, 16, spar_foa_dec_wav[1] );
+ CloseWav( spar_foa_dec_wav[1] );
+ }
+ if ( spar_foa_dec_wav[2] != NULL )
+ {
+ UpdateWave( fs, pca_ingest_channels, 16, spar_foa_dec_wav[2] );
+ CloseWav( spar_foa_dec_wav[2] );
+ }
+ if ( spar_foa_dec_wav[3] != NULL )
+ {
+ UpdateWave( fs, n_ch, 16, spar_foa_dec_wav[3] );
+ CloseWav( spar_foa_dec_wav[3] );
+ }
+
+ if ( spar_foa_dec_wav[4] != NULL )
+ {
+ UpdateWave( fs, n_ch, 16, spar_foa_dec_wav[4] );
+ CloseWav( spar_foa_dec_wav[4] );
+ }
+
+ return;
+}
+
+
+void ivas_close_sba_encoder_debug_files( void )
+{
+
+ if ( spar_foa_enc_wav[0] != NULL )
+ {
+ CloseWav( spar_foa_enc_wav[0] );
+ }
+ if ( spar_foa_enc_wav[1] != NULL )
+ {
+ CloseWav( spar_foa_enc_wav[1] );
+ }
+ if ( spar_foa_enc_wav[2] != NULL )
+ {
+ CloseWav( spar_foa_enc_wav[2] );
+ }
+
+ /* Enable print max diff to a file */
+
+ /* FILE *fp = fopen("max_diff.txt", "a");
+ fprintf(fp, "%s\n", file_names[0]);
+ fprintf(fp, "max diff = %0.15f\n frame_no = %d\n band num = %d\n coeff type %d\n", max_diff, dbg_frm_num, dbg_band, dbg_type);
+ fclose(fp); */
+
+ /* Enable print max eig iters to a file */
+
+ /*FILE *fp = fopen("max_iters.txt", "a");
+ fprintf(fp, "%s\n", file_names[0]);
+ fprintf(fp, "%d\n", iter_max);
+ fclose(fp); */
+
+ return;
+}
+
+
+void ivas_open_sba_decoder_debug_files(
+ const int32_t fs,
+ const int16_t n_ch,
+ const int16_t n_transport )
+{
+ int8_t fb_wav_dump_path[NUM_DEBUG_FILES][MAX_PLUG_IN_FILE_LEN] = { "", "", "", "", "" };
+
+ cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), "dec_out.wav" );
+ spar_foa_dec_wav[0] = CreateWav( (const char *) fb_wav_dump_path[0], fs, n_ch, 32 /* const uint32_t writeWaveExt */ );
+
+ cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), "agc_dec_out.wav" );
+ spar_foa_dec_wav[1] = CreateWav( (const char *) fb_wav_dump_path[1], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), "pca_dec.wav" );
+ spar_foa_dec_wav[2] = CreateWav( (const char *) fb_wav_dump_path[2], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ cstrcat( (char *) fb_wav_dump_path[3], sizeof( fb_wav_dump_path[3] ), "cldfbSynthesis.wav" );
+ spar_foa_dec_wav[3] = CreateWav( (const char *) fb_wav_dump_path[3], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ cstrcat( (char *) fb_wav_dump_path[4], sizeof( fb_wav_dump_path[4] ), "cldfbAnalysis.wav" );
+ spar_foa_dec_wav[4] = CreateWav( (const char *) fb_wav_dump_path[4], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ return;
+}
+
+
+void ivas_open_sba_encoder_debug_files(
+ const int32_t fs,
+ const int16_t n_transport,
+ const char *file_tag,
+ const int32_t ivas_total_brate,
+ const int16_t dtx_on )
+{
+ int8_t fb_wav_dump_path[3][MAX_PLUG_IN_FILE_LEN] = { "spar_foa_enc", "spar_foa_enc", "spar_foa_enc" };
+
+ if ( file_tag != NULL )
+ {
+ cstrcpy( (char *) file_names[0], sizeof( file_names[0] ), (const char *) file_tag );
+ }
+
+ /* ivas_total_brate */
+ switch ( ivas_total_brate )
+ {
+ case IVAS_24k4:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr24k" );
+ break;
+ case IVAS_32k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr32k" );
+ break;
+ case IVAS_48k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr48k" );
+ break;
+ case IVAS_64k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr64k" );
+ break;
+ case IVAS_80k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr80k" );
+ break;
+ case IVAS_96k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr96k" );
+ break;
+ case IVAS_128k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr128k" );
+ break;
+ case IVAS_160k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr160k" );
+ break;
+ case IVAS_192k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr192k" );
+ break;
+ case IVAS_256k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr256k" );
+ break;
+ case IVAS_384k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr384k" );
+ break;
+ case IVAS_512k:
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr512k" );
+ break;
+ }
+
+ /* DTX */
+ if ( dtx_on )
+ {
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_DTX1" );
+ }
+ else
+ {
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_DTX0" );
+ }
+
+ cstrcpy( (char *) file_names[1], sizeof( file_names[1] ), (const char *) file_names[0] );
+ cstrcpy( (char *) file_names[2], sizeof( file_names[2] ), (const char *) file_names[0] );
+ cstrcpy( (char *) file_names[3], sizeof( file_names[3] ), (const char *) file_names[0] );
+ cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_pcm.txt" );
+
+ cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), (const char *) file_names[2] );
+ cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), "_pca_enc.wav" );
+ spar_foa_enc_wav[0] = CreateWav( (const char *) fb_wav_dump_path[0], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), (const char *) file_names[2] );
+ cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), "_fb_mixer_enc.wav" );
+ spar_foa_enc_wav[1] = CreateWav( (const char *) fb_wav_dump_path[1], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), (const char *) file_names[2] );
+ cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), "_agc_enc.wav" );
+ spar_foa_enc_wav[2] = CreateWav( (const char *) fb_wav_dump_path[2], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
+
+ return;
+}
+
+#endif /* DEBUG_SBA */
diff --git a/lib_debug/sba_debug.h b/lib_debug/sba_debug.h
new file mode 100644
index 0000000000000000000000000000000000000000..a314d1568cc2df74be82d26610a30b00e78b6866
--- /dev/null
+++ b/lib_debug/sba_debug.h
@@ -0,0 +1,61 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#ifndef SBA_DEBUG_H
+#define SBA_DEBUG_H
+
+#include "options.h"
+#include
+#include
+#ifdef DEBUG_SBA
+#include "cnst.h"
+#include "ivas_cnst.h"
+#include "tinywaveout_c.h"
+
+
+#ifdef DEBUG_SBA_AUDIO_DUMP
+extern WAVEFILEOUT *spar_foa_enc_wav[3];
+extern WAVEFILEOUT *spar_foa_dec_wav[5];
+#endif
+
+#ifdef DEBUG_AGC
+void ivas_close_agc_debug_files( void );
+void ivas_open_agc_debug_files( int16_t agc );
+#endif
+void ivas_spar_dump_signal_wav( const int16_t input_frame, float **ppPcm, float pcm_array[IVAS_SPAR_MAX_CH][L_FRAME48k], const int16_t no_channel, WAVEFILEOUT *wave_file, char *location );
+void ivas_close_sba_encoder_debug_files( void );
+void ivas_open_sba_encoder_debug_files( const int32_t fs, const int16_t n_transport, const char *file_tag, const int32_t ivas_total_brate, const int16_t dtx_on );
+void ivas_close_sba_decoder_debug_files( const int32_t fs, const int16_t n_ch, const int16_t n_transport, const int16_t pca_ingest_channels );
+void ivas_open_sba_decoder_debug_files( const int32_t fs, const int16_t n_ch, const int16_t n_transport );
+#endif
+
+#endif /* SBA_DEBUG_H */
diff --git a/lib_debug/snr.c b/lib_debug/snr.c
new file mode 100644
index 0000000000000000000000000000000000000000..3e817287c744ee5f32d41744bd1300e0885c204c
--- /dev/null
+++ b/lib_debug/snr.c
@@ -0,0 +1,465 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+#include
+#include
+#include
+#include "wmc_auto.h"
+#include "cnst.h"
+#include "ivas_cnst.h"
+
+#ifdef DEBUGGING
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *--------------------------------------------------------------------*/
+
+#define N_SNRPTR 100
+#define MAX_SIGNAL_LENGTH 1024
+#define MAX_DELAY 320
+
+/*-------------------------------------------------------------------*
+ * Global variables
+ *--------------------------------------------------------------------*/
+
+int16_t snr_count = 0;
+char *snr_name[N_SNRPTR] = { 0 };
+
+#ifdef DEBUG_MODE_INFO
+float snr_[2][320];
+#endif
+
+/*-------------------------------------------------------------------*
+ * Local variables
+ *--------------------------------------------------------------------*/
+
+static double signal_energy[N_SNRPTR];
+static double noise_energy[N_SNRPTR];
+static double acc_seg_snr[N_SNRPTR];
+static int32_t seg_count[N_SNRPTR];
+static double acc_wseg_snr[N_SNRPTR];
+static double wseg_count[N_SNRPTR];
+static float *mem_delay_comp[N_SNRPTR] = { 0 };
+static float mem_deemph_x[MAX_INPUT_CHANNELS] = { 0 };
+static float mem_deemph_y[MAX_INPUT_CHANNELS] = { 0 };
+static float mem_synth_snr[MAX_INPUT_CHANNELS][M];
+
+
+/*-------------------------------------------------------------------*
+ * Local functions - they are copies of functions declared in prot.h but
+ here we do not want to include prot.h due to its dependencies
+ *--------------------------------------------------------------------*/
+
+#ifdef DEBUG_MODE_INFO
+static void set_f(
+ float y[], /* i/o: Vector to set */
+ const float a, /* i : Value to set the vector to */
+ const int16_t N /* i : Lenght of the vector */
+)
+{
+ int16_t i;
+
+ for ( i = 0; i < N; i++ )
+ {
+ y[i] = a;
+ }
+
+ return;
+}
+#endif
+
+static float sum2_f(
+ const float *vec, /* i : input vector */
+ const int16_t lvec /* i : length of input vector */
+)
+{
+ int16_t i;
+ float tmp;
+
+ tmp = 0.0f;
+ for ( i = 0; i < lvec; i++ )
+ {
+ tmp += vec[i] * vec[i];
+ }
+
+ return tmp;
+}
+
+
+static void mvr2r(
+ const float x[], /* i : input vector */
+ float y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+)
+{
+ int16_t i;
+
+ if ( n <= 0 )
+ {
+ /* cannot transfer vectors with size 0 */
+ return;
+ }
+
+ if ( y < x )
+ {
+ for ( i = 0; i < n; i++ )
+ {
+ y[i] = x[i];
+ }
+ }
+ else
+ {
+ for ( i = n - 1; i >= 0; i-- )
+ {
+ y[i] = x[i];
+ }
+ }
+
+ return;
+}
+
+static void residu(
+ const float *a, /* i : LP filter coefficients */
+ const int16_t m, /* i : order of LP filter */
+ const float *x, /* i : input signal (usually speech) */
+ float *y, /* o : output signal (usually residual) */
+ const int16_t l /* i : size of filtering */
+)
+{
+ float s;
+ int16_t i, j;
+
+ for ( i = 0; i < l; i++ )
+ {
+ s = x[i];
+ for ( j = 1; j <= m; j++ )
+ {
+ s += a[j] * x[i - j];
+ }
+ y[i] = s;
+ }
+
+ return;
+}
+
+static void deemph(
+ float *signal, /* i/o: signal */
+ const float mu, /* i : deemphasis factor */
+ const int16_t L, /* i : vector size */
+ float *mem /* i/o: memory (y[-1]) */
+)
+{
+ int16_t i;
+
+ signal[0] = signal[0] + mu * ( *mem );
+ for ( i = 1; i < L; i++ )
+ {
+ signal[i] = signal[i] + mu * signal[i - 1];
+ }
+
+ *mem = signal[L - 1];
+
+ if ( ( *mem < 1e-10 ) & ( *mem > -1e-10 ) )
+ {
+ *mem = 0;
+ }
+
+ return;
+}
+
+static void weight_a(
+ const float *a, /* i : LP filter coefficients */
+ float *ap, /* o : weighted LP filter coefficients */
+ const float gamma, /* i : weighting factor */
+ const int16_t m /* i : order of LP filter */
+)
+{
+ float f;
+ int16_t i;
+
+ ap[0] = a[0];
+ f = gamma;
+
+ for ( i = 1; i <= m; i++ )
+ {
+ ap[i] = f * a[i];
+ f *= gamma;
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * snr()
+ *
+ * Calculates and accumulates SNR values for a signal specified with a
+ * certain string. The signal is input in segments having certain length,
+ * for which a global SNR, segmental SNR and weighted segmental SNR is computed.
+ *--------------------------------------------------------------------*/
+
+void snr(
+ const float *const signal,
+ const float *const noise,
+ const int16_t length,
+ const char *const name )
+{
+ int16_t index;
+ double signal_sumsq, noise_sumsq, frame_snr, seg_en;
+
+ index = lookup( name, (const char *const *) snr_name, snr_count );
+ if ( index == -1 )
+ {
+ index = snr_count;
+ signal_energy[index] = 0;
+ noise_energy[index] = 0;
+ acc_seg_snr[index] = 0;
+ seg_count[index] = 0;
+ acc_wseg_snr[index] = 0;
+ wseg_count[index] = 0;
+ snr_name[index] = malloc( sizeof( char ) * ( strlen( name ) + 1 ) );
+ strcpy( snr_name[index], name );
+ snr_count++;
+ }
+
+ signal_sumsq = sum2_f( signal, length ) + 0.001f;
+ noise_sumsq = sum2_f( noise, length ) + 0.001f;
+ if ( signal_sumsq < noise_sumsq )
+ signal_sumsq = noise_sumsq;
+ frame_snr = 10 * log10( signal_sumsq / noise_sumsq );
+ seg_en = 10 * log10( signal_sumsq / length );
+ if ( seg_en < 0.0 )
+ seg_en = 0.0;
+
+ signal_energy[index] += signal_sumsq;
+ noise_energy[index] += noise_sumsq;
+ acc_seg_snr[index] += frame_snr;
+ seg_count[index]++;
+ acc_wseg_snr[index] += frame_snr * seg_en;
+ wseg_count[index] += seg_en;
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * snr_diff()
+ *
+ * Calculates and accumulates SNR values for a signal specified with a
+ * certain string. The signal is input in segments having certain length,
+ * for which a global SNR, segmental SNR and weighted segmental SNR is computed.
+ * A delay between both signals is taken into account
+ * and compensated for (positive value means degraded signal is delayed).
+ *--------------------------------------------------------------------*/
+
+void snr_diff(
+ const float *const clean,
+ const float *const degraded,
+ const int16_t length,
+ const int16_t delay,
+ const char *const name )
+{
+ int16_t i, index;
+ float noise[MAX_SIGNAL_LENGTH], comp_buf[MAX_SIGNAL_LENGTH + MAX_DELAY];
+
+ if ( length > MAX_SIGNAL_LENGTH )
+ {
+ fprintf( stdout, "snr_diff::Input segment too long. Exiting...\n" );
+ exit( -1 );
+ }
+
+ if ( delay < 0 )
+ {
+ fprintf( stdout, "snr_diff::Degraded signal cannot have negative delay. Exiting...\n" );
+ exit( -1 );
+ }
+
+ /* search for the name in the database */
+ index = (int16_t) lookup( name, (const char *const *) snr_name, snr_count );
+ if ( index == -1 )
+ {
+ index = (int16_t) snr_count;
+ signal_energy[index] = 0.0f;
+ noise_energy[index] = 0.0f;
+ acc_seg_snr[index] = 0.0f;
+ seg_count[index] = 0;
+ acc_wseg_snr[index] = 0.001f;
+ wseg_count[index] = 0.001f;
+ snr_name[index] = malloc( sizeof( char ) * ( strlen( name ) + 1 ) );
+ mem_delay_comp[index] = calloc( delay, sizeof( float ) );
+ strcpy( snr_name[index], name );
+ snr_count++;
+ }
+
+ /* delay compensation - introduction of delay to the clean signal */
+ mvr2r( mem_delay_comp[index], comp_buf, delay );
+ mvr2r( clean, comp_buf + delay, length );
+ mvr2r( comp_buf + length, mem_delay_comp[index], delay );
+
+ for ( i = 0; i < length; i++ )
+ {
+ noise[i] = comp_buf[i] - degraded[i];
+ }
+
+ snr( comp_buf, noise, length, name );
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * snr_celp()
+ *
+ * Calculates SNR, segmental SNR and weighted segmental SNR values for active
+ * frames (GENERIC, VOICED, TRANSITION and AUDIO) of CELP-coded signals. Both, the input and output
+ * signals are first converted to the perceptually weighted domain, subtracted to
+ * obtain the noise signal and de-emphasized.
+ *--------------------------------------------------------------------*/
+
+void snr_celp(
+ const int16_t L_frame,
+ const int16_t L_subfr,
+ const float gamma,
+ const float tilt_fac,
+ const int16_t vad_flag,
+ const int16_t coder_type,
+ const float *input,
+ const float *output,
+ const float *A,
+ const int16_t idchan,
+ const char *name )
+{
+ int16_t i;
+ float noise[L_FRAME16k], Ap[M + 1], x[L_FRAME16k], y[L_FRAME16k], synth_buf[M + L_FRAME16k], *synth;
+ const float *p_A;
+ int16_t j;
+#ifdef DEBUG_MODE_INFO
+ float signal2, noise2, subframe_snr;
+#endif
+
+ synth = synth_buf + M;
+ mvr2r( mem_synth_snr[idchan], synth_buf, M );
+ mvr2r( output, synth, L_frame );
+ mvr2r( synth_buf + L_frame, mem_synth_snr[idchan], M );
+
+ p_A = A;
+ for ( i = 0; i < L_frame; i += L_subfr )
+ {
+ weight_a( p_A, Ap, gamma, M );
+ residu( Ap, M, &input[i], &x[i], L_subfr );
+ residu( Ap, M, &synth[i], &y[i], L_subfr );
+ p_A += ( M + 1 );
+
+ deemph( &x[i], tilt_fac, L_subfr, &mem_deemph_x[idchan] );
+ deemph( &y[i], tilt_fac, L_subfr, &mem_deemph_y[idchan] );
+
+ for ( j = 0; j < L_subfr; j++ )
+ {
+ noise[i + j] = x[i + j] - y[i + j];
+ }
+
+#ifdef DEBUG_MODE_INFO
+ signal2 = sum2_f( &x[i], L_subfr ) + 0.001f;
+ noise2 = sum2_f( &noise[i], L_subfr ) + 0.001f;
+ if ( signal2 < noise2 )
+ signal2 = noise2;
+ subframe_snr = 10.0f * log10f( signal2 / noise2 );
+
+ if ( L_frame == L_FRAME )
+ {
+ set_f( snr_[idchan] + i * 5 / 4, subframe_snr, L_subfr * 5 / 4 );
+ }
+ else
+ {
+ set_f( snr_[idchan] + i, subframe_snr, L_subfr );
+ }
+#endif
+ }
+
+ if ( vad_flag == 1 && ( coder_type == GENERIC || coder_type == VOICED || coder_type == TRANSITION || coder_type == AUDIO ) )
+ {
+ snr( x, noise, L_frame, name );
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * print_snr()
+ *
+ * Finalizes and presents accumulated SNR data
+ *--------------------------------------------------------------------*/
+
+void print_snr( void )
+{
+ int16_t i;
+ double snr, segsnr, wsegsnr;
+
+ if ( snr_count > 0 )
+ {
+ fprintf( stdout, "\n --- SNR report --- \n" );
+
+ for ( i = 0; i < snr_count; i++ )
+ {
+ snr = 10 * log10( signal_energy[i] / ( noise_energy[i] + 0.0001f ) );
+ segsnr = acc_seg_snr[i] / ( seg_count[i] + 0.0001f );
+ wsegsnr = acc_wseg_snr[i] / ( wseg_count[i] + 0.0001f );
+ fprintf( stdout, "%-22s %6.3f dB SNR %6.3f dB SegSNR %6.3f dB WSegSNR\n", snr_name[i], snr, segsnr, wsegsnr );
+ }
+ fprintf( stdout, "\n" );
+ }
+
+ /* free allocated memory */
+ for ( i = 0; i < N_SNRPTR; i++ )
+ {
+ if ( snr_name[i] )
+ {
+ free( snr_name[i] );
+ snr_name[i] = NULL;
+ }
+
+ if ( mem_delay_comp[i] )
+ {
+ free( mem_delay_comp[i] );
+ mem_delay_comp[i] = NULL;
+ }
+ }
+
+ return;
+}
+
+#endif
diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c
index 0ff7786f05f57e7493782fad180053f1b2467091..1ab20a2ee8da89fbe648a039aea4a0bce45af550 100644
--- a/lib_debug/wmc_auto.c
+++ b/lib_debug/wmc_auto.c
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include
#ifndef _MSC_VER
@@ -36,12 +37,14 @@
* Complexity counting tool
*--------------------------------------------------------------------*/
-#define MAX_FUNCTION_NAME_LENGTH 50 /* Maximum length of the function name */
-#define MAX_PARAMS_LENGTH 50 /* Maximum length of the function parameter string */
-#define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> mightb be increased during runtime, if needed */
+#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */
+#define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */
+#define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> might be increased during runtime, if needed */
#define MAX_NUM_RECORDS_REALLOC_STEP 50 /* When re-allocating the list of records, increase the number of records by this number */
#define MAX_CALL_TREE_DEPTH 100 /* maximum depth of the function call tree */
#define DOUBLE_MAX 0x80000000
+#define FAC ( FRAMES_PER_SECOND / 1e6 )
+
typedef struct
{
@@ -123,7 +126,7 @@ void reset_wmops( void )
exit( -1 );
}
- /* initilize the list of wmops records */
+ /* initilize the list of WMOPS records */
/* initilize the BASOP WMOPS counters */
for ( i = 0; i < max_num_wmops_records; i++ )
{
@@ -186,35 +189,84 @@ void reset_wmops( void )
return;
}
-
-void push_wmops( const char *label )
+void push_wmops_fct( const char *label, ... )
{
int new_flag;
- int i, j;
+ int i, j, index_record;
+ unsigned int *ptr;
+ va_list arg;
+ char func_name[MAX_FUNCTION_NAME_LENGTH] = "";
+
+ /* concatenate all function name labels into a single string */
+ va_start( arg, label );
+ while ( label )
+ {
+ strcat( func_name, label );
+ label = va_arg( arg, const char * );
+ }
+ va_end( arg );
/* Check, if this is a new function label */
new_flag = 1;
for ( i = 0; i < num_wmops_records; i++ )
{
- if ( strcmp( wmops[i].label, label ) == 0 )
+ if ( strcmp( wmops[i].label, func_name ) == 0 )
{
new_flag = 0;
break;
}
}
+ index_record = i;
/* Create a new record in the list */
if ( new_flag )
{
if ( num_wmops_records >= max_num_wmops_records )
{
- /* There is no room for a new wmops record -> reallocate the list */
+ /* There is no room for a new WMOPS record -> reallocate the list */
max_num_wmops_records += MAX_NUM_RECORDS_REALLOC_STEP;
wmops = realloc( wmops, max_num_wmops_records * sizeof( wmops_record ) );
multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) );
+
+ /* initilize newly created WMOPS records */
+ for ( i = num_wmops_records; i < max_num_wmops_records; i++ )
+ {
+ strcpy( &wmops[i].label[0], "\0" );
+ wmops[i].call_number = 0;
+ wmops[i].update_cnt = 0;
+ for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ )
+ {
+ wmops[i].call_tree[j] = -1;
+ }
+ wmops[i].start_selfcnt = 0.0;
+ wmops[i].current_selfcnt = 0.0;
+ wmops[i].max_selfcnt = 0.0;
+ wmops[i].min_selfcnt = DOUBLE_MAX;
+ wmops[i].tot_selfcnt = 0.0;
+ wmops[i].start_cnt = 0.0;
+ wmops[i].current_cnt = 0.0;
+ wmops[i].max_cnt = 0.0;
+ wmops[i].min_cnt = DOUBLE_MAX;
+ wmops[i].tot_cnt = 0.0;
+#ifdef WMOPS_WC_FRAME_ANALYSIS
+ wmops[i].wc_cnt = 0.0;
+ wmops[i].wc_selfcnt = 0.0;
+ wmops[i].current_call_number = 0;
+ wmops[i].wc_call_number = -1;
+#endif
+
+ /* initialize BASOP WMOPS counters */
+ ptr = (unsigned int *) &multiCounter[i];
+ for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ )
+ {
+ *ptr++ = 0;
+ }
+ wmops[i].LastWOper = 0;
+ }
+
}
- strcpy( wmops[i].label, label );
+ strcpy( wmops[index_record].label, func_name );
num_wmops_records++;
}
@@ -236,29 +288,29 @@ void push_wmops( const char *label )
/* update call tree */
for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ )
{
- if ( wmops[i].call_tree[j] == current_record )
+ if ( wmops[index_record].call_tree[j] == current_record )
{
break;
}
- else if ( wmops[i].call_tree[j] == -1 )
+ else if ( wmops[index_record].call_tree[j] == -1 )
{
- wmops[i].call_tree[j] = current_record;
+ wmops[index_record].call_tree[j] = current_record;
break;
}
}
}
/* update the current context info */
- current_record = i;
- wmops[current_record].start_selfcnt = ops_cnt;
- wmops[current_record].start_cnt = ops_cnt;
- wmops[current_record].call_number++;
+ current_record = index_record;
+ wmops[index_record].start_selfcnt = ops_cnt;
+ wmops[index_record].start_cnt = ops_cnt;
+ wmops[index_record].call_number++;
#ifdef WMOPS_WC_FRAME_ANALYSIS
- wmops[current_record].current_call_number++;
+ wmops[index_record].current_call_number++;
#endif
/* set the ID of BASOP functions counters */
- Set_BASOP_WMOPS_counter( current_record );
+ Set_BASOP_WMOPS_counter( index_record );
return;
}
@@ -1095,7 +1147,7 @@ void *mem_alloc(
#ifdef MEM_COUNT_DETAILS
/* Export heap memory allocation record to the .csv file */
- fprintf( fid_csv_filename, "A,%d,%s,%d,%d\n", update_cnt, ptr_record->name, ptr_record->lineno, ptr_record->block_size );
+ fprintf( fid_csv_filename, "A,%ld,%s,%d,%d\n", update_cnt, ptr_record->name, ptr_record->lineno, ptr_record->block_size );
#endif
if ( ptr_record->frame_allocated != -1 )
@@ -1393,8 +1445,8 @@ allocator_record *get_mem_record( unsigned long *hash, const char *func_name, in
/*-------------------------------------------------------------------*
* mem_free()
*
- * This function de-allocatesd the memory block and frees the mphysical memory with free().
- * It also updates actual and average usage of the memory block.
+ * This function de-allocates memory blocks and frees physical memory with free().
+ * It also updates the actual and average usage of memory blocks.
*
* Note: The record is not removed from the list and may be reused later on in mem_alloc()!
*--------------------------------------------------------------------*/
@@ -1435,7 +1487,7 @@ void mem_free( const char *func_name, int func_lineno, void *ptr )
#ifdef MEM_COUNT_DETAILS
/* Export heap memory de-allocation record to the .csv file */
- fprintf( fid_csv_filename, "D,%d,%s,%d,%d\n", update_cnt, ptr_record->name, ptr_record->lineno, ptr_record->block_size );
+ fprintf( fid_csv_filename, "D,%ld,%s,%d,%d\n", update_cnt, ptr_record->name, ptr_record->lineno, ptr_record->block_size );
#endif
/* De-Allocate Memory Block */
@@ -1695,7 +1747,7 @@ static void mem_count_summary( void )
allocator_record *ptr_record, *ptr;
/* Prepare format string */
- sprintf( format_str, "%%-%ds %%5s %%6s %%-%ds %%20s %%6s ", MAX_FUNCTION_NAME_LENGTH, MAX_PARAMS_LENGTH );
+ sprintf( format_str, "%%-%d.%ds %%5.5s %%6.6s %%-%d.%ds %%20.20s %%6.6s ", 50, 50, 50, 50 );
if ( n_items_wc_intra_frame_heap > 0 )
{
@@ -1903,8 +1955,8 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] )
}
else
{
- /* bytes */
- fprintf( stdout, "Program ROM size (%s): %d bytes\n", Const_Data_PROM_Table[i].file_spec, Const_Data_PROM_Table[i].PROM_size << Stat_Cnt_Size );
+ /* bytes (here, we assume that each instruction takes PROM_INST_SIZE bits of the PROM memory) */
+ fprintf( stdout, "Program ROM size (%s): %d bytes\n", Const_Data_PROM_Table[i].file_spec, Const_Data_PROM_Table[i].PROM_size * ( PROM_INST_SIZE / 8 ) );
}
}
@@ -1994,10 +2046,15 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] )
mem_count_summary();
#endif
- if ( Stat_Cnt_Size == 0 )
+ if ( Stat_Cnt_Size > 0 )
+ {
+ /* words */
+ fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bits\n", 8 << Stat_Cnt_Size );
+ }
+ else
{
/* bytes */
- fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bytes (%d bits)\n", 1 << Stat_Cnt_Size, 8 << Stat_Cnt_Size );
+ fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bits\n", PROM_INST_SIZE );
}
fprintf( stdout, "Note: The Data ROM size is calculated using the sizeof(type) built-in function\n" );
diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h
index e2f2af4d8ffcf6436543de5ec3770c459ae26d8e..42110465e0cf675cf631dddb44010074631f85b2 100644
--- a/lib_debug/wmc_auto.h
+++ b/lib_debug/wmc_auto.h
@@ -33,10 +33,8 @@
#define INT_MAX 32767
#endif
-/* Real-time relationships */
#define FRAMES_PER_SECOND 50.0
-#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */
-#define FAC ( FRAMES_PER_SECOND / 1e6 * WMOPS_BOOST_FAC )
+#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */
#ifdef WMOPS
enum instructions
@@ -565,7 +563,8 @@ extern double prom_cnt;
extern double inst_cnt[NUM_INST];
void reset_wmops( void );
-void push_wmops( const char *label );
+#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL )
+void push_wmops_fct( const char *label, ... );
void pop_wmops( void );
void update_wmops( void );
void update_mem( void );
@@ -615,14 +614,6 @@ extern int cntr_push_pop;
#endif
-/* mac & msu (Non Instrumented Versions) */
-#ifndef mac
-#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) )
-#endif
-#ifndef mac
-#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) )
-#endif
-
#ifndef WMOPS
/* DESACTIVATE the Counting Mechanism */
#define OP_COUNT_( op, n )
@@ -670,84 +661,99 @@ static int wmc_flag_ = 0;
#endif
/* Define all Macros without '{' & '}' (None of these should be called externally!) */
-#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC )
-#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC )
-#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC )
-#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC )
-#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC )
-#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC )
-#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC )
-#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC )
-#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC )
-#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC )
-#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC )
-#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC )
+#define ABS_( x ) OP_COUNT_( _ABS, ( x ) )
+#define ADD_( x ) OP_COUNT_( _ADD, ( x ) )
+#define MULT_( x ) OP_COUNT_( _MULT, ( x ) )
+#define MAC_( x ) OP_COUNT_( _MAC, ( x ) )
+#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) )
+#define STORE_( x ) OP_COUNT_( _STORE, ( x ) )
+#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) )
+#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) )
+#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) )
+#define DIV_( x ) OP_COUNT_( _DIV, ( x ) )
+#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) )
+#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) )
#define POWER_( x ) TRANS_( x )
#define LOG_( x ) TRANS_( x )
-#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC )
-#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC )
-#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC )
-#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) )
+#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) )
+#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) )
+#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) )
+#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) )
#define MISC_( x ) ABS_( x )
/* Math Operations */
-#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs )
-#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs )
-#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs )
-#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor )
-#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt )
-#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow )
-#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp )
-#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log )
-#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 )
-#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos )
-#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin )
-#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan )
-#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos )
-#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin )
-#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan )
-#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 )
-#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh )
-#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh )
-#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh )
-#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod )
-/* these macros use any local macros already defined */
-/* min/max and their Variants */
-#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) )
-#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) )
-#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) )
-#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) )
-#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) )
-#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) )
-/* Square and its Variants */
-#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) )
-#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) )
-#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) )
-#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) )
-#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) )
-#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) )
-/* Sign and its Variants */
-#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) )
-#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) )
-#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) )
-/* Square Root and its Variants */
-#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) )
-/* Invert Square Root and its Variants */
-#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) )
-/* Others */
+#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs )
+#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs )
+#define fabsf_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabsf )
+#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs )
+#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor )
+#define floorf_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floorf )
+#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt )
+#define sqrtf_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf )
+#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow )
+#define powf_ OP_COUNT_WRAPPER1_( POWER_( 1 ), powf )
+#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp )
+#define expf_ OP_COUNT_WRAPPER1_( POWER_( 1 ), expf )
+#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log )
+#define logf_ OP_COUNT_WRAPPER1_( LOG_( 1 ), logf )
+#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 )
+#define log10f_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10f )
+#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos )
+#define cosf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosf )
+#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin )
+#define sinf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinf )
+#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan )
+#define tanf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanf )
+#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos )
+#define acosf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acosf )
+#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin )
+#define asinf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asinf )
+#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan )
+#define atanf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atanf )
+#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 )
+#define atan2f_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2f )
+#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh )
+#define coshf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), coshf )
+#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh )
+#define sinhf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinhf )
+#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh )
+#define tanhf_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanhf )
+#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod )
+#define fmodf_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmodf )
+#define frexp_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexp )
+#define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf )
+
+/* the macros below are instrumented versions of user-defined macros that might be used in the source code
+/* representing some well-known and recognized mathematical operations (that are not defined in math.h) */
+/* Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */
+
+#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) )
+#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) )
+#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) )
+#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) )
+#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) )
+#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) )
+#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) )
+#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) )
+#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) )
+#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) )
+#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) )
+#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) )
+#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) )
+#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) )
+#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) )
+#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) )
+#define inv_sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrtf( ( x ) ) )
#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) )
+#define log2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2( ( x ) ) )
+#define log2f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2f( ( x ) ) )
#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) )
-/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect"
- with Cygwin gcc Compiler */
-#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) )
-#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) )
-#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) )
-/* Set Min/Max */
+#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) )
+#define round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round( ( x ) ) )
+#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) )
+#define roundf_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, roundf( ( x ) ) )
#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) )
#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) )
-/* mac & msu (Instrumented Versions) */
-#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) )
-#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) )
/* Functions */
#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name )
@@ -1014,11 +1020,11 @@ int push_stack( const char *filename, const char *fctname );
int pop_stack( const char *filename, const char *fctname );
#ifdef WMOPS_DETAIL
-#define STACK_DEPTH_FCT_CALL ( push_wmops( __FUNCTION__ " [WMC_AUTO]" ), push_stack( __FILE__, __FUNCTION__ ) ) /* add push_wmops() in all function calls */
-#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __FUNCTION__ ) ) /* add pop_wmops() in all function returns */
+#define STACK_DEPTH_FCT_CALL ( push_wmops( __func__, "[WMC_AUTO]" ), push_stack( __FILE__, __func__ ) ) /* add push_wmops() in all function calls */
+#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __func__ ) ) /* add pop_wmops() in all function returns */
#else
#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __FUNCTION__ )
-#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __FUNCTION__ )
+#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __func__ )
#endif
void reset_stack( void );
diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c
index cabbef7c2609ad3d6e8bc4f9135b6c3b2a45a817..5139106d9fe8834d8fed53536ae2a244c34fd936 100644
--- a/lib_dec/ACcontextMapping_dec.c
+++ b/lib_dec/ACcontextMapping_dec.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
@@ -491,6 +494,9 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
st->next_bit_pos = start_bit_pos + bits_tups + rc_uni_dec_virtual_finish( &rc_st_dec );
/* Confirm that there is no overflow */
+#ifdef DEBUGGING
+ assert( st->next_bit_pos - start_bit_pos + rest_bits <= 0 );
+#endif
/* Store decoded data */
x[a1_i] = a;
@@ -538,6 +544,9 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
assert( rc_st_dec.bit_error_detected == 0 );
/* Cross-check: No overflow */
+#ifdef DEBUGGING
+ assert( k == lastnz );
+#endif
/* Decode signs */
n = nt;
@@ -625,6 +634,9 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
st->next_bit_pos = start_bit_pos + bits_tups + rc_uni_dec_virtual_finish( &rc_st_dec );
/* Confirm that there is no overflow */
+#ifdef DEBUGGING
+ assert( st->next_bit_pos - start_bit_pos + rest_bits <= 0 );
+#endif
/* Store decoded data */
x[k + 0] = a;
diff --git a/lib_dec/FEC.c b/lib_dec/FEC.c
index 31b05b390fca0010e2952dd51ce62be826b9d4b1..c0db9325f504d743f2416272dc16a8e2859f7552 100644
--- a/lib_dec/FEC.c
+++ b/lib_dec/FEC.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c
index edc1c2490b5a9288e6017b5246f143c040de1a4e..988689b76d63f5af2b859298ad8dacbc110441b5 100644
--- a/lib_dec/FEC_HQ_core.c
+++ b/lib_dec/FEC_HQ_core.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_dec.h"
diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c
index 49e3636087e0bbcc53fa4037473b2ad50591a1f2..28cafd4732873ca9a7a07ef576ad50954287bac7 100644
--- a/lib_dec/FEC_HQ_phase_ecu.c
+++ b/lib_dec/FEC_HQ_phase_ecu.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "rom_dec.h"
#include "rom_com.h"
diff --git a/lib_dec/FEC_adapt_codebook.c b/lib_dec/FEC_adapt_codebook.c
index 3ef001909bf712190533129cc68597f84c6e42e5..1200e2651cf52f30ff9fb82be8440dc076e960c5 100644
--- a/lib_dec/FEC_adapt_codebook.c
+++ b/lib_dec/FEC_adapt_codebook.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_dec.h"
diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c
index e514326be3abbe89de0209011db6386818f92a7c..d20760ddbfa2983b8037ed583657cc3f369b40d7 100644
--- a/lib_dec/FEC_clas_estim.c
+++ b/lib_dec/FEC_clas_estim.c
@@ -37,6 +37,9 @@
#include "cnst.h"
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "rom_com.h"
diff --git a/lib_dec/FEC_lsf_estim.c b/lib_dec/FEC_lsf_estim.c
index e8e16599149c57723c6432fa0149abad1639b566..dce8b8351583c298dcd5ed8f41b0807d7ac32f0c 100644
--- a/lib_dec/FEC_lsf_estim.c
+++ b/lib_dec/FEC_lsf_estim.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_dec/FEC_pitch_estim.c b/lib_dec/FEC_pitch_estim.c
index 738000a4d55c24ff0c85c5573fe103fe4872fb91..3076f7bcaaccd78c0e92566c68669bc56eed653e 100644
--- a/lib_dec/FEC_pitch_estim.c
+++ b/lib_dec/FEC_pitch_estim.c
@@ -37,6 +37,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_dec/FEC_scale_syn.c b/lib_dec/FEC_scale_syn.c
index 5ac57bb9125f580c6bc10aa2c175e4848293824b..7d43ad3a9ae7840dd49894d6a796169878894861 100644
--- a/lib_dec/FEC_scale_syn.c
+++ b/lib_dec/FEC_scale_syn.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "prot.h"
diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c
index dd2493b0e687d78d082bee8a3617e225ff83ba12..b7885d35b4cb8d04a771a46d7f11e8fa7cf04c1c 100644
--- a/lib_dec/LD_music_post_filter.c
+++ b/lib_dec/LD_music_post_filter.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c
index f3b73bf8ccba82a478155d0fd4efa2d201c3f43a..fedfe0c2e6be69c18d76ad5576922432a2408f21 100644
--- a/lib_dec/TonalComponentDetection.c
+++ b/lib_dec/TonalComponentDetection.c
@@ -39,6 +39,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "prot.h"
#include "cnst.h"
diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c
index 9a155491027e04a7dde5b6931c3124434cbb9d66..8233e26376bf2c4347a0f3750068b41b9cb3b3d6 100644
--- a/lib_dec/acelp_core_dec.c
+++ b/lib_dec/acelp_core_dec.c
@@ -37,6 +37,9 @@
#include
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
@@ -561,6 +564,9 @@ ivas_error acelp_core_dec(
}
}
+#ifdef DEBUG_MODE_ACELP
+ dbgwrite( exc, sizeof( float ), st->L_frame, 1, fname( debug_dir, "exc", st->idchan, st->id_element, DEC ) );
+#endif
/* synthesis at 12.8kHz sampling rate */
syn_12k8( st->L_frame, Aq, exc2, syn, st->mem_syn2, 1 );
@@ -820,6 +826,9 @@ ivas_error acelp_core_dec(
}
}
+#ifdef DEBUG_MODE_ACELP
+ dbgwrite( exc, sizeof( float ), st->L_frame, 1, fname( debug_dir, "exc", st->idchan, st->id_element, DEC ) );
+#endif
/* synthesis for ACELP core switching and SWB BWE */
syn_12k8( st->L_frame, Aq, exc, temp_buf, st->mem_syn1, 1 );
@@ -1222,6 +1231,9 @@ ivas_error acelp_core_dec(
}
}
+#ifdef DEBUG_MODE_ACELP
+ dbgwrite( syn, sizeof( float ), st->L_frame, 1, fname( debug_dir, "syn.intFs", st->idchan, st->id_element, DEC ) );
+#endif
/*----------------------------------------------------------------*
* Resample to the output sampling rate (8/16/32/48 kHz)
@@ -1352,6 +1364,9 @@ ivas_error acelp_core_dec(
/* save synthesis - needed in case of core switching */
mvr2r( synth, st->previoussynth, output_frame );
+#ifdef DEBUG_MODE_ACELP
+ dbgwrite( synth, sizeof( float ), output_frame, 1, fname( debug_dir, "output.Fs", st->idchan, st->id_element, DEC ) );
+#endif
}
else
{
@@ -1371,6 +1386,9 @@ ivas_error acelp_core_dec(
mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame );
}
+#ifdef DEBUG_MODE_ACELP
+ dbgwrite( synth, sizeof( float ), output_frame, 1, fname( debug_dir, "output.Fs", st->idchan, st->id_element, DEC ) );
+#endif
set_f( synth, 0.0f, output_frame );
}
diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c
index 96e6bec4ef9cf560374a5e12fce7d28044dc81fe..51d459b205e980505dd12a2d5c87795b95244c8b 100644
--- a/lib_dec/acelp_core_switch_dec.c
+++ b/lib_dec/acelp_core_switch_dec.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c
index b585eecf99e815fe242033de9f7d57b84bcda36a..5252b265647b1efd2581b816d7b72f2cad8a7f97 100644
--- a/lib_dec/amr_wb_dec.c
+++ b/lib_dec/amr_wb_dec.c
@@ -36,6 +36,9 @@
#include
#include "options.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
#include
#include "cnst.h"
#include "rom_com.h"
@@ -806,6 +809,20 @@ ivas_error amr_wb_dec(
/* final output of synthesis signal */
mvr2r( synth_out, output, output_frame );
+#ifdef DEBUG_MODE_INFO
+ dbgwrite( &st->clas_dec, sizeof( int16_t ), 1, output_frame, "res/clas.dec" );
+ dbgwrite( &st->codec_mode, sizeof( int16_t ), 1, output_frame, "res/codec.dec" );
+ dbgwrite( &st->core, sizeof( int16_t ), 1, output_frame, "res/core.dec" );
+ dbgwrite( &st->extl, sizeof( int16_t ), 1, output_frame, "res/extl.dec" );
+ dbgwrite( &st->bwidth, sizeof( int16_t ), 1, output_frame, "res/bwidth.dec" );
+ dbgwrite( &st->cng_type, sizeof( int16_t ), 1, output_frame, "res/cng_type.dec" );
+ tmp = st->core_brate / 1000.0f;
+ dbgwrite( &tmp, sizeof( float ), 1, output_frame, "res/core_brate.dec" );
+ dbgwrite( &tmp, sizeof( float ), 1, output_frame, "res/total_brate.dec" );
+ dbgwrite( &st->coder_type, sizeof( int16_t ), 1, output_frame, "res/coder_type.dec" );
+ dbgwrite( &st->L_frame, sizeof( int16_t ), 1, output_frame, "res/L_frame.dec" );
+ dbgwrite( &st->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" );
+#endif
return error;
}
diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c
index 82f35846c076109b6ede8c92e99b8a41802199db..09f1698133aabf410b5ff434b1b5a4cbffb8e4f6 100644
--- a/lib_dec/arith_coder_dec.c
+++ b/lib_dec/arith_coder_dec.c
@@ -37,6 +37,9 @@
#include
#include