diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d3eb0663641f691830768d6a5d5d6e6a0f95c8b9..a3fa4217b7aefb21f1be5bf9789acd8038432e70 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -168,7 +168,7 @@ stages:
- current_commit_sha=$(git rev-parse HEAD)
### build reference binaries
- git checkout $FLOAT_REF_BRANCH
- - git pull
+ - git pull origin $FLOAT_REF_BRANCH
- *activate-debug-mode-info-if-set
- make clean
- make -j
@@ -184,7 +184,7 @@ stages:
- current_commit_sha=$(git rev-parse HEAD)
### build merge target binaries
- git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- - git pull
+ - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- *activate-debug-mode-info-if-set
- make clean
- make -j
@@ -232,7 +232,7 @@ stages:
- git fetch
- git restore . # Just as a precaution
- git checkout $BASOP_CI_BRANCH_PC_REPO
- - git pull
+ - git pull origin $BASOP_CI_BRANCH_PC_REPO
- cd -
- cp -r $SCRIPTS_DIR/ci .
- cp -r $SCRIPTS_DIR/scripts .
@@ -274,12 +274,11 @@ stages:
.rules-pytest-to-ref-short:
rules:
+ - if: $PYTEST_MLD_SHORT # Set by scheduled pipeline
- 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
.rules-pytest-to-input-short:
rules:
@@ -397,8 +396,8 @@ stages:
- fi
- *build-and-create-float-ref-outputs
- - comp_args="--mld --ssnr --odg"
-
+ - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}")
+ - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING"
- summary_args="MLD DIFF SSNR ODG"
- REPORT_ARG=""
- if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi
@@ -518,7 +517,7 @@ stages:
- exit_code=0
- rm -rf .pytest_cache || true
- - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$?
+ - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$?
- if [ $exit_code -ne 0 ]; then
- exit_code=$EXIT_CODE_NON_BE
@@ -602,6 +601,10 @@ stages:
script:
- *print-common-info
+ # create empty files for all artifacts to suppress warnings in case of no regressions found or all is BE
+ - touch $XML_REPORT_BRANCH $XML_REPORT_MAIN $HTML_REPORT_BRANCH $HTML_REPORT_MAIN $CSV_BRANCH $CSV_MAIN $SUMMARY_HTML_ARTIFACT_NAME $FLOAT_REF_COMMIT_FILE $CUT_COMMIT_FILE $MERGE_TARGET_COMMIT_FILE regressions_crashes.csv regressions_MLD.csv regressions_MAXIMUM_ABS_DIFF.csv regressions_MIN_SSNR.csv regressions_MIN_ODG.csv improvements_crashes.csv improvements_MLD.csv improvements_MAXIMUM_ABS_DIFF.csv improvements_MIN_SSNR.csv improvements_MIN_ODG.csv
+ - mkdir $IMAGES_ARTIFACT_NAME
+
- set -euxo pipefail
- if [ -s $FAILED_TESTCASES_LIST ]; then
@@ -633,13 +636,16 @@ stages:
- echo $CI_MERGE_REQUEST_TITLE > tmp.txt
- allow_regressions_flag=$(grep -c --ignore-case "\[allow[ -]*regression\]" tmp.txt) || true
+ - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}")
+ - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING"
+
### run branch first
# this per default builds the branch and the reference and creates the reference outputs
- *build-and-create-float-ref-outputs
- *check-up-to-date-in-comparison-jobs
# need to restore cache again
- *overwrite-pytest-cache-with-artifact
- - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --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 || true
+ - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --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
- zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true
- python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH
@@ -647,18 +653,17 @@ stages:
- mv tests/dut tests/dut_branch
# create the summary based on the branch
- - mkdir $IMAGES_ARTIFACT_NAME
- for MEASURE in MLD DIFF SSNR ODG;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
+ - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- make clean
- make -j
# need to restore cache again
- *overwrite-pytest-cache-with-artifact
- - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --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 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --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
@@ -673,7 +678,7 @@ stages:
- echo "Reproduce locally with:"
- echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH"
- echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH"
- - echo "The individual command lines can be found in the changes*.csv files in the job artifacts."
+ - echo "The individual command lines can be found in the regressions_crashes.csv files in the job artifacts."
- elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then
- cat regression_log.txt
- if [ $allow_regressions_flag == 0 ]; then
@@ -686,7 +691,7 @@ stages:
- echo "Reproduce locally with:"
- echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH"
- echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH"
- - echo "The individual command lines can be found in the changes*.csv files in the job artifacts."
+ - echo "The individual command lines can be found in the regressions_*.csv files in the job artifacts."
- fi
- exit $exit_code
@@ -711,11 +716,16 @@ stages:
- $FLOAT_REF_COMMIT_FILE
- $CUT_COMMIT_FILE
- $MERGE_TARGET_COMMIT_FILE
- - changes_crashes.csv
- - changes_MLD.csv
- - changes_MAXIMUM_ABS_DIFF.csv
- - changes_MIN_SSNR.csv
- - changes_MIN_ODG.csv
+ - regressions_crashes.csv
+ - regressions_MLD.csv
+ - regressions_MAXIMUM_ABS_DIFF.csv
+ - regressions_MIN_SSNR.csv
+ - regressions_MIN_ODG.csv
+ - improvements_crashes.csv
+ - improvements_MLD.csv
+ - improvements_MAXIMUM_ABS_DIFF.csv
+ - improvements_MIN_SSNR.csv
+ - improvements_MIN_ODG.csv
expose_as: "pytest compare results"
reports:
junit:
@@ -744,7 +754,7 @@ stages:
- set -euxo pipefail
- make_args="CLANG=$CLANG_NUM"
- if [[ $CLANG_NUM == 3 ]]; then
- - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1"
+ - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1,print_stacktrace=1"
- python3 scripts/basop_create_ignorelist_for_ubsan.py
- make_args="$make_args IGNORELIST=1"
- fi
@@ -791,10 +801,13 @@ stages:
- fi
- *build-float-ref-and-dut-binaries
+ - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}")
+ - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING"
+
### run pytest
- exit_code=0
- - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report-ref.html --self-contained-html --junit-xml=report-junit-ref.xml --mld --ssnr --odg -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $REF_ENCODER_PATH --dut_decoder_path $REF_DECODER_PATH --compare_to_input || exit_code=$?
- - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report-dut.html --self-contained-html --junit-xml=report-junit-dut.xml --mld --ssnr --odg -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH --compare_to_input || exit_code=$?
+ - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report-ref.html --self-contained-html --junit-xml=report-junit-ref.xml $comp_args -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $REF_ENCODER_PATH --dut_decoder_path $REF_DECODER_PATH --compare_to_input || exit_code=$?
+ - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report-dut.html --self-contained-html --junit-xml=report-junit-dut.xml $comp_args -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH --compare_to_input || exit_code=$?
- zero_errors_ref=$(cat report-junit-ref.xml | grep -c 'errors="0"') || true
- zero_errors_dut=$(cat report-junit-dut.xml | grep -c 'errors="0"') || true
- python3 scripts/parse_xml_report.py report-junit-ref.xml report-ref.csv
@@ -973,7 +986,7 @@ build-codec-linux-instrumented-make:
script:
- *print-common-info
- *update-scripts-repo
- - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP
+ - bash scripts/prepare_instrumentation.sh -m MEM_ONLY
- make -j -C $INSTR_DIR
build-codec-linux-debugging-make:
@@ -1303,7 +1316,7 @@ ivas-pytest-enc-usan:
before_script:
- CLANG_NUM=3
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE=$SHORT_TEST_SUITE_ENCODER
+ - TEST_SUITE=$LONG_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
### jobs that test flt encoder -> fx decoder
@@ -1393,7 +1406,7 @@ ivas-pytest-dec-usan:
before_script:
- CLANG_NUM=3
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
- - TEST_SUITE=$SHORT_TEST_SUITE
+ - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER
<<: *ivas-pytest-sanitizers-anchor
# ---------------------------------------------------------------
@@ -1726,7 +1739,7 @@ voip-be-on-merge-request:
stage: test
variables:
ret_val: 0
- GET_WMOPS_ARGS: "mem_only basop"
+ GET_WMOPS_ARGS: "mem_only"
timeout: 3 hours 30 minutes
before_script:
- *print-common-info
@@ -1734,13 +1747,19 @@ voip-be-on-merge-request:
- *update-ltv-repo
- *build-float-ref-and-dut-binaries
- *complexity-measurements-setup
+ # delete previous jobs logfiles if present (-f flag ensures return calue of 0 even in first run where this folder is not present)
+ - rm -rf COMPLEXITY/logs
- which coan
+ allow_failure:
+ exit_codes:
+ - 123
artifacts:
name: "$CI_JOB_NAME--$CI_COMMIT_REF_NAME--sha-$CI_COMMIT_SHA"
when: always
expire_in: 2 week
paths:
- $CI_JOB_NAME-public
+ - COMPLEXITY/logs
complexity-stereo-in-stereo-out:
extends:
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index c88725ef0a7c34891cf22d6eaeffdddc1a237dab..7a2aa8a7f66bcdd6ec2164f382b709a8b43cc925 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -138,7 +138,6 @@
-
@@ -200,45 +199,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
@@ -279,7 +277,6 @@
-
@@ -318,13 +315,11 @@
-
-
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index c58edbff66fed647de45957935168e3d43c45bca..89b47a3fcf9b04744c7ba3e9fd1cfec159c27ca9 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -1,81 +1,6 @@
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
common_all_c
@@ -379,9 +304,6 @@
common_all_c
-
- common_all_c
-
common_all_c
@@ -469,18 +391,6 @@
common_ivas_c
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
-
- common_ivas_c
-
common_ivas_c
@@ -493,18 +403,12 @@
common_ivas_c
-
- common_ivas_c
-
common_all_c
common_all_c
-
- common_all_c
-
common_all_c
@@ -526,9 +430,6 @@
common_all_c
-
- common_all_c
-
common_all_c
@@ -544,6 +445,96 @@
common_all_c
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
+
+ common_ivas_c
+
@@ -579,18 +570,12 @@
common_h
-
- common_h
-
common_h
common_h
-
- common_h
-
common_h
@@ -628,7 +613,7 @@
common_h
- common_all_c
+ common_h
diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index d6e4a7c672d91bb76b7e3e30fdca199c56285df7..2d06d29aa90604e44237a3feaf6dc21c57fa4850 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -136,297 +136,184 @@
-
false
-
false
-
-
-
-
-
-
-
false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
-
-
+
-
-
-
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index 348c5fbda5c75c35efa9ddc97f6246a8d33ed218..8a4fc4605a1170b9da66c90a81b8bdd4134573c7 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -1,671 +1,274 @@
-
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
-
- decoder_evs_c
-
decoder_evs_c
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
-
- decoder_evs_c
-
decoder_evs_c
decoder_evs_c
-
- decoder_evs_c
-
-
- decoder_evs_c
-
decoder_evs_c
decoder_evs_c
-
- decoder_evs_c
-
-
- decoder_evs_c
-
decoder_evs_c
decoder_evs_c
-
- decoder_evs_c
-
-
- decoder_evs_c
-
decoder_evs_c
decoder_evs_c
-
- decoder_evs_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
decoder_ivas_c
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
@@ -681,179 +284,239 @@
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj
index 75831970efdfb8fc2a9230f03be6eba7eb990195..86dcef90541be79286704dffc2160960a9846d2c 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -215,127 +215,71 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
@@ -373,19 +317,9 @@
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters
index 0c3220178924f65ff87dfee9b4c2a57195bfd1d9..8990971637ef90b8f3a11fbd672278a29d3f89da 100644
--- a/Workspace_msvc/lib_enc.vcxproj.filters
+++ b/Workspace_msvc/lib_enc.vcxproj.filters
@@ -8,75 +8,39 @@
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
@@ -92,54 +56,33 @@
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
encoder_evs_c
-
- encoder_evs_c
-
encoder_evs_c
@@ -164,174 +107,9 @@
encoder_evs_c
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
encoder_ivas_c
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
-
- encoder_ivas_c
-
encoder_all_c
@@ -347,135 +125,72 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -494,9 +209,6 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -506,27 +218,15 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -536,45 +236,24 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -590,39 +269,21 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -632,27 +293,15 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -668,21 +317,12 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -719,9 +359,6 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -800,6 +437,171 @@
encoder_all_c
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
+
+ encoder_ivas_c
+
diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj
index fa11b23beb756bdfe1bbad4a3cf989ea5ed750bb..e47858ae380f169b2bf53e720d1c3abf23c29224 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -136,50 +136,50 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters
index 01f3dfb74b19aaa5bbfbce01fa14d68eaf0e5af8..5c4a4901111136b5ce1c1406701ffe10e156b86b 100644
--- a/Workspace_msvc/lib_rend.vcxproj.filters
+++ b/Workspace_msvc/lib_rend.vcxproj.filters
@@ -2,132 +2,129 @@
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
+
rend_c
-
- rend_h
-
rend_h
@@ -143,7 +140,7 @@
rend_h
-
+
rend_h
diff --git a/apps/renderer.c b/apps/renderer.c
index ceb1a448e38d866ec5162e2cc637cf18273c5fd4..47548d438f9d3ae4e8e409c60d14051f256e24b0 100644
--- a/apps/renderer.c
+++ b/apps/renderer.c
@@ -699,10 +699,8 @@ int main(
lfeRoutingConfigs[i] = NULL;
}
-#ifdef FIX_DISCLAIMER
IVAS_REND_PrintDisclaimer();
-#endif
CmdlnArgs args = parseCmdlnArgs( argc, argv );
if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) ||
@@ -864,7 +862,6 @@ int main(
exit( -1 );
}
-#ifdef FIX_DISCLAIMER
fprintf( stdout, "Input audio file: %s\n", args.inputFilePath );
fprintf( stdout, "Output audio file: %s\n\n", args.outputFilePath );
@@ -907,7 +904,6 @@ int main(
exit( -1 );
}
-#endif
/* === Configure === */
if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
{
diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c
index 076bc8d9263d1f59c12906bb796fcbd5f245f591..46f8ecea1e78f01164d1acc083f29d3c26b145b6 100644
--- a/lib_com/ari_hm_fx.c
+++ b/lib_com/ari_hm_fx.c
@@ -10,7 +10,6 @@
#include "basop_util.h"
#include "rom_com.h"
#include "prot_fx.h"
-#include "prot.h"
#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
void UnmapIndex(
diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c
index de22a7cf34863a72a79c2ba62661753766146176..846b4dceab0befaa6257563eda540e785fb7c1d9 100644
--- a/lib_com/arith_coder_fx.c
+++ b/lib_com/arith_coder_fx.c
@@ -6,7 +6,6 @@
#include
#include "options.h"
#include "prot_fx.h"
-#include "prot.h"
#include "basop_util.h"
#include "basop_proto_func.h"
#include "cnst.h"
diff --git a/lib_com/basop32.c b/lib_com/basop32.c
index 7fab246607e316ca3e688971e6b850277fe9576c..20dbe663e6f5379f61062595a096af00c50480dc 100644
--- a/lib_com/basop32.c
+++ b/lib_com/basop32.c
@@ -2563,10 +2563,8 @@ Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow )
{
var_out = shr_o( var1, var2, Overflow );
-#ifdef FIX_1049_SHR_RO_COMPLEXITY
#ifdef WMOPS
multiCounter[currCounter].shr--;
-#endif
#endif
if ( var2 > 0 )
{
@@ -2577,13 +2575,11 @@ Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow )
}
}
-#ifdef FIX_1049_SHR_RO_COMPLEXITY
#ifdef WMOPS
multiCounter[currCounter].shr_r++;
#endif
BASOP_CHECK();
-#endif
return ( var_out );
}
diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c
index 378faae0f912a9af3b62e846b29ec38b8fbb44d4..8038c4f91e44fa3d4f3be746e03c2e3f1a7816ce 100644
--- a/lib_com/basop_tcx_utils.c
+++ b/lib_com/basop_tcx_utils.c
@@ -40,7 +40,7 @@
#include "cnst.h"
#include "basop_proto_func.h"
#include "stl.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#define WMC_TOOL_SKIP
diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c
index 92a8e3928cf25b050ed7cc0a5766181b60f4a66f..30ae2d47b028021152ead282c240af1a18c6f46b 100644
--- a/lib_com/bitalloc_fx.c
+++ b/lib_com/bitalloc_fx.c
@@ -7,7 +7,6 @@
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
-#include "prot.h" /* Function prototypes */
void bitalloc_fx(
Word16 *y, /* i : reordered norm of sub-vectors Q0 */
diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c
index f2a074ba52262775d8bd34d2298645746b971661..8162a98d3fa3147ea128100fddad063e0f8cd18d 100644
--- a/lib_com/bits_alloc_fx.c
+++ b/lib_com/bits_alloc_fx.c
@@ -408,7 +408,7 @@ static Word16 BITS_ALLOC_adjust_acelp_fixed_cdk(
return bitsused;
}
-/*#ifdef IVAS_CODE Below basop operators are missing */
+
/*-------------------------------------------------------------------*
* fcb_table()
*
@@ -762,42 +762,38 @@ static ivas_error acelp_FCB_allocator_ivas(
*--------------------------------------------------------------------*/
ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
-#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signalling_bits, /* i : number of signalling bits */
+ const Word16 coder_type, /* i : coder type */
const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
-#endif
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
+ const Word16 tc_subfr, /* i : TC subfr ID */
+ const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
+ Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
+ Word16 *unbits, /* o : number of unused bits */
+ const Word16 element_mode, /* i : element mode */
+ Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
+ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 idchan, /* i : stereo channel ID */
+ const Word16 active_cnt, /* i : Active frame counter */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
)
{
Word16 i, bits, nb_subfr;
Word16 flag_hardcoded, coder_type_sw, fix_first;
Word32 core_brate;
#ifdef DEBUGGING
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) active_cnt;
-#endif
#endif
ivas_error error;
@@ -1078,13 +1074,9 @@ ivas_error config_acelp1(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ ||
( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */
)
-#else
- IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) || ( coder_type == INACTIVE && GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
-#endif
{
*nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )];
move16();
@@ -1205,11 +1197,7 @@ ivas_error config_acelp1(
{
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
-#else
- IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) /* GSC Inactive @16kHz */
-#endif
{
acelp_cfg->ltf_mode = FULL_BAND;
move16();
@@ -1427,14 +1415,10 @@ ivas_error config_acelp1(
acelp_cfg->fixed_cdk_index[3] = -1;
move16();
}
-#ifdef NONBE_FIX_GSC_BSTR
ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || /* @12.8kHz core except of GSC */
( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ ||
EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */
)
-#else
- ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) || coder_type != INACTIVE ) ) || EQ_16( core, HQ_CORE ) )
-#endif
{
/* pitch Q & gain Q bit-budget - part 2*/
FOR( i = 0; i < nb_subfr; i++ )
@@ -1498,13 +1482,9 @@ ivas_error config_acelp1(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( flag_hardcoded /* EVS */ ||
( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
-#else
- IF( flag_hardcoded || ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
-#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -1613,12 +1593,8 @@ ivas_error config_acelp1(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
-#else
- IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
-#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -1658,13 +1634,9 @@ ivas_error config_acelp1(
}
}
}
-#ifdef NONBE_FIX_GSC_BSTR
ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ ||
( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ ||
( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ )
-#else
- ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) || ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) || ( coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
-#endif
{
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT;
@@ -1805,12 +1777,8 @@ ivas_error config_acelp1(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ ||
( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */
-#else
- IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) || ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* GSC Inactive @16kHz */
-#endif
{
acelp_cfg->ubits = 0;
move16();
@@ -1919,33 +1887,31 @@ ivas_error config_acelp1(
*--------------------------------------------------------------------*/
ivas_error config_acelp1_IVAS(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signaling_bits, /* i : number of signaling bits */
- const Word16 coder_type, /* i : coder type */
-#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signaling_bits, /* i : number of signaling bits */
+ const Word16 coder_type, /* i : coder type */
const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
-#endif
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
+ const Word16 tc_subfr, /* i : TC subfr ID */
+ const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
+ Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
+ Word16 *unbits, /* o : number of unused bits */
+ const Word16 element_mode, /* i : element mode */
+ Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
+ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 idchan, /* i : stereo channel ID */
+ const Word16 active_cnt, /* i : Active frame counter */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
)
{
Word16 i, bits, nb_subfr;
@@ -2214,12 +2180,8 @@ ivas_error config_acelp1_IVAS(
test();
test();
/* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */
-#ifdef NONBE_FIX_GSC_BSTR
IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ ||
( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */ )
-#else
- IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && ( coder_type != INACTIVE ) && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) || ( ( coder_type == INACTIVE ) && GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
-#endif
{
*nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX( core_brate, coder_type, -1, -1 )];
move16();
@@ -2344,11 +2306,7 @@ ivas_error config_acelp1_IVAS(
{
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
-#else
- IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) /* GSC Inactive @16kHz */
-#endif
{
acelp_cfg->ltf_mode = FULL_BAND;
move16();
@@ -2564,13 +2522,9 @@ ivas_error config_acelp1_IVAS(
acelp_cfg->fixed_cdk_index[3] = -1;
move16();
}
-#ifdef NONBE_FIX_GSC_BSTR
ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) /* @12.8kHz core except of GSC */ ||
( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ ||
EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */ )
-#else
- ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) || coder_type != INACTIVE ) ) || EQ_16( core, HQ_CORE ) )
-#endif
{
/* pitch Q & gain Q bit-budget - part 2*/
FOR( i = 0; i < nb_subfr; i++ )
@@ -2634,13 +2588,9 @@ ivas_error config_acelp1_IVAS(
test();
test();
/* algebraic codebook bit-budget */
-#ifdef NONBE_FIX_GSC_BSTR
IF( flag_hardcoded /* EVS */ ||
( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
-#else
- IF( flag_hardcoded || ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
-#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -2741,12 +2691,8 @@ ivas_error config_acelp1_IVAS(
test();
test();
/* AVQ codebook */
-#ifdef NONBE_FIX_GSC_BSTR
IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
-#else
- IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
-#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -2784,13 +2730,9 @@ ivas_error config_acelp1_IVAS(
}
}
}
-#ifdef NONBE_FIX_GSC_BSTR
ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ ||
( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ ||
( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ )
-#else
- ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) || ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) || ( coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
-#endif
{
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT;
@@ -2931,12 +2873,8 @@ ivas_error config_acelp1_IVAS(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ ||
( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */
-#else
- IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) || ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* GSC Inactive @16kHz */
-#endif
{
acelp_cfg->ubits = 0;
move16();
@@ -3271,4 +3209,3 @@ Word16 set_ACELP_flag_IVAS(
return 0;
}
}
-/*#endif IVAS_CODE*/
diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c
index e5754fa3550fc318b4ab703338a30db52018fa1d..d8d4563ed3a60fdf6325d71a81a73384c100f911 100644
--- a/lib_com/bitstream.c
+++ b/lib_com/bitstream.c
@@ -38,13 +38,11 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot.h"
#include "prot_fx.h"
#include "stat_enc.h"
#include "stat_dec.h"
#include "rom_com.h"
#include "mime.h"
-#include "ivas_prot.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
@@ -1320,33 +1318,6 @@ UWord16 get_indice_st(
}
#define WMC_TOOL_SKIP
-/*-------------------------------------------------------------------*
- * reset_indices_enc()
- *
- * Reset the buffer of encoder indices
- *-------------------------------------------------------------------*/
-
-void reset_indices_enc(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 max_num_indices /* i : max number of indices */
-)
-{
- Word16 i;
-
- hBstr->nb_bits_tot = 0;
- move16();
- hBstr->nb_ind_tot = 0;
- move16();
-
- FOR( i = 0; i < max_num_indices; i++ )
- {
- hBstr->ind_list[i].nb_bits = -1;
- move16();
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
* reset_indices_dec()
*
@@ -1535,21 +1506,21 @@ static ivas_error write_indices_element_fx(
{
IF( st_ivas->hSCE[element_id]->hMetaData != NULL )
{
- reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot );
+ reset_indices_enc_fx( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot );
}
- reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot );
+ reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot );
}
ELSE
{
IF( st_ivas->hCPE[element_id]->hMetaData != NULL )
{
- reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot );
+ reset_indices_enc_fx( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot );
}
FOR( n = 0; n < n_channels; n++ )
{
- reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot );
+ reset_indices_enc_fx( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot );
}
}
@@ -1689,281 +1660,6 @@ static void decoder_selectCodec(
return;
}
-/*-------------------------------------------------------------------*
- * dec_prm_core()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void dec_prm_core(
- Decoder_State *st )
-{
- int16_t n, frame_size_index = -1;
-
- st->core = -1;
-
- if ( st->total_brate == FRAME_NO_DATA )
- {
- st->m_frame_type = ZERO_FRAME;
- }
- else if ( st->total_brate == SID_2k40 )
- {
- st->m_frame_type = SID_FRAME;
- }
- else
- {
- st->m_frame_type = ACTIVE_FRAME;
- for ( n = 0; n < FRAME_SIZE_NB; ++n )
- {
- if ( FrameSizeConfig[n].frame_bits == st->total_brate / FRAMES_PER_SEC )
- {
- frame_size_index = n;
- break;
- }
- }
-
- /* Get audio bandwidth info */
- st->bwidth = get_next_indice( st, FrameSizeConfig[frame_size_index].bandwidth_bits );
- st->bwidth += FrameSizeConfig[frame_size_index].bandwidth_min;
- if ( st->bwidth > FB )
- {
- st->bwidth = FB;
- st->BER_detect = 1;
- }
-
- if ( st->bwidth > SWB && st->total_brate < ACELP_16k40 )
- {
- st->bwidth = SWB;
- st->BER_detect = 1;
- }
- /* Skip reserved bit */
- get_next_indice_tmp( st, FrameSizeConfig[frame_size_index].reserved_bits );
-
- if ( get_next_indice_1( st ) ) /* TCX */
- {
- if ( get_next_indice_1( st ) )
- {
- st->core = HQ_CORE;
- }
- else
- {
- st->core = TCX_20_CORE;
- }
- }
- else /* ACELP */
- {
- st->core = ACELP_CORE;
- }
- }
-
- return;
-}
-
-/*-----------------------------------------------------------------*
- * decision_matrix_core_dec()
- *
- * Read core signaling bits from the bitstream
- * Set st->core, and st->bwidth if signalled together with the core.
- *-----------------------------------------------------------------*/
-
-static void decision_matrix_core_dec(
- Decoder_State *st /* i/o: decoder state structure */
-)
-{
- int16_t start_idx;
- int32_t ind;
- int16_t nBits;
-
- assert( st->bfi != 1 );
-
- st->core = -1;
- st->bwidth = -1;
-
- if ( st->total_brate == FRAME_NO_DATA || st->total_brate == SID_2k40 )
- {
- st->core = ACELP_CORE;
- }
- /* SC-VBR */
- else if ( st->total_brate == PPP_NELP_2k80 )
- {
- st->core = ACELP_CORE;
- return;
- }
-
- /*---------------------------------------------------------------------*
- * ACELP/HQ core selection
- *---------------------------------------------------------------------*/
-
- if ( st->total_brate < ACELP_24k40 )
- {
- st->core = ACELP_CORE;
- }
- else if ( st->total_brate >= ACELP_24k40 && st->total_brate <= ACELP_64k )
- {
- /* read the ACELP/HQ core selection bit */
- st->core = get_next_indice( st, 1 ) * HQ_CORE;
- }
- else
- {
- st->core = HQ_CORE;
- }
-
- /*-----------------------------------------------------------------*
- * Read ACELP signaling bits from the bitstream
- *-----------------------------------------------------------------*/
-
- if ( st->core == ACELP_CORE )
- {
- /* find the section in the ACELP signaling table corresponding to bitrate */
- start_idx = 0;
- while ( acelp_sig_tbl[start_idx] != st->total_brate )
- {
- start_idx++;
- }
-
- /* skip the bitrate */
- start_idx += 1;
-
- /* retrieve the number of bits */
- nBits = (int16_t) acelp_sig_tbl[start_idx++];
-
- /* retrieve the signaling indice */
- ind = acelp_sig_tbl[start_idx + get_next_indice( st, nBits )];
- st->bwidth = ( ind >> 3 ) & 0x7;
-
- /* convert signaling indice into signaling information */
- if ( ( ind & 0x7 ) == LR_MDCT )
- {
- st->core = HQ_CORE;
- }
- }
-
- /*-----------------------------------------------------------------*
- * Read HQ signaling bits from the bitstream
- * Set HQ core type
- *-----------------------------------------------------------------*/
-
- if ( st->core == HQ_CORE )
- {
- /* read the HQ/TCX core switching flag */
- if ( get_next_indice( st, 1 ) )
- {
- st->core = TCX_20_CORE;
- }
-
- /* For TCX: read/set band-width (needed for different I/O sampling rate support) */
- if ( st->core == TCX_20_CORE && st->total_brate > ACELP_16k40 )
- {
- ind = get_next_indice( st, 2 );
-
- if ( ind == 0 )
- {
- st->bwidth = NB;
- }
- else if ( ind == 1 )
- {
- st->bwidth = WB;
- }
- else if ( ind == 2 )
- {
- st->bwidth = SWB;
- }
- else
- {
- st->bwidth = FB;
- }
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * mdct_switching_dec()
- *
- * Set up MDCT core switching if indicated in the bitstream
- *-------------------------------------------------------------------*/
-
-void mdct_switching_dec(
- Decoder_State *st /* i/o: decoder state structure */
-)
-{
- if ( !st->bfi )
- {
-
- if ( st->Opt_AMR_WB )
- {
- return;
- }
-
-
- if ( st->total_brate == ACELP_13k20 || st->total_brate == ACELP_32k )
- {
- st->mdct_sw_enable = MODE1;
- }
- else if ( ACELP_16k40 <= st->total_brate && st->total_brate <= ACELP_24k40 )
- {
- st->mdct_sw_enable = MODE2;
- }
-
- if ( st->codec_mode == MODE1 && st->mdct_sw_enable == MODE1 )
- {
- /* Read ahead core signaling */
- int16_t next_bit_pos_save = st->next_bit_pos;
- int16_t core_save = st->core;
- int16_t bwidth_save = st->bwidth;
-
- decision_matrix_core_dec( st ); /* sets st->core */
-
- if ( st->core == TCX_20_CORE )
- {
- /* Trigger TCX */
- st->codec_mode = MODE2;
- st->mdct_sw = MODE1;
- }
- else
- {
- /* Rewind bitstream */
- st->next_bit_pos = next_bit_pos_save;
- if ( st->bfi )
- {
- st->core = core_save;
- st->bwidth = bwidth_save;
- }
- }
- }
- else if ( st->codec_mode == MODE2 && st->mdct_sw_enable == MODE2 )
- {
- /* Read ahead core signaling */
- int16_t next_bit_pos_save = st->next_bit_pos;
- int16_t core_save = st->core;
- int16_t bwidth_save = st->bwidth;
-
- dec_prm_core( st ); /* sets st->core */
-
- if ( st->core == HQ_CORE )
- {
- /* Trigger HQ_CORE */
- st->codec_mode = MODE1;
- st->mdct_sw = MODE2;
- }
- else
- {
- /* Rewind bitstream */
- st->next_bit_pos = next_bit_pos_save;
- if ( st->bfi )
- {
- st->core = core_save;
- }
- /* always reset bwidth, to not interfere with BER logic */
- st->bwidth = bwidth_save;
- }
- }
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
* reset_elements()
@@ -2061,67 +1757,84 @@ void ivas_set_bitstream_pointers(
*-------------------------------------------------------------------*/
/*! r: 1 = reading OK, 0 = problem */
-ivas_error read_indices(
+ivas_error read_indices_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- uint16_t bit_stream[], /* i : bitstream buffer */
+ UWord16 bit_stream[], /* i : bitstream buffer */
UWord16 num_bits, /* i : number of bits in bitstream */
- int16_t *prev_ft_speech,
- int16_t *CNG,
- int16_t bfi /* i : bad frame indicator */
+ Word16 *prev_ft_speech,
+ Word16 *CNG,
+ Word16 bfi /* i : bad frame indicator */
)
{
- int16_t k;
+ Word16 k;
Decoder_State **sts;
- int32_t total_brate = 0;
- int16_t curr_ft_good_sp, curr_ft_bad_sp;
- int16_t g192_sid_first, sid_upd_bad, sid_update;
- int16_t speech_bad, speech_lost;
- int16_t n;
+ Word32 total_brate = 0;
+ move32();
+ Word16 curr_ft_good_sp, curr_ft_bad_sp;
+ Word16 g192_sid_first, sid_upd_bad, sid_update;
+ Word16 speech_bad, speech_lost;
+ Word16 n;
ivas_error error;
error = IVAS_ERR_OK;
+ move32();
st_ivas->BER_detect = 0;
+ move16();
st_ivas->num_bits = num_bits;
+ move16();
sts = reset_elements( st_ivas );
st_ivas->bfi = bfi;
+ move16();
/* convert the frame length to total bitrate */
- total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC );
+ total_brate = imult3216( num_bits, FRAMES_PER_SEC );
+ move32();
/* verify that a valid num bits value is present in the G.192 file */
/* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */
- if ( st_ivas->ivas_format != MONO_FORMAT )
+ IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) )
{
k = 0;
- while ( k < SIZE_IVAS_BRATE_TBL && total_brate != ivas_brate_tbl[k] )
+ move16();
+
+ test();
+ WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( total_brate, ivas_brate_tbl[k] ) )
{
- k++;
+ k = add( k, 1 );
}
- if ( st_ivas->ivas_format == ISM_FORMAT && ( k < SIZE_IVAS_BRATE_TBL || total_brate <= SID_2k40 ) )
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && ( LT_16( k, SIZE_IVAS_BRATE_TBL ) || LE_32( total_brate, SID_2k40 ) ) )
{
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
}
- else if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) && ( total_brate <= SID_2k40 ) )
+ ELSE IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( total_brate, SID_2k40 ) )
{
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
}
- else if ( k == SIZE_IVAS_BRATE_TBL )
+ ELSE IF( EQ_16( k, SIZE_IVAS_BRATE_TBL ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate );
}
- else
+ ELSE
{
st_ivas->element_mode_init = -1;
+ move16();
}
}
- else /* AMRWB or EVS */
+ ELSE /* AMRWB or EVS */
{
st_ivas->element_mode_init = EVS_MONO;
+ move16();
- if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
+ IF( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate );
}
@@ -2131,47 +1844,58 @@ ivas_error read_indices(
/* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */
/* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */
curr_ft_good_sp = 0;
+ move16();
curr_ft_bad_sp = 0;
+ move16();
- if ( is_DTXrate( total_brate ) == 0 )
+ IF( is_DTXrate( total_brate ) == 0 )
{
- if ( st_ivas->bfi == 0 )
+ IF( st_ivas->bfi == 0 )
{
curr_ft_good_sp = 1;
+ move16();
}
- else
+ ELSE
{
curr_ft_bad_sp = 1;
+ move16();
}
}
sid_update = 0;
+ move16();
sid_upd_bad = 0;
- if ( is_SIDrate( total_brate ) == 1 )
+ move16();
+ IF( EQ_16( is_SIDrate( total_brate ), 1 ) )
{
- if ( st_ivas->bfi == 0 )
+ IF( st_ivas->bfi == 0 )
{
sid_update = 1;
+ move16();
}
- else
+ ELSE
{
sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames */
+ move16();
}
}
/* all zero indices/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */
/* all zero indices/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */
- if ( total_brate == SID_1k75 && sid_update == 1 )
+ test();
+ IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) )
{
/* valid sid_update received, check for very risky but formally valid content */
- int16_t sum = 0;
- for ( k = 0; k < num_bits; ++k )
+ Word16 sum = 0;
+ move16();
+ FOR( k = 0; k < num_bits; ++k )
{
- sum += ( bit_stream[k] == 1 ); /* check of 35 zeroes */
+ sum = add( sum, extract_l( EQ_32( bit_stream[k], 1 ) ) ); /* check of 35 zeroes */
}
if ( sum == 0 )
{ /* all zeros */
sid_upd_bad = 1; /* initial signal as corrupt (BER likely) */
+ move16();
}
}
@@ -2182,14 +1906,22 @@ ivas_error read_indices(
Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR .
*/
- if ( sid_upd_bad )
+ IF( sid_upd_bad )
{
sid_upd_bad = 0;
+ move16();
total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */
+ move32();
}
g192_sid_first = 0;
- if ( st_ivas->ivas_format == MONO_FORMAT && sts[0]->core == AMR_WB_CORE && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 )
+ move16();
+
+ test();
+ test();
+ test();
+ test();
+ if ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( sts[0]->core, AMR_WB_CORE ) && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 )
{
g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */
/* It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where:
@@ -2197,104 +1929,135 @@ ivas_error read_indices(
and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO,
due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding
*/
+ move16();
}
speech_bad = 0;
+ move16();
+
+ test();
if ( st_ivas->bfi != 0 && ( is_DTXrate( total_brate ) == 0 ) )
{
speech_bad = 1; /* initial ft assumption, CNG_state decides what to do */
+ move16();
}
speech_lost = 0;
+ move16();
+
+ test();
if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */
{
speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */
+ move16();
}
/* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame
as this frame was never transmitted, one can not know it is good and has a a length of zero ) */
- if ( *CNG != 0 )
+ IF( *CNG != 0 )
{
/* We were in CNG synthesis */
if ( curr_ft_good_sp != 0 )
{
/* only a good speech frame makes you leave CNG synthesis */
*CNG = 0;
+ move16();
}
}
- else
+ ELSE
{
/* We were in SPEECH synthesis */
/* only a received/detected SID frame can make the decoder enter into CNG synthsis */
+ test();
+ test();
if ( g192_sid_first || sid_update || sid_upd_bad )
{
*CNG = 1;
+ move16();
}
}
/* set bfi, total_brate pair for proper decoding */
/* handle the G.192 _simulated_ untransmitted NO_DATA frame, setting for decoder SPEECH synthesis */
+ test();
+ test();
if ( *CNG == 0 && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 )
{
st_ivas->bfi = 1; /* SPEECH PLC code will now become active as in a real system */
/* total_brate= 0 */
+ move16();
}
/* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
- if ( (
- bfi != FRAMEMODE_FUTURE &&
- ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
- ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */
+ test();
+ test();
+ test();
+ test();
+ IF( (
+ NE_16( bfi, FRAMEMODE_FUTURE ) &&
+ ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
+ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */
{
st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */
+ move16();
total_brate = FRAME_NO_DATA;
+ move32();
}
/* update for next frame's G.192 file format's odd SID_FIRST detection (primarily for AMRWBIO) */
+ test();
*prev_ft_speech = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) );
+ move16();
/* st->total brate= total_brate; updated in a good frame below */
- for ( k = 0; k < st_ivas->nCPE; k++ )
+ FOR( k = 0; k < st_ivas->nCPE; k++ )
{
sts = st_ivas->hCPE[k]->hCoreCoder;
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
sts[n]->bfi = st_ivas->bfi;
+ move16();
}
}
- for ( k = 0; k < st_ivas->nSCE; k++ )
+ FOR( k = 0; k < st_ivas->nSCE; k++ )
{
sts = st_ivas->hSCE[k]->hCoreCoder;
sts[0]->bfi = st_ivas->bfi;
+ move16();
}
- if ( st_ivas->bfi == 0 )
+ IF( st_ivas->bfi == 0 )
{
/* select Mode 1 or Mode 2 */
- if ( st_ivas->ivas_format == MONO_FORMAT ) /* EVS mono */
+ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) /* EVS mono */
{
decoder_selectCodec( sts[0], total_brate, bit_stream[0] );
st_ivas->hDecoderConfig->Opt_AMR_WB = sts[0]->Opt_AMR_WB;
+ move16();
}
- else /* IVAS */
+ ELSE /* IVAS */
{
st_ivas->codec_mode = MODE1;
+ move16();
st_ivas->hDecoderConfig->Opt_AMR_WB = 0;
+ move16();
}
}
/* GOOD frame */
- if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE )
+ test();
+ if ( st_ivas->bfi == 0 || EQ_16( st_ivas->bfi, FRAMEMODE_FUTURE ) )
{
/* GOOD frame - convert ITU-T G.192 words to short values */
st_ivas->hDecoderConfig->ivas_total_brate = total_brate;
+ move32();
}
st_ivas->bit_stream = bit_stream;
- if ( st_ivas->ivas_format == MONO_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
{
ivas_set_bitstream_pointers( st_ivas );
}
diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c
index 6163fc4ff4163b4f2bee8a629d9ca7f35c2fdfaa..e144c2cc9332daf6dad320ddca2526de274bd4ea 100644
--- a/lib_com/bitstream_fx.c
+++ b/lib_com/bitstream_fx.c
@@ -143,29 +143,6 @@ void pack_bit(
return;
}
-/*-------------------------------------------------------------------*
- * unpack_bit()
- *
- * unpack a bit from packed octet
- *-------------------------------------------------------------------*/
-static Word16 unpack_bit(
- UWord8 **pt, /* i/o: pointer to octet array from which bit will be read */
- UWord8 *mask /* i/o: mask to indicate the bit in the octet */
-)
-{
- Word16 bit;
-
- bit = s_and( **pt, *mask ) != 0;
- *mask = (UWord8) shr( *mask, 1 );
- move16();
- IF( *mask == 0 )
- {
- *mask = 0x80;
- move16();
- ( *pt )++;
- }
- return bit;
-}
/*-------------------------------------------------------------------*
* rate2AMRWB_IOmode()
@@ -543,15 +520,14 @@ UWord16 get_indice_1_fx( /* o : value of the indice */
*-------------------------------------------------------------------*/
void reset_indices_enc_fx(
- BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
+ const Word16 max_num_indices /* i : max number of indices */
)
{
Word16 i;
-#ifdef MSAN_FIX
hBstr->nb_ind_tot = 0;
move16();
-#endif
hBstr->nb_bits_tot = 0;
move16();
hBstr->next_ind_fx = 0;
@@ -559,7 +535,7 @@ void reset_indices_enc_fx(
hBstr->last_ind_fx = -1;
move16();
- FOR( i = 0; i < MAX_NUM_INDICES; i++ )
+ FOR( i = 0; i < max_num_indices; i++ )
{
hBstr->ind_list[i].nb_bits = -1;
move16();
@@ -944,154 +920,6 @@ return;
}
-static void decoder_selectCodec(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word32 total_brate, /* i : total bitrate */
- const Word16 bit0 )
-{
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- /* check if we are in AMR-WB IO mode */
- IF( EQ_32( total_brate, SID_1k75 ) ||
- EQ_32( total_brate, ACELP_6k60 ) || EQ_32( total_brate, ACELP_8k85 ) || EQ_32( total_brate, ACELP_12k65 ) ||
- EQ_32( total_brate, ACELP_14k25 ) || EQ_32( total_brate, ACELP_15k85 ) || EQ_32( total_brate, ACELP_18k25 ) ||
- EQ_32( total_brate, ACELP_19k85 ) || EQ_32( total_brate, ACELP_23k05 ) || EQ_32( total_brate, ACELP_23k85 ) )
- {
- st->Opt_AMR_WB = 1;
- move16();
- }
- ELSE IF( total_brate != FRAME_NO_DATA )
- {
- st->Opt_AMR_WB = 0;
- move16();
- }
-
- /* select MODE1 or MODE2 */
- IF( st->Opt_AMR_WB )
- {
- st->codec_mode = MODE1;
- move16(); /**/
- }
- ELSE
- {
- SWITCH( total_brate )
- {
- case 0:
- st->codec_mode = st->last_codec_mode;
- move16();
- BREAK;
- case 2400:
- st->codec_mode = st->last_codec_mode;
- move16();
- BREAK;
- case 2800:
- st->codec_mode = MODE1;
- move16();
- BREAK;
- case 7200:
- st->codec_mode = MODE1;
- move16();
- BREAK;
- case 8000:
- st->codec_mode = MODE1;
- move16();
- BREAK;
- case 9600:
- st->codec_mode = MODE2;
- move16();
- BREAK;
- case 13200:
- st->codec_mode = MODE1;
- move16();
- BREAK;
- case 16400:
- st->codec_mode = MODE2;
- move16();
- BREAK;
- case 24400:
- st->codec_mode = MODE2;
- move16();
- BREAK;
- case 32000:
- st->codec_mode = MODE1;
- move16();
- BREAK;
- case 48000:
- st->codec_mode = MODE2;
- move16();
- BREAK;
- case 64000:
- st->codec_mode = MODE1;
- move16();
- BREAK;
- case 96000:
- st->codec_mode = MODE2;
- move16();
- BREAK;
- case 128000:
- st->codec_mode = MODE2;
- move16();
- BREAK;
- default:
- /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */
- st->codec_mode = st->last_codec_mode;
- st->bfi = 1;
- move16();
- move16();
- BREAK;
- }
- }
-
- IF( st->ini_frame == 0 )
- {
- if ( EQ_16( st->codec_mode, -1 ) )
- {
- st->codec_mode = MODE1;
- move16();
- }
- st->last_codec_mode = st->codec_mode;
- move16();
- }
-
- /* set SID/CNG type */
- IF( EQ_32( total_brate, SID_2k40 ) )
- {
- IF( EQ_16( bit0, G192_BIN0 ) )
- {
- st->cng_type = LP_CNG;
- move16();
-
- /* force MODE1 when selecting LP_CNG */
- st->codec_mode = MODE1;
- move16();
- }
- ELSE
- {
- st->cng_type = FD_CNG;
- move16();
- test();
- if ( EQ_16( st->last_codec_mode, MODE2 ) && EQ_32( st->last_total_brate, 13200 ) )
- {
- st->codec_mode = MODE1;
- move16();
- }
- }
- st->hTdCngDec->last_cng_type_fx = st->cng_type; /* CNG type switching at the first correctly received SID frame */
- move16();
- }
-
-
- return;
-}
-
-
static void dec_prm_core( Decoder_State *st )
{
Word16 n, frame_size_index, num_bits;
@@ -1319,109 +1147,115 @@ static void decision_matrix_core_dec(
* Set up MDCT core switching if indicated in the bit stream
*-------------------------------------------------------------------*/
-static void mdct_switching_dec(
+void mdct_switching_dec_fx(
Decoder_State *st /* i/o: decoder state structure */
)
{
- IF( st->Opt_AMR_WB != 0 )
- {
- return;
- }
-
- test();
- test();
- IF( EQ_32( st->total_brate, ACELP_13k20 ) || EQ_32( st->total_brate, ACELP_32k ) )
- {
- st->mdct_sw_enable = MODE1;
- move16();
- }
- ELSE IF( LE_32( ACELP_16k40, st->total_brate ) && LE_32( st->total_brate, ACELP_24k40 ) )
- {
- st->mdct_sw_enable = MODE2;
- move16();
- }
-
- test();
- test();
- IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->mdct_sw_enable, MODE1 ) )
+ if ( !st->bfi )
{
- /* Read ahead core mode signaling */
- Word16 next_bit_pos_save;
- Word16 core_save;
- Word16 bwidth_save;
-
- next_bit_pos_save = st->next_bit_pos;
- move16();
- core_save = st->core;
- move16();
- bwidth_save = st->bwidth;
- move16();
-
- decision_matrix_core_dec( st ); /* sets st->core */
+ IF( st->Opt_AMR_WB != 0 )
+ {
+ return;
+ }
- IF( EQ_16( st->core, TCX_20_CORE ) )
+ test();
+ test();
+ IF( EQ_32( st->total_brate, ACELP_13k20 ) || EQ_32( st->total_brate, ACELP_32k ) )
{
- /* Trigger TCX */
- st->codec_mode = MODE2;
+ st->mdct_sw_enable = MODE1;
move16();
- st->mdct_sw = MODE1;
+ }
+ ELSE IF( LE_32( ACELP_16k40, st->total_brate ) && LE_32( st->total_brate, ACELP_24k40 ) )
+ {
+ st->mdct_sw_enable = MODE2;
move16();
}
- ELSE
+
+ test();
+ test();
+ IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->mdct_sw_enable, MODE1 ) )
{
- /* Rewind bitstream */
- st->next_bit_pos = next_bit_pos_save;
+ /* Read ahead core mode signaling */
+ Word16 next_bit_pos_save;
+ Word16 core_save;
+ Word16 bwidth_save;
+
+ next_bit_pos_save = st->next_bit_pos;
move16();
- IF( st->bfi != 0 )
+ core_save = st->core;
+ move16();
+ bwidth_save = st->bwidth;
+ move16();
+
+ decision_matrix_core_dec( st ); /* sets st->core */
+
+ IF( EQ_16( st->core, TCX_20_CORE ) )
{
- st->core = core_save;
+ /* Trigger TCX */
+ st->codec_mode = MODE2;
move16();
- st->bwidth = bwidth_save;
+ st->mdct_sw = MODE1;
+ move16();
+ }
+ ELSE
+ {
+ /* Rewind bitstream */
+ st->next_bit_pos = next_bit_pos_save;
move16();
+ IF( st->bfi != 0 )
+ {
+ st->core = core_save;
+ move16();
+ st->bwidth = bwidth_save;
+ move16();
+ }
}
}
- }
- ELSE IF( EQ_16( st->codec_mode, MODE2 ) && EQ_16( st->mdct_sw_enable, MODE2 ) )
- {
- /* Read ahead core mode signaling */
- Word16 next_bit_pos_save;
- Word16 core_save;
- Word16 bwidth_save;
-
- next_bit_pos_save = st->next_bit_pos;
- move16();
- core_save = st->core;
- move16();
- bwidth_save = st->bwidth;
- move16();
-
- dec_prm_core( st ); /* sets st->core */
-
- IF( EQ_16( st->core, HQ_CORE ) )
+ ELSE IF( EQ_16( st->codec_mode, MODE2 ) && EQ_16( st->mdct_sw_enable, MODE2 ) )
{
- /* Trigger HQ_CORE */
- st->codec_mode = MODE1;
+ /* Read ahead core mode signaling */
+ Word16 next_bit_pos_save;
+ Word16 core_save;
+ Word16 bwidth_save;
+
+ next_bit_pos_save = st->next_bit_pos;
move16();
- st->mdct_sw = MODE2;
+ core_save = st->core;
move16();
- }
- ELSE
- {
- /* Rewind bitstream */
- st->next_bit_pos = next_bit_pos_save;
+ bwidth_save = st->bwidth;
move16();
- if ( st->bfi != 0 )
+
+ dec_prm_core( st ); /* sets st->core */
+
+ IF( EQ_16( st->core, HQ_CORE ) )
{
- st->core = core_save;
+ /* Trigger HQ_CORE */
+ st->codec_mode = MODE1;
+ move16();
+ st->mdct_sw = MODE2;
+ move16();
+ }
+ ELSE
+ {
+ /* Rewind bitstream */
+ st->next_bit_pos = next_bit_pos_save;
+ move16();
+ if ( st->bfi != 0 )
+ {
+ st->core = core_save;
+ move16();
+ }
+ /* always reset bwidth, to not interfere with BER logic */
+ st->bwidth = bwidth_save;
move16();
}
- /* always reset bwidth, to not interfere with BER logic */
- st->bwidth = bwidth_save;
- move16();
}
}
+
+ return;
}
+
/*-------------------------------------------------------------------*
* BRATE2IDX_fx()
*
@@ -1549,907 +1383,45 @@ Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 t
/*-------------------------------------------------------------------*
- * read_indices_fx()
+ * berCheck()
*
- * Read indices from an ITU-T G.192 bitstream to the buffer
- * Simulate packet losses by inserting frame erasures
+ * Check for bit errors in channel aware signalling.
*-------------------------------------------------------------------*/
-Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem */
- Decoder_State *st, /* i/o: decoder state structure */
- FILE *file, /* i : bitstream file */
- Word16 rew_flag /* i : rewind flag (rewind file after reading)*/
+static void berCheck(
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word16 *coder_type /* i/o: coder type */
)
{
- Word16 k;
- UWord16 utmp, stream[2 + MAX_BITS_PER_FRAME], *pt_stream, *bit_stream_ptr;
- Word16 num_bits;
- Word32 total_brate;
- Word32 L_tmp;
- Word16 curr_ft_good_sp, curr_ft_bad_sp;
- Word16 g192_sid_first, sid_upd_bad, sid_update;
- Word16 speech_bad, speech_lost;
- Word16 num_bits_read;
-
- st->bfi = 0;
- move16();
- st->BER_detect = 0;
- move16();
- st->mdct_sw_enable = 0;
- move16();
- st->mdct_sw = 0;
- move16();
- reset_indices_dec_fx( st );
-
- /* read the Sync Header field from the bitstream */
- /* in case rew_flag is set, read until first good frame is encountered */
+ /* In case of RF flag = 1, and valid RF packet with primary and partial copy */
test();
test();
- DO
+ IF( ( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, FB ) ) || ( GE_16( *coder_type, TRANSITION ) ) )
{
- /* read the Sync header */
- IF( NE_32( fread( &utmp, sizeof( unsigned short ), 1, file ), 1 ) )
- {
- IF( ferror( file ) )
- {
- /* error during reading */
- fprintf( stderr, "\nError reading the bitstream !" );
- exit( -1 );
- }
- ELSE
- {
- /* end of file reached */
- return 0;
- }
- }
-
- /* set the BFI indicator according the value of Sync Header */
- IF( EQ_16( utmp, SYNC_BAD_FRAME ) )
- {
- st->bfi = 1;
- move16();
- }
- ELSE
+ if ( EQ_16( st->use_partial_copy, 1 ) )
{
- st->bfi = 0;
+ st->use_partial_copy = 0;
move16();
}
- /* read the Frame Length field from the bitstream */
- IF( NE_32( fread( &num_bits, sizeof( unsigned short ), 1, file ), 1 ) )
- {
- IF( ferror( file ) )
- {
- /* error during reading */
- fprintf( stderr, "\nError reading the bitstream !" );
- exit( -1 );
- }
- ELSE
- {
- /* end of file reached */
- return 0;
- }
- }
- /* convert the frame length to total bitrate */
- total_brate = L_mult0( num_bits, 50 );
-
- /* read ITU-T G.192 serial stream of indices from file to the local buffer */
- /* Validate that the G.192 length is within the defined bit rate range
- to not allow writing past the end of the "stream" buffer */
- IF( GT_16( num_bits, MAX_BITS_PER_FRAME ) )
- {
- fprintf( stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits );
- exit( -1 );
- }
-
- /* verify that a valid num bits value is present in the G.192 file */
- /* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */
- IF( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
- {
- fprintf( stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate );
- exit( -1 );
- }
- pt_stream = stream;
-
- num_bits_read = (Word16) fread( pt_stream, sizeof( unsigned short ), num_bits, file );
+ st->bfi = 1;
+ move16();
+ st->bwidth = st->last_bwidth;
+ move16();
+ st->BER_detect = 1;
+ move16();
+ *coder_type = GENERIC;
move16();
-
- IF( NE_16( num_bits_read, num_bits ) )
- {
- fprintf( stderr, "\nError, invalid number of bits read ! Exiting ! \n" );
- exit( -1 );
- }
}
- WHILE( rew_flag && ( st->bfi || ( total_brate < 2800 ) ) );
- /* G.192 RX DTX handler*/
- IF( !rew_flag )
- {
- /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */
+ return;
+}
- /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */
- curr_ft_good_sp = 0;
- move16();
- curr_ft_bad_sp = 0;
- move16();
-
- IF( GT_32( total_brate, SID_2k40 ) )
- {
- IF( st->bfi == 0 )
- {
- curr_ft_good_sp = 1;
- move16();
- }
- ELSE
- {
- curr_ft_bad_sp = 1;
- move16();
- }
- }
- sid_update = 0;
- move16();
- sid_upd_bad = 0;
- move16();
-
- test();
- IF( total_brate == SID_1k75 || total_brate == SID_2k40 )
- {
- IF( st->bfi == 0 )
- {
- sid_update = 1;
- move16();
- }
- ELSE
- {
- sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */
- move16();
- }
- }
-
- /* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */
- /* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */
- test();
- IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) )
- {
- /* valid sid_update received, check for very risky but formally valid content */
- Word16 sum = 0;
- move16();
- FOR( k = 0; k < num_bits; ++k )
- {
- sum = add( sum, extract_l( EQ_16( pt_stream[k], G192_BIN1 ) ) ); /* check of 35 zeroes, 35 ones */
- }
- if ( sum == 0 )
- { /* all zeros */
- sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */
- move16();
- }
- }
-
- /* AMRWB 26.173 G.192 file reader (read_serial) does not declare/use SID_BAD ft,
- it declares every bad synch marked frame initially as a lost_speech frame,
- and then the RXDTX handler CNG state decides the decoding mode CNG/SPEECH.
- While In the AMRWB ETSI/3GPP format eid a CRC error in a detected SID_UPDATE frame triggers SID_UPD_BAD.
-
- Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR .
- */
- IF( sid_upd_bad )
- {
- sid_upd_bad = 0;
- move16();
- total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */
- move32();
- }
-
- g192_sid_first = 0;
- move16();
-
- test();
- test();
- test();
- if ( EQ_16( st->core, AMR_WB_CORE ) && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 )
- {
- g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */
- /*
- It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where:
- the very first SID_FIRST detection is based on a past EVS active frame
- and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO,
- , due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding
- */
- move16();
- }
-
- speech_bad = 0;
- move16();
-
- test();
- if ( GT_32( total_brate, SID_2k40 ) && st->bfi != 0 ) /* CS-type of CRC failure frame */
- {
- speech_bad = 1; /* initial assumption, CNG_state decides what to do */
- move16();
- }
-
- speech_lost = 0;
- move16();
-
- test();
- if ( total_brate == 0 && st->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */
- {
- speech_lost = 1; /* initial assumption, CNG_state decides what to do */
- move16();
- }
-
- /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame
- as this frame was never transmitted, one can not know it is good and has a a length of zero ) */
-
- IF( st->CNG_fx != 0 )
- {
- /* We were in CNG synthesis */
- if ( curr_ft_good_sp != 0 )
- {
- /* only a good speech frame makes you leave CNG synthesis */
- st->CNG_fx = 0;
- move16();
- }
- }
- ELSE
- {
- /* We were in SPEECH synthesis */
- /* only a received SID frame can make the decoder enter into CNG synthsis */
- test();
- test();
- if ( g192_sid_first || sid_update || sid_upd_bad )
- {
- st->CNG_fx = 1;
- move16();
- }
- }
-
- /* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */
- test();
- test();
- if ( ( st->CNG_fx == 0 ) && ( total_brate == 0 && st->bfi == 0 ) )
- {
- st->bfi = 1;
- move16(); /* SPEECH PLC code will now become active as in a real system */
- /* total_brate= 0 */
- }
-
- /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
- test();
- test();
- test();
- IF( ( ( st->CNG_fx != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
- ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */
- {
- st->bfi = 0;
- move16();
- total_brate = 0;
- move32();
- }
- /* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */
- test();
- st->prev_ft_speech_fx = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) );
- move16();
-
- /* st->total brate= total_brate ; updated in a good frame below */
- } /* rew_flag */
-
- /* get total bit-rate */
-#ifdef DEBUGGING
- st->bfi |= file_read_FECpattern();
-#endif
- test();
- IF( st->bfi == 0 && !rew_flag )
- {
- /* select MODE1 or MODE2 */
- decoder_selectCodec( st, total_brate, *pt_stream );
- }
-
- Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
- st->total_num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
- move16();
-
- /* in case rew_flag is set, rewind the file and return */
- /* (used in io_enc() to print out info about technologies and to initialize the codec) */
- IF( rew_flag )
- {
- rewind( file );
- st->total_brate = total_brate;
- move32();
- return 1;
- }
-
- /* GOOD frame */
- IF( st->bfi == 0 )
- {
- /* GOOD frame - convert ITU-T G.192 words to short values */
- bit_stream_ptr = st->bit_stream;
-
- FOR( k = 0; k < num_bits; ++k )
- {
- *bit_stream_ptr++ = (UWord16) EQ_32( *pt_stream++, G192_BIN1 );
- move16();
- }
-
- /*add two zero bytes for arithmetic coder flush*/
- FOR( k = 0; k < 2 * 8; ++k )
- {
- *bit_stream_ptr++ = 0;
- move16();
- }
- /*a change of the total bitrate should not be
- known to the decoder, if the received frame was lost*/
- st->total_brate = total_brate;
- move32();
-
- mdct_switching_dec( st );
- }
-#ifdef DEBUGGING
- else
- {
- bit_stream_ptr = st->bit_stream;
-
- for ( k = 0; k < num_bits + 2 * 8; ++k )
- {
- *bit_stream_ptr++ = 0;
- }
- }
-#endif
- return 1;
-}
-
-
-/*-------------------------------------------------------------------*
- * read_indices_mime_handle_dtx()
- *
- * Handle DTX for MIME and RTP_DUMP decoding.
- * Returns the actual total_brate.
- *-------------------------------------------------------------------*/
-
-static Word32 read_indices_mime_handle_dtx(
- Decoder_State *st,
- Word16 isAMRWB_IOmode,
- Word16 core_mode,
- Word32 total_brate,
- Word16 sti,
- Word16 speech_lost,
- Word16 no_data )
-{
- Word16 curr_ft_good_sp = 0;
- Word16 speech_bad = 0;
- Word16 sid_upd_bad = 0, sid_update = 0;
- Word16 amrwb_sid_first = 0; /* derived from sti SID_FIRST indicator in AMRWB payload */
- move16();
- move16();
- move16();
- move16();
- move16();
-
- /* keep st->CNG , st_bfi and total_brate updated for proper synthesis in DTX and FER */
- IF( GT_32( total_brate, SID_2k40 ) )
- {
- if ( NE_16( st->bfi, 1 ) ) /* so far derived from q bit in AMRWB/AMRWBIO cases */
- {
- curr_ft_good_sp = 1;
- move16();
- }
- }
-
- /* handle q_bit and lost_sp clash , assume worst case */
- IF( speech_lost != 0 ) /* overrides a good q_bit */
- {
- curr_ft_good_sp = 0;
- move16();
- st->bfi = 1; /* override qbit */
- move16();
- }
-
- /* now_bfi_fx has been set based on q_bit and ToC fields */
-
-
- /* SID_UPDATE check */
- test();
- IF( EQ_32( total_brate, SID_1k75 ) || EQ_32( total_brate, SID_2k40 ) )
- {
- IF( st->bfi == 0 )
- {
- /* typically from q bit */
- sid_update = 1;
- move16();
- }
- ELSE
- {
- sid_upd_bad = 1; /* may happen in saving from e.g. a CS-connection */
- move16();
- }
- }
-
- test();
- test();
- IF( isAMRWB_IOmode && total_brate == 0 && sti == 0 )
- {
- IF( st->bfi )
- {
- sid_upd_bad = 1; /* corrupt sid_first, signaled as bad sid */
- move16();
- }
- ELSE
- {
- amrwb_sid_first = 1; /* 1-sti */
- move16();
- }
- }
-
- test();
- test();
- test();
- test();
- IF( sid_upd_bad != 0 && ( ( isAMRWB_IOmode != 0 && st->Opt_AMR_WB == 0 ) || /* switch to AMRWBIO */
- ( NE_16( isAMRWB_IOmode, 1 ) && EQ_16( st->Opt_AMR_WB, 1 ) ) /* switch from AMRWBIO */
- ) )
- {
- /* do not allow a normal start of CNG synthesis if this SID(with BER or FER) is a switch to/from AMRWBIO */
- sid_upd_bad = 0; /* revert this detection due to AMRWBIO/EVS mode switch */
- move16();
- total_brate = 0;
- move32();
- no_data = 1;
- move16();
- assert( st->bfi == 1 ); /* bfi stays 1 */
- }
-
- test();
- if ( GT_32( total_brate, SID_2k40 ) && EQ_16( st->bfi, 1 ) ) /* typically from q bit */
- {
- speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */
- move16();
- }
- /* all frame types decoded */
-
- /* update CNG synthesis state */
- /* Decoder can only enter CNG-synthesis for CNG frame types (sid_upd, sid_bad, sid_first) */
- IF( st->CNG_fx != 0 )
- {
- /* We were in CNG synthesis */
- if ( curr_ft_good_sp != 0 )
- {
- /* only a good speech frame makes decoder leave CNG synthesis */
- st->CNG_fx = 0;
- move16();
- }
- }
- ELSE
- {
- /* We were in SPEECH synthesis */
- /* only a received SID frame can make the decoder enter into CNG synthesis */
- test();
- test();
- if ( amrwb_sid_first || sid_update || sid_upd_bad )
- {
- st->CNG_fx = 1;
- move16();
- }
- }
-
- /* Now modify bfi flag for the decoder's SPEECH/CNG synthesis logic */
- /* in SPEECH synthesis, make sure to activate speech plc for a received no_data frame,
- no_data frames may be injected by the network or by the dejitter buffer */
- /* modify bfi_flag to stay/move into the correct decoder PLC section */
- test();
- if ( ( st->CNG_fx == 0 ) && ( no_data != 0 ) )
- {
- /* treat no_data received in speech synthesis as SP_LOST frames, SPEECH PLC code will now become active */
- st->bfi = 1;
- move16();
- /* total_brate= 0; always zero for no_data */
- }
-
- /* in CNG */
- /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
- test();
- test();
- test();
- test();
- IF( ( st->CNG_fx != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
- sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */
- {
- st->bfi = 0; /* mark as good to not start speech PLC */
- move16();
- total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */
- move32();
- }
-
-
- /* now bfi, total_brate are set by RX-DTX handler::
- bfi==0, total_brate!=0 cng or speech pending bitrate
- bfi==0, total_brate==0 cng will continue or start(sid_first, sid_bad)
- bfi==1, total_brate!=0 speech plc
- bfi==1, total_brate==0 , speech plc
- */
-
-
- /* handle available AMRWB/AMRWBIO MIME header ToC rate-info at startup */
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->bfi, 1 ) && st->ini_frame == 0 ) &&
- ( ( st->amrwb_rfc4867_flag != 0 ) || ( st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 ) ) ) /*AMRWB ToC */
- {
- Word32 init_rate;
-
- init_rate = total_brate; /* default , may have been modified from original ToC value */
- move32();
-
- test();
- IF( speech_lost != 0 || no_data != 0 )
- {
- init_rate = ACELP_12k65; /* make sure the decoder starts up in a selected AMRWB mode */
- move32();
- }
- ELSE IF( speech_bad != 0 )
- {
- init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */
- move32();
- }
- st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */
- move32();
- st->core_brate = init_rate;
- move32();
- }
-
- return total_brate;
-}
-
-
-/*-------------------------------------------------------------------*
- * read_indices_mime_handle_sti_and_all_zero_bits()
- *
- * Handle STI and frames with all zero bits for MIME and RTP_DUMP decoding.
- *-------------------------------------------------------------------*/
-
-static void read_indices_mime_handle_sti_and_all_zero_bits(
- Decoder_State *st,
- Word32 *total_brate,
- Word16 sti )
-{
- Word16 k;
-
- IF( sti == 0 )
- {
- *total_brate = 0; /* signal received SID_FIRST as a good frame with no bits */
- move32();
- FOR( k = 0; k < 35; k++ )
- {
- st->bfi = s_or( st->bfi, st->bit_stream[k] ); /* partity check of 35 zeroes, any single 1 gives BFI */
- move16();
- }
- }
- /* all zero bit SID_update results in a valid LP filter with extremely high LP-filter-gain */
- /* all zero bits signal may be a result of CS bit errors or erronesouly injected by gateways or bad dejitter handlers */
- IF( EQ_16( sti, 1 ) )
- { /*sid_update received */
- Word16 sum = 0;
- move16();
- FOR( k = 0; k < 35; k++ )
- {
- sum = add( sum, st->bit_stream[k] ); /* check of 35 zeroes */
- }
-
- if ( sum == 0 )
- {
- st->bfi = 1; /* eventually becomes SID_UPD_BAD */
- move16();
- }
- }
-}
-
-
-/*------------------------------------------------------------------------------------------*
- * read_indices_mime()
- *
- * Read indices from MIME formatted bitstream to the buffer
- * The magic word and number of channnels should be consumed before calling this function
- *-------------------------------------------------------------------------------------------*/
-
-Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */
- Decoder_State *st, /* i/o: decoder state structure */
- FILE *file, /* i : bitstream file */
- Word16 rew_flag /* i : rewind flag (rewind file after reading) */
-)
-{
- Word16 k, isAMRWB_IOmode, cmi, core_mode = -1, qbit, sti;
- UWord8 header;
- UWord8 pFrame[( MAX_BITS_PER_FRAME + 7 ) >> 3];
- UWord8 mask = 0x80, *pt_pFrame = pFrame;
- UWord16 *bit_stream_ptr;
- Word16 num_bits;
- Word32 total_brate;
- UWord16 utmp;
- Word32 L_tmp;
- Word16 speech_lost = 0, no_data = 0;
- Word16 num_bytes_read;
-
- move16();
- move16();
- move16();
- move16();
-
- st->BER_detect = 0;
- move16();
- st->bfi = 0;
- move16();
- st->mdct_sw_enable = 0;
- move16();
- st->mdct_sw = 0;
- move16();
- reset_indices_dec_fx( st );
-
- /* read the FT Header field from the bitstream */
- IF( NE_32( fread( &header, sizeof( UWord8 ), 1, file ), 1 ) )
- {
- IF( ferror( file ) )
- {
- /* error during reading */
- fprintf( stderr, "\nError reading the bitstream !" );
- exit( -1 );
- }
- ELSE
- {
- /* end of file reached */
- return 0;
- }
- }
-
- /* init local RXDTX flags */
- sti = -1;
- move16();
-
- IF( st->amrwb_rfc4867_flag != 0 )
- {
- /* RFC 4867
- 5.3 ....
- Each stored speech frame starts with a one-octet frame header with
- the following format:
- 0 1 2 3 4 5 6 7
- +-+-+-+-+-+-+-+-+
- |P| FT |Q|P|P|
- +-+-+-+-+-+-+-+-+
- The FT field and the Q bit are defined in the same way as in
- Section 4.3.2. The P bits are padding and MUST be set to 0, and MUST be ignored. */
-
- isAMRWB_IOmode = 1;
- move16();
- qbit = s_and( shr( header, 2 ), 0x01 ); /* b2 bit (b7 is the F bit ) */
- st->bfi = !qbit;
- move16();
- core_mode = s_and( shr( header, 3 ), 0x0F ); /* b6..b3 */
- total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */
- move32();
- }
- ELSE
- {
- /*0 1 2 3 4 5 6 7 MS-bit ---> LS-bit
- +-+-+-+-+-+-+-+-+
- |H|F|E|x| brate |
- +-+-+-+-+-+-+-+-+
- where :
- "E|x| brate " is the 6 bit "FT" -field
- x is unused if E=0, (should be 0 )
- x is the q-bit if E=1, q==1(good), Q==0(bad, maybe bit errors in payload )
- H,F always 0 in RTP format.
- */
- isAMRWB_IOmode = extract_l( GT_16( s_and( header, 0x20 ), 0 ) ); /* get EVS mode-from header */ /* b2 */
- core_mode = s_and( header, 0x0F ); /* b4,b5,b6,b7 */
-
- IF( isAMRWB_IOmode )
- {
- qbit = extract_l( GT_16( s_and( header, 0x10 ), 0 ) ); /* get Q bit, valid for IO rates */ /* b3 */
- total_brate = AMRWB_IOmode2rate[core_mode];
- move32();
- }
- ELSE
- {
- qbit = 1; /* assume good q_bit for the unused EVS-mode bit, complete ToC validity checked later */
- move16();
- total_brate = PRIMARYmode2rate[core_mode];
- move32();
- }
- st->bfi = !qbit;
- move16();
- }
-
-
- /* set up RX-DTX-handler input */
- if ( EQ_16( core_mode, 14 ) )
- {
- /* SP_LOST */
- speech_lost = 1;
- move16();
- }
- if ( EQ_16( core_mode, 15 ) )
- {
- /* NO_DATA unsent CNG frame OR any frame marked or injected as no_data by e.g a signaling layer or dejitter buffer */
- no_data = 1;
- move16();
- }
-
- Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
- num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
- st->total_num_bits = num_bits;
- move16();
-
- IF( total_brate < 0 )
- {
- /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */
- fprintf( stderr, "\n Error. Illegal total bit rate (= %d) in MIME ToC header \n", total_brate );
- /* num_bits = -1; not needed as BASOP multiplication preserves sign */
- }
-
- /* Check correctness of ToC headers */
- IF( st->amrwb_rfc4867_flag == 0 )
- {
- /* EVS ToC header (FT field(b2-b7), H bit (b0), F bit (b1) , (EVS-modebit(b2)=0 unused(Qbit)(b3)==0) */
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( isAMRWB_IOmode == 0 ) && ( ( num_bits < 0 ) || ( s_and( header, 0x80 ) > 0 ) || ( s_and( header, 0x40 ) > 0 ) || s_and( header, 0x30 ) != 0x00 ) )
- {
- /* incorrect FT header */
- fprintf( stderr, "\nError in EVS FT ToC header(%02x) ! ", header );
- exit( -1 );
- }
- ELSE IF( ( isAMRWB_IOmode != 0 ) && ( ( num_bits < 0 ) || ( s_and( header, 0x80 ) > 0 ) || ( s_and( header, 0x40 ) > 0 ) ) ) /* AMRWBIO */
- {
- /* incorrect IO FT header */
- fprintf( stderr, "\nError in EVS(AMRWBIO) FT ToC header(%02x) ! ", header );
- exit( -1 );
- }
- }
- ELSE
- {
- /* legacy AMRWB ToC, is only using Padding bits which MUST be ignored */
- IF( num_bits < 0 )
- {
- /* incorrect FT header */
- fprintf( stderr, "\nError in AMRWB RFC4867 Toc(FT) header(%02x) !", header );
- exit( -1 );
- }
- }
-
- /* read serial stream of indices from file to the local buffer */
- num_bytes_read = extract_l( fread( pFrame, sizeof( UWord8 ), shr( add( num_bits, 7 ), 3 ), file ) );
- IF( NE_16( num_bytes_read, shr( add( num_bits, 7 ), 3 ) ) )
- {
- fprintf( stderr, "\nError, invalid number of bytes read ! Exiting ! \n" );
- exit( -1 );
- }
-
- /* in case rew_flag is set, rewind the file and return */
- /* (used in io_dec() to attempt print out info about technologies and to initialize the codec ) */
- IF( rew_flag )
- {
- st->total_brate = total_brate; /* used for the codec banner output */
- move32();
- test();
- test();
- IF( st->bfi == 0 && speech_lost == 0 && no_data == 0 )
- {
- decoder_selectCodec( st, total_brate, unpack_bit( &pt_pFrame, &mask ) ? G192_BIN1 : G192_BIN0 );
- }
- return 1;
- }
-
-
- /* unpack speech data */
- bit_stream_ptr = st->bit_stream;
- FOR( k = 0; k < num_bits; k++ )
- {
- IF( isAMRWB_IOmode )
- {
- st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_pFrame, &mask );
- move16();
- bit_stream_ptr++;
- }
- ELSE
- {
- *bit_stream_ptr++ = unpack_bit( &pt_pFrame, &mask );
- move16();
- }
- }
-
- /* unpack auxiliary bits */
- /* Note: the cmi bits are unpacked for demo purposes; */
- test();
- IF( isAMRWB_IOmode && EQ_32( total_brate, SID_1k75 ) )
- {
- sti = unpack_bit( &pt_pFrame, &mask );
- cmi = shl( unpack_bit( &pt_pFrame, &mask ), 3 );
- cmi = s_or( cmi, shl( unpack_bit( &pt_pFrame, &mask ), 2 ) );
- cmi = s_or( cmi, shl( unpack_bit( &pt_pFrame, &mask ), 1 ) );
- cmi = s_or( cmi, unpack_bit( &pt_pFrame, &mask ) );
-
- read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti );
- }
-
- /*add two zero bytes for arithmetic coder flush*/
- FOR( k = 0; k < 2 * 8; ++k )
- {
- *bit_stream_ptr++ = 0;
- move16();
- }
-
- /* MIME RX_DTX handler */
- IF( !rew_flag )
- {
- total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data );
- }
-
- IF( st->bfi == 0 )
- {
- /* select MODE1 or MODE2 in MIME */
- IF( *st->bit_stream )
- {
- decoder_selectCodec( st, total_brate, G192_BIN1 );
- }
- ELSE
- {
- decoder_selectCodec( st, total_brate, G192_BIN0 );
- }
- /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
- st->total_brate = total_brate;
- move32();
- mdct_switching_dec( st );
- }
- /* else{ bfi stay in past synthesis mode(SP,CNG) } */
-
- return 1;
-}
-
-/*-------------------------------------------------------------------*
- * berCheck()
- *
- * Check for bit errors in channel aware signalling.
- *-------------------------------------------------------------------*/
-
-static void berCheck(
- Decoder_State *st, /* i/o: decoder state structure */
- Word16 *coder_type /* i/o: coder type */
-)
-{
- /* In case of RF flag = 1, and valid RF packet with primary and partial copy */
- test();
- test();
- IF( ( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, FB ) ) || ( GE_16( *coder_type, TRANSITION ) ) )
- {
- if ( EQ_16( st->use_partial_copy, 1 ) )
- {
- st->use_partial_copy = 0;
- move16();
- }
-
- st->bfi = 1;
- move16();
- st->bwidth = st->last_bwidth;
- move16();
- st->BER_detect = 1;
- move16();
- *coder_type = GENERIC;
- move16();
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * getPartialCopyInfo()
- *
- * Check if the frame includes a partial copy for channel aware processing.
- *-------------------------------------------------------------------*/
+/*-------------------------------------------------------------------*
+ * getPartialCopyInfo()
+ *
+ * Check if the frame includes a partial copy for channel aware processing.
+ *-------------------------------------------------------------------*/
void getPartialCopyInfo(
Decoder_State *st, /* i/o: decoder state structure */
@@ -2769,148 +1741,6 @@ void get_NextCoderType_fx(
move16();
}
-/*-------------------------------------------------------------------*
- * read_indices_from_djb_fx()
- *
- * Read indices from the de-jitter buffer payload (works also for AMR-WB IO mode)
- *-------------------------------------------------------------------*/
-
-void read_indices_from_djb_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- UWord8 *pt_stream, /* i : bitstream file */
- Word16 num_bits, /* i : input frame length in bits */
- Word16 isAMRWB_IOmode,
- Word16 core_mode,
- Word16 qbit,
- Word16 partialframe, /* i : partial frame information */
- Word16 next_coder_type /* i : next coder type information */
-)
-{
- Word16 k;
- UWord8 mask = 0x80;
- Word16 no_data = 0;
- Word16 sti = -1;
- UWord16 *bit_stream_ptr;
- Word32 total_brate;
- Word16 speech_lost = 0;
-
- move16();
- move16();
- move16();
- move16();
-
- st->bfi = 0;
- move16();
- st->BER_detect = 0;
- move16();
- st->mdct_sw_enable = 0;
- move16();
- st->mdct_sw = 0;
- move16();
- reset_indices_dec_fx( st );
-
- st->bfi = !qbit;
- move16();
- total_brate = L_mult0( num_bits, 50 );
- st->total_num_bits = num_bits;
- move16();
-
- IF( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */
- {
- speech_lost = st->CNG_fx == 0;
- move16();
- move16();
- no_data = st->CNG_fx != 0;
- move16();
- }
-
- test();
- IF( partialframe || st->prev_use_partial_copy )
- {
- st->next_coder_type = next_coder_type;
- move16();
- }
- ELSE
- {
- st->next_coder_type = INACTIVE;
- move16();
- }
-
- if ( EQ_16( partialframe, 1 ) )
- {
- st->bfi = 2;
- move16();
- }
-
- /* unpack speech data */
- bit_stream_ptr = st->bit_stream;
- /* convert bitstream from compact bytes to short values and store it in decoder state */
- FOR( k = 0; k < num_bits; k++ )
- {
- test();
- IF( EQ_16( st->bitstreamformat, VOIP_RTPDUMP ) && isAMRWB_IOmode )
- {
- st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_stream, &mask );
- move16();
- bit_stream_ptr++;
- }
- ELSE
- {
- *bit_stream_ptr++ = unpack_bit( &pt_stream, &mask );
- move16();
- }
- }
-
- /* unpack auxiliary bits */
- test();
- IF( isAMRWB_IOmode && EQ_32( total_brate, SID_1k75 ) )
- {
- IF( EQ_16( st->bitstreamformat, VOIP_RTPDUMP ) )
- {
- /* A.2.2.1.3: AMR-WB SID_1k75 frame is followed by STI bit and CMI bits */
- sti = unpack_bit( &pt_stream, &mask );
- }
- ELSE
- {
- /* VOIP_G192_RTP does not contain STI and CMI */
- sti = 1;
- move16();
- }
- read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti );
- }
-
- /* add two zero bytes for arithmetic coder flush */
- FOR( k = 0; k < 8 * 2; ++k )
- {
- *bit_stream_ptr++ = 0;
- move16();
- }
-
- total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data );
- /* st->CNG_fx set inside */
-
- IF( NE_16( st->bfi, 1 ) )
- {
- /* select Mode 1 or Mode 2 */
- IF( *st->bit_stream )
- {
- decoder_selectCodec( st, total_brate, G192_BIN1 );
- }
- ELSE
- {
- decoder_selectCodec( st, total_brate, G192_BIN0 );
- }
-
-
- /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
- st->total_brate = total_brate;
- move32();
-
- mdct_switching_dec( st );
- }
-}
-
-
/*-------------------------------------------------------------------*
* get_indice_preview()
*
diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c
index 1907ef327628d6b60c2af3a5443ef37a1db114ba..720ee37a03584ca9e89ab0b7d4cbdf9ff37aed78 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb.c
@@ -39,7 +39,6 @@
#include "options.h"
#include
#include "stat_dec.h"
-#include "prot.h"
#include "prot_fx.h"
#include "rom_com.h"
#include "rom_com_fx.h"
@@ -400,18 +399,28 @@ void cldfbAnalysis_ts_fx(
/* folding + pre modulation of DST IV */
rr12_fx = L_sub( r1_fx, r2_fx ); // q -1
ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1
- /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
- rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
///* folding + pre modulation of DCT IV */
ir12_fx = L_add( r1_fx, r2_fx ); // q - 1
ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1
- /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
- iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
}
@@ -451,18 +460,28 @@ void cldfbAnalysis_ts_fx(
/* folding + pre modulation of DST IV */
rr12_fx = L_add( r1_fx, r2_fx ); // q - 1
ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1
- /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
- rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
/* folding + pre modulation of DCT IV */
ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1
ii12_fx = L_add( i1_fx, i2_fx ); // q - 1
- /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
- iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
}
@@ -491,8 +510,13 @@ void cldfbAnalysis_ts_fx(
FOR( k = 0; k < M2; k++ )
{
/*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
}
@@ -521,8 +545,13 @@ void cldfbAnalysis_ts_fx(
{
/* do it inplace */
/*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
- imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
- imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
}
@@ -543,8 +572,13 @@ void cldfbAnalysis_ts_fx(
/*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/
/*realBuffer[k] = rBuffer[k];
imagBuffer[k] = iBuffer[k];*/
- cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5
- imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5
+ imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5
+ imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
realBuffer_fx[k] = cplx_aux_fx;
move32();
move32();
@@ -1092,16 +1126,21 @@ void cldfbAnalysis_ts_fx_fixed_q(
return;
}
+
/*-------------------------------------------------------------------*
* cldfbSynthesis_ivas()
*
* Conduct inverse multple overlap cmplex low delay MDCT
*--------------------------------------------------------------------*/
void cldfbSynthesis_ivas_fx(
- Word32 **realBuffer_fx, /* i : real values Qx*/
- Word32 **imagBuffer_fx, /* i : imag values Qx*/
- Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/
- const Word16 samplesToProcess, /* i : number of processed samples */
+ Word32 **realBuffer_fx, /* i : real values Qx*/
+ Word32 **imagBuffer_fx, /* i : imag values Qx*/
+ Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/
+ const Word16 samplesToProcess, /* i : number of processed samples */
+ const Word16 shift, /* i : scale for state buffer */
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ const Word16 out_shift, /* i : scale for output buffer */
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */
)
{
@@ -1267,31 +1306,73 @@ void cldfbSynthesis_ivas_fx(
}
/* synthesis prototype filter */
- FOR( i = 0; i < L2; i++ )
+ IF( 0 == shift )
+ {
+ FOR( i = 0; i < L2; i++ )
+ {
+ accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[i] ), p_filter_sf ); // Qx - 1
+ accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1
+ accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1
+ accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1
+ accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1
+
+ synthesisBuffer_fx[i] = accu0;
+ move32();
+ synthesisBuffer_fx[1 * L2 + i] = accu1;
+ move32();
+ synthesisBuffer_fx[2 * L2 + i] = accu2;
+ move32();
+ synthesisBuffer_fx[3 * L2 + i] = accu3;
+ move32();
+ synthesisBuffer_fx[4 * L2 + i] = accu4;
+ move32();
+ }
+ }
+ ELSE
{
- accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[i] ), p_filter_sf ); // Qx - 1
- accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1
- accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1
- accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1
- accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1
- synthesisBuffer_fx[i] = accu0;
- move32();
- synthesisBuffer_fx[1 * L2 + i] = accu1;
- move32();
- synthesisBuffer_fx[2 * L2 + i] = accu2;
- move32();
- synthesisBuffer_fx[3 * L2 + i] = accu3;
- move32();
- synthesisBuffer_fx[4 * L2 + i] = accu4;
- move32();
+ FOR( i = 0; i < L2; i++ )
+ {
+ Word32 prod = L_shl_sat( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter_sf ), shift );
+ accu0 = Madd_32_16( synthesisBuffer_fx[i], prod, p_filter[i] ); // Qx -1 + shift
+ accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx -1 + shift
+ accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx -1 + shift
+ accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx -1 + shift
+ accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx -1 + shift
+
+ synthesisBuffer_fx[i] = accu0;
+ move32();
+ synthesisBuffer_fx[1 * L2 + i] = accu1;
+ move32();
+ synthesisBuffer_fx[2 * L2 + i] = accu2;
+ move32();
+ synthesisBuffer_fx[3 * L2 + i] = accu3;
+ move32();
+ synthesisBuffer_fx[4 * L2 + i] = accu4;
+ move32();
+ }
}
- FOR( i = 0; i < M1; i++ )
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ IF( 0 == out_shift )
{
- ptr_time_out_fx[( M1 - 1 ) - i] = synthesisBuffer_fx[4 * L2 + M1 + i];
- move32();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ FOR( i = 0; i < M1; i++ )
+ {
+ ptr_time_out_fx[( M1 - 1 ) - i] = synthesisBuffer_fx[4 * L2 + M1 + i];
+ move32();
+ }
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
}
+ ELSE
+ {
+ FOR( i = 0; i < M1; i++ )
+ {
+ ptr_time_out_fx[( M1 - 1 ) - i] = L_shl_sat( synthesisBuffer_fx[4 * L2 + M1 + i], out_shift );
+ move32();
+ }
+ }
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
ptr_time_out_fx += M1;
@@ -1306,7 +1387,6 @@ void cldfbSynthesis_ivas_fx(
return;
}
-
void configureCldfb_ivas_enc_fx(
HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
const Word32 sampling_rate /* i : sampling rate */
@@ -1365,8 +1445,8 @@ ivas_error openCldfb_ivas_fx(
HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
CLDFB_TYPE type, /* i : analysis or synthesis */
const Word32 sampling_rate, /* i : sampling rate */
- CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
-)
+ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */
+ const Word16 enc_dec ) /* i : encoder/decoder flag */
{
HANDLE_CLDFB_FILTER_BANK hs;
Word16 buf_len;
@@ -1380,95 +1460,45 @@ ivas_error openCldfb_ivas_fx(
move32();
hs->prototype = prototype;
move32();
- configureCldfb_ivas_fx( hs, sampling_rate );
- hs->memory32 = NULL;
- hs->FilterStates = NULL;
- hs->memory_length = 0;
- move16();
-
- IF( EQ_32( type, CLDFB_ANALYSIS ) )
+ IF( enc_dec == ENC )
{
- buf_len = sub( hs->p_filter_length, hs->no_channels );
+ configureCldfb_ivas_enc_fx( hs, sampling_rate );
+ hs->Q_cldfb_state = 0;
}
ELSE
{
- buf_len = hs->p_filter_length;
- move16();
- }
-
- IF( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
+ configureCldfb_ivas_fx( hs, sampling_rate );
+ hs->Q_cldfb_state = Q11;
}
-
- hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
- move16();
- hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
- move16();
- set32_fx( hs->cldfb_state_fx, 0, buf_len );
- hs->Q_cldfb_state = Q11;
move16();
- *h_cldfb = hs;
- move16();
-
- return IVAS_ERR_OK;
-}
-
-ivas_error openCldfb_ivas_enc(
- HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
- CLDFB_TYPE type, /* i : analysis or synthesis */
- const Word32 sampling_rate, /* i : sampling rate */
- CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
-)
-{
- HANDLE_CLDFB_FILTER_BANK hs;
- Word16 buf_len;
-
- IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
- }
-
- hs->type = type;
- move32();
- hs->prototype = prototype;
- move32();
-
- configureCldfb_ivas_enc_fx( hs, sampling_rate );
+ hs->memory32 = NULL;
+ hs->FilterStates = NULL;
hs->memory_length = 0;
- move32();
+ move16();
- IF( type == CLDFB_ANALYSIS )
+ IF( EQ_32( type, CLDFB_ANALYSIS ) )
{
buf_len = sub( hs->p_filter_length, hs->no_channels );
- hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
- hs->FilterStates_eg = 0;
- move16();
}
ELSE
{
buf_len = hs->p_filter_length;
move16();
- hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
- hs->FilterStates_eg = 0;
- move16();
}
- if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
+
hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
move16();
hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
move16();
set32_fx( hs->cldfb_state_fx, 0, buf_len );
- hs->Q_cldfb_state = 0;
- move16();
- set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) );
- set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );
*h_cldfb = hs;
+ move16();
return IVAS_ERR_OK;
}
@@ -1564,41 +1594,6 @@ void analysisCldfbEncoder_ivas_fx(
return;
}
-
-/*-------------------------------------------------------------------*
- * GetEnergyCldfb_ivas()
- *
- * Remove handle
- *--------------------------------------------------------------------*/
-
-void deleteCldfb_ivas(
- HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */
-)
-{
- HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb;
-
- test();
- IF( h_cldfb == NULL || *h_cldfb == NULL )
- {
- return;
- }
-
- IF( hs->cldfb_state_fx )
- {
- free( hs->cldfb_state_fx );
- }
-
- IF( hs->FilterStates )
- {
- free( hs->FilterStates );
- }
-
- free( hs );
- *h_cldfb = NULL;
-
- return;
-}
-
void deleteCldfb_ivas_fx(
HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */
)
diff --git a/lib_com/cldfb_evs.c b/lib_com/cldfb_evs.c
index d74b9b64671902f550e2b560d4b3a3992a05ee3e..c28a534d63b01c63d73249732fba395ba4311f79 100644
--- a/lib_com/cldfb_evs.c
+++ b/lib_com/cldfb_evs.c
@@ -338,7 +338,7 @@ static void calcModulationAndFolding( Word16 *rY,
}
-/* cldfbAnalysisFiltering
+/* cldfbAnalysis_fx
Parameters:
cldfbBank I/O: handle to analysis CLDFB filter struct
@@ -356,14 +356,15 @@ static void calcModulationAndFolding( Word16 *rY,
Returns:
void
*/
-void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
- Word32 **rAnalysis,
- Word32 **iAnalysis,
- CLDFB_SCALE_FACTOR *scaleFactor,
- const Word16 *timeIn, // Q(15-timeIn_e)
- const Word16 timeIn_e,
- const Word16 nTimeSlots,
- Word32 *pWorkBuffer // Qx
+void cldfbAnalysis_fx(
+ HANDLE_CLDFB_FILTER_BANK cldfbBank,
+ Word32 **rAnalysis,
+ Word32 **iAnalysis,
+ CLDFB_SCALE_FACTOR *scaleFactor,
+ const Word16 *timeIn, // Q(15-timeIn_e)
+ const Word16 timeIn_e,
+ const Word16 nTimeSlots,
+ Word32 *pWorkBuffer // Qx
)
{
@@ -610,7 +611,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
}
-/* cldfbSynthesisFiltering
+/* cldfbSynthesis_fx
Parameters:
cldfbBank I/O: handle to analysis CLDFB filter struct
@@ -629,14 +630,15 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
Returns:
void
*/
-void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
- Word32 **rAnalysis,
- Word32 **iAnalysis,
- const CLDFB_SCALE_FACTOR *scaleFactor,
- Word16 *timeOut, // Q(15-timeOut_e)
- const Word16 timeOut_e,
- const Word16 nTimeSlots,
- Word32 *pWorkBuffer // Qx
+void cldfbSynthesis_fx(
+ HANDLE_CLDFB_FILTER_BANK cldfbBank,
+ Word32 **rAnalysis,
+ Word32 **iAnalysis,
+ const CLDFB_SCALE_FACTOR *scaleFactor,
+ Word16 *timeOut, // Q(15-timeOut_e)
+ const Word16 timeOut_e,
+ const Word16 nTimeSlots,
+ Word32 *pWorkBuffer // Qx
)
{
Word16 i;
@@ -1186,20 +1188,13 @@ void analysisCldfbEncoder_fx(
}
/* perform analysis */
- cldfbAnalysisFiltering(
- st_fx->cldfbAnaEnc,
- ppBuf_Real,
- ppBuf_Imag,
- scale,
- timeIn,
- 0,
- CLDFB_NO_COL_MAX,
- workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, scale, timeIn, 0, CLDFB_NO_COL_MAX, workBuffer );
enerScale.lb_scale = negate( scale->lb_scale );
enerScale.lb_scale16 = negate( scale->lb_scale );
move16();
move16();
+
/* get 16bit respresentation */
AnalysisPostSpectrumScaling_Fx(
st_fx->cldfbAnaEnc,
diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c
deleted file mode 100644
index 494305e6f6435bf08e82e84ff48aa93390afef7d..0000000000000000000000000000000000000000
--- a/lib_com/cng_exc.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local constants
- *---------------------------------------------------------------------*/
-
-#define A2 0.2f
-#define GAIN_VAR 0.000011f
-
-
-/*-------------------------------------------------------*
- * cng_params_upd()
- *
- * update CNG parameters
- *-------------------------------------------------------*/
diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c
index 3eab0b1f5251aef2467b21caed74f9d40672a597..b314357adee7954c8797853f405db0296b5df6ee 100644
--- a/lib_com/cng_exc_fx.c
+++ b/lib_com/cng_exc_fx.c
@@ -47,7 +47,7 @@ void CNG_exc_fx(
Word16 *cng_ener_seed1,
Word16 exc3[], /*Q_exc*/
Word16 Opt_AMR_WB,
- const int16_t element_mode /* i : IVAS Element mode */
+ const Word16 element_mode /* i : IVAS Element mode */
)
{
Word16 i, tmp, tmp2, exp, exp2, Q_ener;
@@ -295,10 +295,9 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
/* calculate the spectrum of random excitation signal */
Copy( exc2, fft_io, L_frame );
- Word16 Q_new_inp, mem_decim_size; // TO be removed
IF( EQ_16( L_frame, L_FRAME16k ) )
{
- modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0, &Q_new_inp, &mem_decim_size );
+ modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 );
}
/* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */
@@ -411,7 +410,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
IF( EQ_16( L_frame, L_FRAME16k ) )
{
- modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0, &Q_new_inp, &mem_decim_size );
+ modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 );
}
/* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */
@@ -1166,7 +1165,7 @@ void cng_params_upd_ivas_fx(
L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_exc+1 */
L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */
tmp = add( add( Q_exc, Q_exc ), 1 );
- sp[i] = L_shr( L_tmp, sub( tmp, 6 ) );
+ sp[i] = L_shr_o( L_tmp, sub( tmp, 6 ), &Overflow );
move32(); /* Q6 */
ptR++;
ptI--;
diff --git a/lib_com/cnst.h b/lib_com/cnst.h
index 26903f525c1b76bb76389ec68d07b0cb6ba155b4..1cc1a8ffefaa48c4b964a11b599e1da102b41fc2 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -239,7 +239,7 @@ enum{
#define L_FRAME48k_EXT 1200 /* Extended MDCT frame size in samples at 48kHz */
/* Conversion of ns to samples for a given sampling frequency */
-#define NS2SA( fs, x ) ( int16_t )( ( ( ( int32_t )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L )
+#define NS2SA( fs, x ) ( Word16 )( ( ( ( Word32 )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L )
#define NRG_CHANGE_E 8
#define AVG_FLAT_E 8
#define ACTIVE_FRAME 0xFF
@@ -932,6 +932,8 @@ typedef enum
#define GAIN_PRED_ORDER 4 /* Gain quantization - prediction order for gain quantizer (only for AMR-WB IO mode) */
#define MEAN_ENER 30 /* Gain quantization - average innovation energy */
+#define DTX_THR 5 /* DTX - lp_noise threshold for DTX at higher bitrates */
+
#define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */
#define CNG_ISF_FACT 0.9f /* CNG & DTX - CNG spectral envelope smoothing factor */
#define STEP_AMR_WB_SID 2.625f /* CNG & DTX - CNG energy quantization step */
@@ -1168,7 +1170,6 @@ enum
#define NBITS_NOISE_FILL_LEVEL 3 /* Number of bits used for coding noise filling level for each range */
#define NF_GAIN_BITS ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL )
#define MIN_NOISE_FILLING_HOLE 8
-#define HOLE_SIZE_FROM_LTP_FLT( gain ) ( 4 + ( int16_t )( 2.0f * gain * ( 4.0f / 0.625f ) ) )
#define HOLE_SIZE_FROM_LTP( gain ) (add(4, extract_h(L_shr(L_mult0(gain, 0x6666), 10)))) /* gain (Q15), 0x6666 = 2.0*(4.0/0.625) (4Q11) */
#define HOLE_SIZE_FROM_LTP32( gain ) (add(4, extract_h(L_shr(Mpy_32_32(gain, 0x66666667), 11)))) /* gain (Q31), 0x66666667 = 2.0*(4.0/0.625) (4Q27) */
@@ -1465,7 +1466,7 @@ enum
#define cbitsnew 16
#define stat_bitsnew 14
-#define ari_q4new ( ( (int32_t) 1 << cbitsnew ) - 1 )
+#define ari_q4new ( ( (Word32) 1 << cbitsnew ) - 1 )
#define ari_q1new ( ari_q4new / 4 + 1 )
#define ari_q2new ( 2 * ari_q1new )
#define ari_q3new ( 3 * ari_q1new )
@@ -1947,7 +1948,6 @@ typedef enum _DCTTYPE
#define N_SMC_MIXTURES 6 /* number of mixtures */
#define N_PCA_COEF 12 /* number of PCA components */
#define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 ))
-#define SMC_ST_MEAN_FACT 0.5 /* forgetting factor of short-term IIR mean filter */
#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */
#define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */
diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c
index f6da34b5583d96ee20611780db70092f10014bfa..1ebc2829c15493506950bd608ca397162826847c 100644
--- a/lib_com/codec_tcx_common.c
+++ b/lib_com/codec_tcx_common.c
@@ -6,7 +6,6 @@
#include
#include
#include "options.h"
-#include "prot.h"
#include "prot_fx.h"
#include "basop_util.h"
#include "rom_basop_util.h"
diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h
index 553a34f56ebd9543b189cc79f33150fef1358883..bc6fd4f1af6f28146c62d4a3d163a421a83fb1e4 100644
--- a/lib_com/common_api_types.h
+++ b/lib_com/common_api_types.h
@@ -108,9 +108,9 @@ typedef enum _IVAS_ENC_FEC_INDICATOR
typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG
{
- int16_t channelAwareModeEnabled;
+ Word16 channelAwareModeEnabled;
IVAS_ENC_FEC_INDICATOR fec_indicator;
- int16_t fec_offset;
+ Word16 fec_offset;
} IVAS_ENC_CHANNEL_AWARE_CONFIG;
@@ -130,7 +130,7 @@ typedef struct _IVAS_ISM_METADATA
float gainFactor;
float yaw;
float pitch;
- int16_t non_diegetic_flag;
+ Word16 non_diegetic_flag;
} IVAS_ISM_METADATA;
@@ -183,29 +183,29 @@ typedef struct ivas_LS_setup_custom IVAS_LSSETUP_CUSTOM_STRUCT;
typedef struct _IVAS_LS_CUSTOM_LAYOUT
{
- int16_t num_spk;
+ Word16 num_spk;
float azimuth[IVAS_MAX_OUTPUT_CHANNELS];
float elevation[IVAS_MAX_OUTPUT_CHANNELS];
Word32 azimuth_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22
Word32 elevation_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22
- int16_t num_lfe;
- int16_t lfe_idx[IVAS_MAX_OUTPUT_CHANNELS];
+ Word16 num_lfe;
+ Word16 lfe_idx[IVAS_MAX_OUTPUT_CHANNELS];
} IVAS_CUSTOM_LS_DATA;
typedef struct _IVAS_JBM_TRACE_DATA
{
- uint32_t systemTimestamp_ms;
- uint16_t extBufferedSamples;
- uint16_t lastDecodedWasActive;
- int32_t output_Fs;
- int16_t dataUnit_flag;
- uint16_t sequenceNumber;
- uint32_t timeStamp;
- uint32_t rcvTime;
-
- int16_t partial_frame;
- int16_t partialCopyOffset;
+ UWord32 systemTimestamp_ms;
+ UWord16 extBufferedSamples;
+ UWord16 lastDecodedWasActive;
+ Word32 output_Fs;
+ Word16 dataUnit_flag;
+ UWord16 sequenceNumber;
+ UWord32 timeStamp;
+ UWord32 rcvTime;
+
+ Word16 partial_frame;
+ Word16 partialCopyOffset;
} IVAS_JBM_TRACE_DATA;
@@ -217,8 +217,8 @@ typedef struct _IVAS_JBM_TRACE_DATA
typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
{
- int16_t override;
- int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */
+ Word16 override;
+ Word16 nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */
float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */
float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */
float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */
@@ -231,12 +231,12 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
Word32 inputPreDelay_fx; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ /* Assumed Q-27*/
/* early reflections */
- int16_t use_er; /* ER activation flag */
- int32_t lowComplexity; /* Low complexity ER flag */
- IVAS_VECTOR3 dimensions; /* Room dimensions [m] */
- float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */
- IVAS_VECTOR3 ListenerOrigin; /* Listener origin */
- int32_t AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */
+ Word16 use_er; /* ER activation flag */
+ Word32 lowComplexity; /* Low complexity ER flag */
+ IVAS_VECTOR3 dimensions; /* Room dimensions [m] */
+ float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */
+ IVAS_VECTOR3 ListenerOrigin; /* Listener origin */
+ Word32 AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */
} IVAS_ROOM_ACOUSTICS_CONFIG_DATA;
diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c
index 8d360c6a33ce404a2f0c4d7881bffb361206ba1e..f0ee8efd8d12c038c78487a8f39ba71dc21a3b9c 100644
--- a/lib_com/core_com_config.c
+++ b/lib_com/core_com_config.c
@@ -38,10 +38,8 @@
#include
#include "options.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#define FSCALE_DENOM_BY_12800_Q15 1311
@@ -551,63 +549,6 @@ int16_t sr2fscale(
return (int16_t) ( ( FSCALE_DENOM * sr_core ) / 12800 );
}
-/*-------------------------------------------------------------------*
- * getCoreSamplerateMode2_flt()
- *
- *
- *-------------------------------------------------------------------*/
-
-int32_t getCoreSamplerateMode2_flt(
- const int16_t element_mode, /* i : IVAS element mode */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
- const int16_t rf_mode, /* i : flag to signal the RF mode */
- const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */
-)
-{
- int32_t sr_core = 0;
-
- if ( bwidth == NB )
- {
- sr_core = INT_FS_12k8;
- }
- else if ( element_mode == EVS_MONO && ( ( bwidth == WB && total_brate < ACELP_13k20 ) || ( bwidth == SWB && total_brate <= ACELP_13k20 ) || ( rf_mode == 1 ) ) )
- {
- sr_core = INT_FS_12k8;
- }
- else if ( element_mode > EVS_MONO && flag_ACELP16k == 0 )
- {
- sr_core = INT_FS_12k8;
- }
- else if ( bwidth == WB || ( bwidth == SWB && total_brate <= ACELP_32k ) || ( bwidth == FB && total_brate <= ACELP_32k ) )
- {
- sr_core = INT_FS_16k;
- }
- else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE && element_mode == IVAS_SCE && !is_ism_format )
- {
- sr_core = INT_FS_16k;
- }
- else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE_ISM && element_mode == IVAS_SCE && is_ism_format )
- {
- sr_core = INT_FS_16k;
- }
- else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE && element_mode == IVAS_SCE && is_ism_format )
- {
- sr_core = 25600;
- }
- else if ( ( ( bwidth == SWB || bwidth == FB ) && element_mode == EVS_MONO && total_brate <= HQ_64k ) || ( element_mode > IVAS_SCE && ( ( bwidth == SWB && total_brate <= IVAS_96k ) || ( bwidth == FB && total_brate <= IVAS_96k ) ) ) )
- {
- sr_core = 25600;
- }
- else if ( bwidth == SWB || bwidth == FB )
- {
- sr_core = 32000;
- }
-
- return sr_core;
-}
-
Word32 getCoreSamplerateMode2(
const Word16 element_mode, /* i : IVAS element mode Q0*/
const Word32 total_brate, /* i : total bitrate Q0*/
@@ -1235,8 +1176,8 @@ void init_tcx_window_cfg_fx(
}
/*Mid-OLA*/
/*compute minimum length for "half" window: lookahead - 5ms. It must be also multiple of 2*/
- hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_FX2( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); /*Q0*/
- hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_FX2( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); /*Q0*/
+ hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); /*Q0*/
+ hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); /*Q0*/
move16();
move16();
assert( GT_16( hTcxCfg->tcx_mdct_window_half_length, 16 ) && "Half window can not be large enough!" );
diff --git a/lib_com/deemph.c b/lib_com/deemph.c
index b2b43cf723086f91f455c975a0db37760bfbca6a..9bc20cb6f6892b86fe023ff163fa8272ec9cc7bb 100644
--- a/lib_com/deemph.c
+++ b/lib_com/deemph.c
@@ -36,32 +36,28 @@
#include
#include "options.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
void deemph_fx_32(
- Word16 shift, /*scaled output*/
Word32 *signal, /* i/o: signal Qx*/
const Word16 mu, /* i : deemphasis factor Q15*/
const Word16 L, /* i : vector size */
- Word32 *mem /* i/o: memory (y[-1]) Qx+shift*/
+ Word32 *mem /* i/o: memory (y[-1]) Qx*/
)
{
Word16 i;
- signal[0] = L_add( signal[0], Mpy_32_16_1( ( *mem ), mu ) ); /*Qx*/
+ signal[0] = Madd_32_16( signal[0], *mem, mu ); // Qx
move32();
FOR( i = 1; i < L; i++ )
{
- signal[i] = L_add( signal[i], Mpy_32_16_1( signal[i - 1], mu ) ); /*Qx*/
- signal[i] = L_shl( signal[i], shift ); /*Qx+shift*/
- move32();
+ signal[i] = Madd_32_16( signal[i], signal[i - 1], mu ); // Qx
move32();
}
- *mem = signal[L - 1]; /*Qx+shift*/
+ *mem = signal[L - 1]; // Qx
move32();
return;
diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c
index 9e6c450cd3b2dc11b0543e41de400afdd67b1145..edccca07400e2758d17230e2030c91929269027f 100644
--- a/lib_com/delay_comp.c
+++ b/lib_com/delay_comp.c
@@ -36,10 +36,9 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/*--------------------------------------------------------------------------
* get_delay()
diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c
index ba0973f97ec04508dda0ac2f6132ad3ac562c0cd..3b16773657ca881ea1c5bf7c555638788ae9fca8 100644
--- a/lib_com/disclaimer.c
+++ b/lib_com/disclaimer.c
@@ -36,7 +36,7 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#define WMC_TOOL_SKIP
@@ -44,11 +44,7 @@ int16_t print_disclaimer( FILE *fPtr )
{
fprintf( fPtr, "\n==================================================================================================\n" );
-#ifdef FIX_DISCLAIMER
fprintf( fPtr, " IVAS Codec BASOP Baseline\n" );
-#else
- fprintf( fPtr, " IVAS Codec Baseline\n" );
-#endif
fprintf( fPtr, " \n" );
fprintf( fPtr, " Based on EVS Codec (Floating Point) 3GPP TS26.443 Nov 04, 2021,\n" );
fprintf( fPtr, " Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0\n" );
diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c
index 8d77da13a7eb7df052bb309302e7f19bdef81432..1b303d2856fda4a014caf1cee1775de7064e2294 100644
--- a/lib_com/edct_fx.c
+++ b/lib_com/edct_fx.c
@@ -395,9 +395,7 @@ void edct_16fx(
Word16 Len2, i2;
const Word16 *px, *pt;
Word16 *py;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) element_mode;
-#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow;
Overflow = 0;
@@ -592,11 +590,12 @@ void edxt_fx(
const UWord16 synthesis /* i : nonzero for inverse Q0*/
)
{
- Word16 k, m, fac;
+ Word16 k, m, fac, hdrm, tmp = 0;
const Word16 *cosPtr, *sinPtr;
Word16 n;
n = 0;
move16();
+ move16();
cosPtr = NULL;
sinPtr = NULL;
IF( EQ_16( length, 512 ) )
@@ -735,7 +734,23 @@ void edxt_fx(
IF( EQ_16( length, 512 ) )
{
+ /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */
+ hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) );
+ IF( LT_16( hdrm, 4 ) )
+ {
+ tmp = sub( hdrm, 4 );
+ scale_sig32( re, 512, tmp );
+ scale_sig32( im, 512, tmp );
+ }
+
DoRTFTn_fx( re, im, 512 );
+
+ IF( LT_16( hdrm, 4 ) )
+ {
+ tmp = negate( tmp );
+ scale_sig32( re, 512, tmp );
+ scale_sig32( im, 512, tmp );
+ }
}
ELSE /* fft() doesn't support 512 */
{
@@ -831,7 +846,23 @@ void edxt_fx(
IF( EQ_16( length, 512 ) )
{
+ /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */
+ hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) );
+ IF( LT_16( hdrm, 4 ) )
+ {
+ tmp = sub( hdrm, 4 );
+ scale_sig32( re, 512, tmp );
+ scale_sig32( im, 512, tmp );
+ }
+
DoRTFTn_fx( re, im, 512 );
+
+ IF( LT_16( hdrm, 4 ) )
+ {
+ tmp = negate( tmp );
+ scale_sig32( re, 512, tmp );
+ scale_sig32( im, 512, tmp );
+ }
}
ELSE /* fft() doesn't support 512 */
{
diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c
index 81fb78262435c66a23d564dc26f15444b91bf27a..5c99cdfa5e27692d9373f9e5bec6e1b046f8b380 100644
--- a/lib_com/enr_1_az.c
+++ b/lib_com/enr_1_az.c
@@ -37,9 +37,8 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */
diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c
index 18520e188655666eb58e0a9ef12e83b364be5c1f..5a83dbe5fa8af935aa151a8fdb7d87738100c789 100644
--- a/lib_com/env_adj.c
+++ b/lib_com/env_adj.c
@@ -38,9 +38,8 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
/*--------------------------------------------------------------------------*
* env_adj()
diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c
index b80fd0a8bddfbcee88da6ec12e1600dd9cf635dd..a3140b4e498beb79ffa011af6baa60bbeb0a2bad 100644
--- a/lib_com/env_stab.c
+++ b/lib_com/env_stab.c
@@ -39,11 +39,10 @@
#include "options.h"
#include
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
#include "stl.h"
-#include "prot_fx.h"
/*--------------------------------------------------------------------------*
* Local constants
*--------------------------------------------------------------------------*/
diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c
index 8c6ec265fca667c94303d50eff38b3d3486f36f1..829bef5f40f99a7245b65102c1f3aad4f685aa7d 100644
--- a/lib_com/env_stab_trans.c
+++ b/lib_com/env_stab_trans.c
@@ -38,10 +38,9 @@
#include "options.h"
#include
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/*--------------------------------------------------------------------------*
* env_stab_transient_detect()
*
diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c
index 138b8c1bc082d6d0b0b4db78e771cc1115c46458..4ff9c6c1129555fe39b5ea34e4200f9afe451741 100644
--- a/lib_com/est_tilt_fx.c
+++ b/lib_com/est_tilt_fx.c
@@ -40,18 +40,12 @@ Word16 est_tilt_fx( /* o : tilt of the code
const Word32 gain_code, /* i : algebraic code gain Q16 */
Word16 *voice_fac, /* o : voicing factor Q15 */
const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
-#ifdef ADD_LRTD
- ,
- const Word16 L_subfr /* i : Sub frame length */
-#endif
)
{
Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
Word32 L_tmp;
Word16 tilt_code;
-#ifdef ADD_LRTD
- PMT( "FIX POINT NEED to be adapted for 16 kHz frame length " )
-#endif
+
ener1 = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp1 ) );
exp1 = sub( exp1, add( Q_exc, Q_exc ) );
L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */
@@ -117,26 +111,23 @@ Word16 est_tilt_fx( /* o : tilt of the code
/* RETURN ARGUMENTS : */
/* _ (Word16) tolt_code : tilt of the code Q15 */
/*=======================================================================*/
-Word16 est_tilt_ivas_fx( /* o : tilt of the code Q15 */
- const Word16 *exc, /* i : adaptive excitation vector Qx */
- const Word16 gain_pit, /* i : adaptive gain Q14 */
- const Word16 *code, /* i : algebraic excitation vector Q9 */
- const Word32 gain_code, /* i : algebraic code gain Q16 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
-#if 1 // def ADD_LRTD
- ,
- const Word16 L_subfr, /* i : Sub frame length */
- const Word16 flag_tilt /* i : flag for special tilt */
-#endif
+
+/* o : tilt of the code Q15 */
+Word16 est_tilt_ivas_fx(
+ const Word16 *exc, /* i : adaptive excitation vector Qx */
+ const Word16 gain_pit, /* i : adaptive gain Q14 */
+ const Word16 *code, /* i : algebraic excitation vector Q9 */
+ const Word32 gain_code, /* i : algebraic code gain Q16 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */
+ const Word16 L_subfr, /* i : Sub frame length */
+ const Word16 flag_tilt /* i : flag for special tilt */
)
{
Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
Word32 L_tmp;
Word16 tilt_code;
-#ifdef ADD_LRTD
- PMT( "FIX POINT NEED to be adapted for 16 kHz frame length " )
-#endif
+
ener1 = extract_h( Dot_product12( exc, exc, L_subfr, &exp1 ) );
exp1 = sub( exp1, add( Q_exc, Q_exc ) );
L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */
diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c
index f4468bd0b7107909f4d29adb81472267ff836aa8..78809ed2c6a0dd5a4ca9ba595896388b03106c75 100644
--- a/lib_com/fd_cng_com_fx.c
+++ b/lib_com/fd_cng_com_fx.c
@@ -12,7 +12,6 @@
#include "prot_fx.h"
#include "prot_fx_enc.h"
#include "ivas_prot_fx.h"
-#include "prot.h"
#define FFT_SCALING_512 1073741824 // Q22
#define FFT_SCALING_640 1342177280 // Q22
@@ -566,11 +565,6 @@ void minimum_statistics(
Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */
Word16 *msPeriodogBufPtr, /* i/o: Counter */
HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
-#ifdef IVAS_CODE_CNG
- ,
- const Word16 enc_dec, /* i : encoder/decoder indicator */
- const Word16 element_mode /* i : IVAS element mode type */
-#endif
)
{
Word16 i, j, k, s, s1, s2, s3;
diff --git a/lib_com/fft.c b/lib_com/fft.c
index 352a24be9f15eef4afe81bb41463b90651e525b4..e262f3909f179ea67b91c160866b1f62cd2b411a 100644
--- a/lib_com/fft.c
+++ b/lib_com/fft.c
@@ -39,7 +39,7 @@
#include "options.h"
#include
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/fft_evs.c b/lib_com/fft_evs.c
index e53404f0b7f4a8d0cdc9ed405d74f91f119a51c2..94c2dea8ff0a7df4fc62fb898eb379e5d2d31a79 100644
--- a/lib_com/fft_evs.c
+++ b/lib_com/fft_evs.c
@@ -505,7 +505,7 @@ static void fft15_with_cmplx_data( cmplx *inp_data /*Qx*/ )
*/
void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale )
{
- int i;
+ Word16 i;
if ( s == 2 )
{
fft16_with_cmplx_data( (cmplx *) re, bScale );
diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c
index 1b095e34620b59ece817572a2b5bc9895222ff60..31b11a9ea889f30a00fed73222a95cc33240856f 100644
--- a/lib_com/fft_fx.c
+++ b/lib_com/fft_fx.c
@@ -44,7 +44,7 @@
#include "options.h"
#include
#include "cnst.h"
-// #include "prot.h"
+// #include "prot_fx.h"
#include "prot_fx.h"
//#include "cnst_fx.h"
#include "rom_com.h"
@@ -4727,6 +4727,16 @@ static void fft_len16(
cmplx t[4];
cmplx y[16];
+#ifdef OPT_STEREO_32KBPS_V1
+ s[0] = x[0]; // Qx
+ move64();
+ s[1] = x[4]; // Qx
+ move64();
+ s[2] = x[8]; // Qx
+ move64();
+ s[3] = x[12]; // Qx
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_shr( x[0], SCALEFACTOR16 ); // Qx
move64();
s[1] = CL_shr( x[4], SCALEFACTOR16 ); // Qx
@@ -4735,6 +4745,7 @@ static void fft_len16(
move64();
s[3] = CL_shr( x[12], SCALEFACTOR16 ); // Qx
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
t[0] = CL_add( s[0], s[2] );
move64();
@@ -4754,6 +4765,16 @@ static void fft_len16(
y[3] = CL_add( t[1], t[3] );
move64();
+#ifdef OPT_STEREO_32KBPS_V1
+ s[0] = x[1]; // Qx
+ move64();
+ s[1] = x[5]; // Qx
+ move64();
+ s[2] = x[9]; // Qx
+ move64();
+ s[3] = x[13]; // Qx
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_shr( x[1], SCALEFACTOR16 ); // Qx
move64();
s[1] = CL_shr( x[5], SCALEFACTOR16 ); // Qx
@@ -4762,6 +4783,7 @@ static void fft_len16(
move64();
s[3] = CL_shr( x[13], SCALEFACTOR16 ); // Qx
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
t[0] = CL_add( s[0], s[2] );
move64();
@@ -4781,6 +4803,16 @@ static void fft_len16(
y[7] = CL_add( t[1], t[3] );
move64();
+#ifdef OPT_STEREO_32KBPS_V1
+ s[0] = x[2]; // Qx
+ move64();
+ s[1] = x[6]; // Qx
+ move64();
+ s[2] = x[10]; // Qx
+ move64();
+ s[3] = x[14]; // Qx
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_shr( x[2], SCALEFACTOR16 ); // Qx
move64();
s[1] = CL_shr( x[6], SCALEFACTOR16 ); // Qx
@@ -4789,6 +4821,7 @@ static void fft_len16(
move64();
s[3] = CL_shr( x[14], SCALEFACTOR16 ); // Qx
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
t[0] = CL_add( s[0], s[2] );
move64();
@@ -4810,6 +4843,16 @@ static void fft_len16(
y[11] = CL_add( t[1], t[3] );
move64();
+#ifdef OPT_STEREO_32KBPS_V1
+ s[0] = x[3]; // Qx
+ move64();
+ s[1] = x[7]; // Qx
+ move64();
+ s[2] = x[11]; // Qx
+ move64();
+ s[3] = x[15]; // Qx
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_shr( x[3], SCALEFACTOR16 ); // Qx
move64();
s[1] = CL_shr( x[7], SCALEFACTOR16 ); // Qx
@@ -4818,6 +4861,7 @@ static void fft_len16(
move64();
s[3] = CL_shr( x[15], SCALEFACTOR16 ); // Qx
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
t[0] = CL_add( s[0], s[2] );
move64();
@@ -4978,6 +5022,18 @@ static void fft_len20_fx(
cmplx tt[4];
cmplx y[20];
+#ifdef OPT_STEREO_32KBPS_V1
+ xx[0] = x[0]; // Qx
+ move64();
+ xx[1] = x[16]; // Qx
+ move64();
+ xx[2] = x[12]; // Qx
+ move64();
+ xx[3] = x[8]; // Qx
+ move64();
+ xx[4] = x[4]; // Qx
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
xx[0] = CL_shr( x[0], SCALEFACTOR20 ); // Qx
move64();
xx[1] = CL_shr( x[16], SCALEFACTOR20 ); // Qx
@@ -4988,6 +5044,7 @@ static void fft_len20_fx(
move64();
xx[4] = CL_shr( x[4], SCALEFACTOR20 ); // Qx
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_add( xx[1], xx[4] );
move64();
@@ -5023,6 +5080,18 @@ static void fft_len20_fx(
y[12] = CL_msu_j( s[2], s[3] );
move64();
+#ifdef OPT_STEREO_32KBPS_V1
+ xx[0] = x[5];
+ move64();
+ xx[1] = x[1];
+ move64();
+ xx[2] = x[17];
+ move64();
+ xx[3] = x[13];
+ move64();
+ xx[4] = x[9];
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
xx[0] = CL_shr( x[5], SCALEFACTOR20 );
move64();
xx[1] = CL_shr( x[1], SCALEFACTOR20 );
@@ -5033,6 +5102,7 @@ static void fft_len20_fx(
move64();
xx[4] = CL_shr( x[9], SCALEFACTOR20 );
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_add( xx[1], xx[4] );
move64();
@@ -5068,6 +5138,18 @@ static void fft_len20_fx(
y[13] = CL_msu_j( s[2], s[3] );
move64();
+#ifdef OPT_STEREO_32KBPS_V1
+ xx[0] = x[10];
+ move64();
+ xx[1] = x[6];
+ move64();
+ xx[2] = x[2];
+ move64();
+ xx[3] = x[18];
+ move64();
+ xx[4] = x[14];
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
xx[0] = CL_shr( x[10], SCALEFACTOR20 );
move64();
xx[1] = CL_shr( x[6], SCALEFACTOR20 );
@@ -5078,6 +5160,7 @@ static void fft_len20_fx(
move64();
xx[4] = CL_shr( x[14], SCALEFACTOR20 );
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_add( xx[1], xx[4] );
move64();
@@ -5113,6 +5196,18 @@ static void fft_len20_fx(
y[14] = CL_msu_j( s[2], s[3] );
move64();
+#ifdef OPT_STEREO_32KBPS_V1
+ xx[0] = x[15];
+ move64();
+ xx[1] = x[11];
+ move64();
+ xx[2] = x[7];
+ move64();
+ xx[3] = x[3];
+ move64();
+ xx[4] = x[19];
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
xx[0] = CL_shr( x[15], SCALEFACTOR20 );
move64();
xx[1] = CL_shr( x[11], SCALEFACTOR20 );
@@ -5123,6 +5218,7 @@ static void fft_len20_fx(
move64();
xx[4] = CL_shr( x[19], SCALEFACTOR20 );
move64();
+#endif /* OPT_STEREO_32KBPS_V1 */
s[0] = CL_add( xx[1], xx[4] );
move64();
@@ -6501,6 +6597,239 @@ static void fft_lenN(
cmplx s[8];
cmplx y[8];
+#ifdef OPT_STEREO_32KBPS_V1
+ y[1] = xx[1 * dim1];
+ move64();
+ y[2] = xx[2 * dim1];
+ move64();
+ y[3] = xx[3 * dim1];
+ move64();
+ y[4] = xx[4 * dim1];
+ move64();
+ y[5] = xx[5 * dim1];
+ move64();
+ y[6] = xx[6 * dim1];
+ move64();
+ y[7] = xx[7 * dim1];
+ move64();
+
+ test();
+ test();
+ IF( EQ_16( dim1, 8 ) || EQ_16( dim1, 16 ) || EQ_16( dim1, 32 ) )
+ {
+ FOR( i = 0; i < dim1; i++ )
+ {
+ {
+ y[0] = xx[i];
+ move64();
+ };
+ IF( i > 0 )
+ {
+ {
+ y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ }
+
+ t[0] = CL_add( y[0], y[4] );
+ move64();
+ t[1] = CL_sub( y[0], y[4] );
+ move64();
+ t[2] = CL_add( y[1], y[5] );
+ move64();
+ t[3] = CL_sub( y[1], y[5] );
+ move64();
+ t[4] = CL_add( y[2], y[6] );
+ move64();
+ t[5] = CL_sub( y[2], y[6] );
+ move64();
+ t[6] = CL_add( y[3], y[7] );
+ move64();
+ t[7] = CL_sub( y[3], y[7] );
+ move64();
+
+ s[0] = CL_add( t[0], t[4] );
+ move64();
+ s[2] = CL_sub( t[0], t[4] );
+ move64();
+ s[4] = CL_mac_j( t[1], t[5] );
+ move64();
+ s[5] = CL_msu_j( t[1], t[5] );
+ move64();
+ s[1] = CL_add( t[2], t[6] );
+ move64();
+ s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
+
+ t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
+ t[1] = CL_sub( t[3], t[7] );
+ move64();
+
+ s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx
+ move64();
+ s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx
+ move64();
+ s[7] = CL_conjugate( s[7] );
+ move64();
+
+ x[i] = CL_add( s[0], s[1] );
+ move64();
+ x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] );
+ move64();
+ x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] );
+ move64();
+ x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] );
+ move64();
+ x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] );
+ move64();
+ x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] );
+ move64();
+ x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] );
+ move64();
+ x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] );
+ move64();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < dim1; i++ )
+ {
+ {
+ y[0] = xx[i];
+ move64();
+ };
+ IF( i > 0 )
+ {
+ {
+ y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ {
+ y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) - Woff )] ),
+ CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx
+ move64();
+ };
+ }
+
+ t[0] = CL_add( y[0], y[4] );
+ move64();
+ t[1] = CL_sub( y[0], y[4] );
+ move64();
+ t[2] = CL_add( y[1], y[5] );
+ move64();
+ t[3] = CL_sub( y[1], y[5] );
+ move64();
+ t[4] = CL_add( y[2], y[6] );
+ move64();
+ t[5] = CL_sub( y[2], y[6] );
+ move64();
+ t[6] = CL_add( y[3], y[7] );
+ move64();
+ t[7] = CL_sub( y[3], y[7] );
+ move64();
+
+ s[0] = CL_add( t[0], t[4] );
+ move64();
+ s[2] = CL_sub( t[0], t[4] );
+ move64();
+ s[4] = CL_mac_j( t[1], t[5] );
+ move64();
+ s[5] = CL_msu_j( t[1], t[5] );
+ move64();
+ s[1] = CL_add( t[2], t[6] );
+ move64();
+ s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
+
+ t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
+ t[1] = CL_sub( t[3], t[7] );
+ move64();
+
+ s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx
+ move64();
+ s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx
+ move64();
+ s[7] = CL_conjugate( s[7] );
+ move64();
+
+ x[i] = CL_add( s[0], s[1] );
+ move64();
+ x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] );
+ move64();
+ x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] );
+ move64();
+ x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] );
+ move64();
+ x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] );
+ move64();
+ x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] );
+ move64();
+ x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] );
+ move64();
+ x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] );
+ move64();
+ }
+ }
+#else /* OPT_STEREO_32KBPS_V1 */
test();
test();
test();
@@ -6781,6 +7110,7 @@ static void fft_lenN(
move64();
}
}
+#endif /* OPT_STEREO_32KBPS_V1 */
BREAK;
}
@@ -7173,7 +7503,11 @@ void rfft_fx(
move32();
x[( length - ( i << 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 /*0.5.Q15*/ );
move32();
+#ifdef OPT_STEREO_32KBPS_V1
+ x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_add( t2, t4 ), -16384 /*0.5.Q15*/ );
+#else /* OPT_STEREO_32KBPS_V1 */
x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 /*0.5.Q15*/ );
+#endif /* OPT_STEREO_32KBPS_V1 */
move32();
}
@@ -7262,12 +7596,6 @@ Word16 L_norm_arr( const Word32 *arr, Word16 size )
Word16 q = 31;
move16();
FOR( Word16 i = 0; i < size; i++ )
-#ifndef FIX_1103_OPT_L_NORM_ARR
- IF( arr[i] != 0 )
- {
- q = s_min( q, norm_l( arr[i] ) );
- }
-#else
{
Word16 q_tst;
@@ -7278,7 +7606,6 @@ Word16 L_norm_arr( const Word32 *arr, Word16 size )
}
}
-#endif
return q;
}
@@ -7302,26 +7629,28 @@ Word16 norm_arr( Word16 *arr, Word16 size )
return q;
}
-Word16 get_min_scalefactor( Word32 x, Word32 y )
+Word16 W_norm_arr( Word64 *arr, Word16 size )
{
-#ifndef FIX_1104_OPT_GETMINSCALEFAC
- Word16 scf = Q31;
+ Word16 q = 63;
+ Word16 exp = 0;
move16();
- test();
- IF( x == 0 && y == 0 )
- {
- return 0;
- }
- IF( x != 0 )
- {
- scf = s_min( scf, norm_l( x ) );
- }
- IF( y != 0 )
+ move16();
+ FOR( Word16 i = 0; i < size; i++ )
{
- scf = s_min( scf, norm_l( y ) );
+ if ( arr[i] != 0 )
+ {
+ exp = W_norm( arr[i] );
+ }
+ if ( arr[i] != 0 )
+ {
+ q = s_min( q, exp );
+ }
}
- return scf;
-#else
+ return q;
+}
+
+Word16 get_min_scalefactor( Word32 x, Word32 y )
+{
Word16 scf_y;
Word16 scf = Q31;
move16();
@@ -7345,7 +7674,6 @@ Word16 get_min_scalefactor( Word32 x, Word32 y )
}
return scf;
-#endif
}
diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c
index 839b2faaf0012cb535e19a5ba8dbf265d6dccb62..1d020cabdd7d013f554eeb3d0a697e73682881d9 100644
--- a/lib_com/fft_rel.c
+++ b/lib_com/fft_rel.c
@@ -36,10 +36,9 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/*---------------------------------------------------------------------*
* Local constants
diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c
index 12ed75f0af89e02d3977505249687b75ebe7d7c4..bd9080a7bd41747ba25f9a5cecce507c5ac55e63 100644
--- a/lib_com/fill_spectrum.c
+++ b/lib_com/fill_spectrum.c
@@ -38,9 +38,8 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c
index f2347d5b37f70a5bf9c5dd41296eb9d59f8da7b1..68853e06142c91523103ce2ae595215b69bbe61c 100644
--- a/lib_com/findpulse.c
+++ b/lib_com/findpulse.c
@@ -37,10 +37,9 @@
#include
#include "options.h"
#include
-#include "prot.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/*----------------------------------------------------------------------------------*
* findpulse()
diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c
index 41d90359f4a2643524d1abd16276b9c1e374512e..8b69e05e8811edbc273a3cd78e735d1bc0f99375 100644
--- a/lib_com/float_to_fix_ops.c
+++ b/lib_com/float_to_fix_ops.c
@@ -3,7 +3,6 @@
#include
#include
#include "options.h"
-#include "prot.h"
#include "prot_fx.h"
#define WMC_TOOL_SKIP
@@ -184,14 +183,14 @@ Word16 Q_factor( float x )
{
Word16 Q = 15;
if ( x >= 1 || x <= -1 )
- Q = norm_s( (Word16) abs( (Word32) x ) );
+ Q = norm_s( (Word16) L_abs( (Word32) x ) );
return Q;
}
Word16 Q_factor_L( float x )
{
Word16 Q = 31;
if ( x >= 1 || x <= -1 )
- Q = norm_l( abs( (Word32) x ) );
+ Q = norm_l( L_abs( (Word32) x ) );
return Q;
}
Word16 Q_factor_L_32( Word32 x )
@@ -207,7 +206,7 @@ Word16 Q_factor_arr( float *x, Word16 l )
for ( int i = 0; i < l; i++ )
{
if ( x[i] >= 1 || x[i] <= -1 )
- Q = s_min( Q, norm_s( (Word16) abs( (Word32) x[i] ) ) );
+ Q = s_min( Q, norm_s( (Word16) L_abs( (Word32) x[i] ) ) );
}
return Q;
}
@@ -217,7 +216,7 @@ Word16 Q_factor_arrL( float *x, Word16 l )
for ( int i = 0; i < l; i++ )
{
if ( x[i] >= 1 || x[i] <= -1 )
- Q = s_min( Q, norm_l( (Word32) abs( (Word32) x[i] ) ) );
+ Q = s_min( Q, norm_l( (Word32) L_abs( (Word32) x[i] ) ) );
}
return Q;
}
diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c
deleted file mode 100644
index e89c4dfad4e22bf0430a33058d441cfcbd4c0956..0000000000000000000000000000000000000000
--- a/lib_com/frame_ener.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-/*----------------------------------------------------------------------------------*
- * fer_energy()
- *
- * Estimation of pitch-synchronous (voiced sounds) or half-frame energy
- *----------------------------------------------------------------------------------*/
-
-#ifndef IVAS_FLOAT_FIXED
-void fer_energy(
- const int16_t L_frame, /* i : frame length */
- const int16_t clas, /* i : frame classification */
- const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */
- const float pitch, /* i : pitch period */
- float *enr, /* o : pitch-synchronous or half_frame energy */
- const int16_t offset /* i : speech pointer offset (0 or L_frame) */
-)
-{
- int16_t len;
- const float *pt_synth;
-
- if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */
- {
- len = (int16_t) ( pitch + 0.5f ); /* pitch value */
-
- pt_synth = synth;
- if ( offset != 0 )
- {
- pt_synth = synth + L_frame - len;
- }
-
- emaximum( pt_synth, len, enr ); /* pitch synchronous E */
- }
- else
- {
- pt_synth = synth;
- if ( offset != 0 )
- {
- pt_synth = synth + L_frame / 2;
- }
-
- *enr = dotp( pt_synth, pt_synth, L_frame / 2 );
- *enr /= (float) ( L_frame / 2 );
- }
- return;
-}
-#endif
-
-void fer_energy_fx(
- const Word16 L_frame, /* i : frame length */
- const Word16 clas, /* i : frame classification */
- const Word32 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q(q_synth) */
- const Word16 q_synth, /* i : synthesized speech at Fs = 12k8 Hz */
- const Word16 pitch, /* i : pitch period Q0 */
- Word32 *enr, /* o : pitch-synchronous or half_frame energy Q0 */
- const Word16 offset /* i : speech pointer offset (0 or L_frame) */
-)
-{
- Word16 len, shift, exp;
- const Word32 *pt_synth;
- Word16 enr_tmp, i;
- Word64 W_tmp;
-
- test();
- test();
- IF( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
- {
- len = ( pitch ); /* pitch value */
- move16();
-
- pt_synth = synth;
- IF( offset != 0 )
- {
- pt_synth = synth + sub( L_frame, len );
- }
-
- emaximum_32fx( q_synth, pt_synth, len, enr ); /* pitch synchronous E */
- }
- ELSE
- {
- pt_synth = synth;
- IF( offset != 0 )
- {
- pt_synth = synth + shr( L_frame, 1 );
- }
-
- W_tmp = 0;
- move64();
- FOR( i = 0; i < L_frame / 2; i++ )
- {
- W_tmp = W_add( W_tmp, W_mult0_32_32( pt_synth[i], pt_synth[i] ) ); // Q = q_synth * 2
- }
- shift = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, shift ); // Q = q_synth * 2 + shift
- *enr = W_extract_h( W_tmp ); // Q = q_synth * 2 + shift - 32
- move32();
-
- enr_tmp = BASOP_Util_Divide3216_Scale( *enr, shr( L_frame, 1 ) /*Q0*/, &exp );
- *enr = L_shr( L_deposit_l( enr_tmp ), sub( sub( sub( shift, 32 ), exp ), 1 ) ); /*Q0*/
- move32();
- }
- return;
-}
-
-
-/*----------------------------------------------------------------------------------*
- * frame_ener()
- *
- * Estimation of pitch-synchronous (voiced) or mean half-frame (unvoiced) energy
- *----------------------------------------------------------------------------------*/
-Word16 frame_ener_fx(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 clas, /* i : frame classification */
- const Word16 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q_new */
- const Word16 pitch, /* i : pitch period Q0 */
- Word32 *enr_q, /* o : pitch-synchronous or half_frame energy Q0 */
- const Word16 offset, /* i : speech pointer offset (0 or L_FRAME) */
- const Word16 Q_new, /* i : Scaling factor */
- Word16 shift, /* i : Shift need to obtain 12 bits vectors */
- const Word16 enc /* i : Encoder/decoder */
-)
-{
- Word16 len, exp_enrq, exp_tmp, pos;
- Word16 i;
- const Word16 *pt_synth;
- Word32 Ltmp;
-
- exp_enrq = 0;
- move16();
- test();
- test();
- IF( ( EQ_16( clas, VOICED_CLAS ) ) || ( EQ_16( clas, ONSET ) ) || ( EQ_16( clas, SIN_ONSET ) ) ) /* current frame is voiced */
- {
- /* current frame is voiced */
- len = pitch;
- move16(); /* pitch value at the end of frame */
- pt_synth = synth;
- if ( offset != 0 )
- {
- pt_synth = synth + sub( L_frame, len );
- }
- emaximum_fx( Q_new, pt_synth, len, enr_q );
- IF( enc != 0 )
- {
- exp_enrq = norm_l( *enr_q );
- *enr_q = L_shl( *enr_q, exp_enrq );
- move32();
- exp_enrq = sub( exp_enrq, 2 );
- }
- }
- ELSE
- {
- /* current frame is unvoiced */
- Word16 L_frame2, exp2, enr_q_tmp;
-
- L_frame2 = shr( L_frame, 1 );
- pos = 0;
- move16();
-
- if ( offset != 0 )
- {
- pos = sub( L_frame, L_frame2 );
- }
- Ltmp = L_mult_sat( synth[pos], synth[pos] ); /*2 * Qnew + 1*/
- FOR( i = 1; i < L_frame2; i++ )
- {
- Ltmp = L_mac_sat( Ltmp, synth[pos + i], synth[pos + i] ); /*2 * Qnew + 1*/
- }
- test();
- IF( EQ_32( Ltmp, MAX_32 ) || enc != 0 )
- {
- /* scale down when overflow occurs */
- *enr_q = Energy_scale( synth + pos, L_frame2, shift, &exp_enrq );
- move32();
- }
- ELSE
- {
- shift = 0;
- move16();
- /* Normalize acc in Q31 (energy already calculated) */
- pos = norm_l( Ltmp );
- Ltmp = L_shl( Ltmp, pos );
- exp_enrq = sub( 30, pos ); /* exponent = 0..30 */
- *enr_q = Ltmp;
- move32();
- }
-
- /* enr2 = 1.0f/L_FRAME2 * dot_product(synth, synth, L_FRAME2) */
- exp_enrq = sub( exp_enrq, shl( shift, 1 ) );
-
- IF( enc != 0 )
- {
- assert( L_frame == 256 || L_frame == 320 );
-
- exp_tmp = add( shl( Q_new, 1 ), -2 + 7 ); /* L_subfr == L_SUBFR */
- exp_enrq = sub( exp_enrq, exp_tmp );
- exp_enrq = sub( 31, exp_enrq );
-
- IF( EQ_16( L_frame, 320 ) )
- {
- *enr_q = Mult_32_16( *enr_q, 26214 ); /*x 0.8 to get /160*/
- move32();
- i = norm_l( *enr_q );
- *enr_q = L_shl( *enr_q, i );
- move32();
- exp_enrq = add( i, exp_enrq );
- }
- }
- ELSE
- {
- exp_enrq = sub( exp_enrq, add( Q_new, Q_new ) );
- enr_q_tmp /*Q30 exp2+exp_enrq*/ = BASOP_Util_Divide3216_Scale( *enr_q /*Q31*/, L_frame2 /*Q0*/, &exp2 );
- *enr_q = L_shr( L_deposit_l( enr_q_tmp ), sub( 30, add( exp2, exp_enrq ) ) ); /*Q0*/
- move32();
- *enr_q = L_add( *enr_q, 1 );
- move32();
- exp_enrq = 0;
- move16();
- }
- }
-
- return exp_enrq;
-}
-
-/*------------------------------------------------------------------------*
- * frame_energy()
- *
- * Compute pitch-synchronous energy at the frame end
- *------------------------------------------------------------------------*/
-Word16 frame_energy_fx( /* o : Frame energy in Q8 */
- Word16 L_frame,
- const Word16 *pitch, /* i : pitch values for each subframe Q6 */
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_syn*/
- const Word16 lp_speech, /* i : long term active speech energy average Q8 */
- Word16 *frame_ener, /* o : pitch-synchronous energy at frame end Q8 */
- const Word16 Q_syn /* i : Synthesis scaling */
-)
-{
- Word32 Ltmp;
- const Word16 *pt1;
- Word16 tmp16, exp1, exp2, tmp1, tmp2;
- Word16 len, enern;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
-
- /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */
- len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 );
-
- if ( LT_16( len, L_SUBFR ) )
- {
- len = shl( len, 1 );
- }
- pt1 = speech + sub( L_frame, len );
-
- /* *frame_ener = 10.0f * log10(dot_product(pt1, pt1, len) / (float)len) */
-
- tmp1 = norm_s( len );
- tmp2 = shl( len, tmp1 );
- tmp1 = sub( 15, tmp1 );
-
- Ltmp = Dot_productSq16HQ( 0, pt1, len, &exp1 );
- exp1 = sub( exp1, shl( Q_syn, 1 ) );
- exp1 = sub( exp1, 1 ); /* compensation of leftshift caused by mac operation in dot_productSq16HQ */
- tmp16 = BASOP_Util_Divide3216_Scale( Ltmp, len, &exp2 );
-
- exp1 = add( exp1, exp2 );
- exp1 = add( exp1, 1 ); /* compensate result of division Q-1 */
-
-
- tmp2 = norm_s( tmp16 );
- Ltmp = L_shl( L_deposit_h( tmp16 ), tmp2 ); /*Q16, (exp1-tmp2) = Q31, exp1-tmp2+15*/
-
- Ltmp = BASOP_Util_Log2( Ltmp ); /*Q(31-6) = Q25*/
- exp1 = sub( 15 + exp1, tmp2 );
-
- /*add ld(2^exp1)=exp1 but check format, first*/
- tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/
- Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/
- exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/
- Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/
-
- /*make 10*log10 out of log2*/
- Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/
- *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/
- move16();
- enern = sub_o( *frame_ener, lp_speech, &Overflow ); /*Q8*/
-
- return enern;
-}
diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c
index 4428c07964003506079fb33e6568451c4c8f1820..68fdf33c3a2db5ba8703f436ddc1e1043d17eef4 100644
--- a/lib_com/frame_ener_fx.c
+++ b/lib_com/frame_ener_fx.c
@@ -38,9 +38,8 @@
#include "options.h"
#include
#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
/*----------------------------------------------------------------------------------*
* fer_energy()
*
diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c
deleted file mode 100644
index 89b5fa3de291311902c7769b951cb2fd901bf218..0000000000000000000000000000000000000000
--- a/lib_com/get_gain.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-/*----------------------------------------------------------------------------------*
- * get_gain()
- *
- *
- *----------------------------------------------------------------------------------*/
-
-#ifndef IVAS_FLOAT_FIXED
-/*! r: codebook gain (adaptive or fixed) */
-float get_gain_flt(
- const float x[], /* i : target signal */
- const float y[], /* i : filtered codebook excitation */
- const int16_t n, /* i : segment length */
- float *en_y /* o : energy of y (sum of y[]^2, optional) */
-)
-{
- float corr = 0.0f, ener = 1e-6f;
- int16_t i;
-
- for ( i = 0; i < n; i++ )
- {
- corr += x[i] * y[i];
- ener += y[i] * y[i];
- }
-
- if ( en_y )
- {
- *en_y = ener;
- }
-
- return ( corr / ener );
-}
-#endif
-
-Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */
- const Word16 x[], /* input : target signal Qx */
- const Word16 y[], /* input : filtered codebook excitation Qx */
- const Word16 n /* input : segment length */
-)
-{
- Word32 tcorr, tener, Lgain;
- Word16 exp_c, exp_e, exp, tmp;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
-
- tcorr = L_deposit_l( 0 );
- tener = L_deposit_l( 0 );
-
-
- /*----------------------------------------------------------------*
- * Find gain based on inter-correlation product
- *----------------------------------------------------------------*/
-
- tcorr = Dot_product16HQ( 0, x, y, n, &exp_c );
- tener = Dot_productSq16HQ( 0, y, n, &exp_e );
-
- BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp );
- Lgain = L_shl_o( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ), &Overflow ) /*Q16*/;
-
- return Lgain;
-}
-
-Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */
- const Word16 x[], /* input : target signal */
- const Word16 y[], /* input : filtered codebook excitation */
- const Word16 n /* input : segment length */
-)
-{
- Word32 tcorr, tener, Lgain;
- Word16 m_corr, m_ener, negative, Q_corr, Q_ener;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
- negative = 0;
- move16();
-
- /*----------------------------------------------------------------*
- * Find gain based on inter-correlation product
- *----------------------------------------------------------------*/
- tcorr = Dot_product16HQ( 0, x, y, n, &Q_corr );
- tener = Dot_productSq16HQ( 0, y, n, &Q_ener );
-
- tener = L_max( tener, 1 );
-
- if ( tcorr <= 0 )
- {
- negative = 1;
- move16();
- }
- BASOP_SATURATE_WARNING_OFF_EVS /*tcorr max be negative maxvall - not critical*/
- tcorr = L_abs( tcorr );
- BASOP_SATURATE_WARNING_ON_EVS
-
- m_corr = extract_h( tcorr );
-
- m_ener = extract_h( tener );
-
- IF( GT_16( m_corr, m_ener ) )
- {
- m_corr = shr( m_corr, 1 );
- Q_corr = add( Q_corr, 1 );
- }
- if ( m_ener == 0 )
- {
- move16();
- m_corr = 0x7FFF;
- }
- IF( m_ener != 0 )
- {
- m_corr = div_s( m_corr, m_ener );
- }
-
- Q_corr = sub( Q_corr, Q_ener );
-
- Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */
-
- if ( negative != 0 )
- {
- Lgain = L_negate( Lgain ); /* Lgain in Q16 */
- }
-
-
- return Lgain;
-}
diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c
index d4c2413c35dcd4893fbfd11e84b593c433b901e9..8ec4f5a40314afa27263cb7a4a77d8a31dd8d53c 100644
--- a/lib_com/get_gain_fx.c
+++ b/lib_com/get_gain_fx.c
@@ -36,9 +36,8 @@
#include
#include "options.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
/*----------------------------------------------------------------------------------*
* get_gain()
diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c
index 47d3679a8289eff3a9131a3cb23f86eab3c5e7cb..0ce59482f1f0a3de6ed59c06bf4b5065ccda3166 100644
--- a/lib_com/gs_bitallocation_fx.c
+++ b/lib_com/gs_bitallocation_fx.c
@@ -75,10 +75,8 @@ void bands_and_bit_alloc_fx(
Word16 SWB_bit_budget;
Word32 bits_per_bands[MBANDS_GN_BITALLOC16k];
Word16 w_sum_bit;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) GSC_IVAS_mode;
(void) element_mode;
-#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#endif
@@ -120,40 +118,7 @@ void bands_and_bit_alloc_fx(
move16();
bit_new_bands = 5;
move16();
-#ifdef ADD_LRTD
- if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) )
- {
- bit_new_bands = 7;
- move16();
- }
-
- i = 0;
- move16();
- WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
- {
- IF( LE_32( core_brate, brate_intermed_tbl[i] ) )
- {
- BREAK;
- }
-
- IF( EQ_32( brate_intermed_tbl[i], ACELP_24k40 ) )
- {
- BREAK;
- }
-
- i = add( i, 1 );
- }
-
- if ( GT_16( element_mode, EVS_MONO ) && EQ_16( coder_type, AUDIO ) &&
- LE_32( core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
- {
- i = sub( i, 1 );
- }
-
- bit_index = i_mult2( BRATE2IDX_fx( brate_intermed_tbl[i] ), 17 );
-#else
bit_index = i_mult2( BRATE2IDX_fx( core_brate ), 17 );
-#endif
bit_index_mem = bit_index;
move16();
@@ -189,668 +154,330 @@ void bands_and_bit_alloc_fx(
move16();
}
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k )
+ IF( EQ_16( GSC_noisy_speech, 1 ) )
{
- *bit -= 8;
- }
+ SWB_bit_budget = *bit;
+ move16();
+ nb_bands = 5;
+ move16();
- if ( coder_type == INACTIVE && core_brate <= GSC_LRES_GAINQ_LIMIT ) /* can happen only for 2nd channel inactive */
- {
- *bit += GSC_LRES_NB_NITS;
- }
+ st_band = nb_bands;
+ move16();
- if ( *bit > 0 )
- {
- if ( GSC_IVAS_mode > 0 )
- {
- SWB_bit_budget = *bit;
- st_band = 5;
+ set32_fx( bits_per_bands, 0, MBANDS_GN );
+ /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */
+ bit_fracf = L_mult( div_s( 1, nb_bands ), shl( SWB_bit_budget, 2 ) ); /* Q18 */
- set_f( bits_per_bands, 0, MBANDS_GN_BITALLOC16k );
+ nb_tot_bands = sub( nb_bands_max, 6 );
+ nb_tot_bands = s_min( nb_tot_bands, 16 );
- /* 2- Decide the pourcentage of bits allocated to LF (between 50-75%) depending of the temporal contribution in GSC */
- bit_fracf = ( -0.125f * Diff_len + 76.0f ) / 100;
- bit_fracf = check_bounds( bit_fracf, 0.50f, 0.75f );
+ FOR( j = 0; j < 2; j++ )
+ {
+ i = j;
+ move16();
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = 0;
+ move16();
+ }
- /* Adjusment of the bitrate between LF and HF base on the content type */
- /* 1 = new GSC bit alloc
- 2 = GSC bit alloc for tc frame
- 3 = more music like (should not happen often given music is coded with dft) */
+ FOR( ; j < nb_bands; j++ )
+ {
+ i = maximum_fx( ener_vec, nb_tot_bands, &etmp );
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = 0;
+ move16();
+ }
- if ( GSC_IVAS_mode <= 3 )
- {
- nb_bands_max -= 6;
- }
+ set32_fx( bits_per_bands, bit_fracf, nb_bands );
+ }
+ ELSE
+ {
+ bit_index++;
+ bit_tmp = sub( *bit, GSC_freq_bits[bit_index] );
+ bit_index++;
+ nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] );
+ bit_index++;
- if ( GSC_IVAS_mode == 2 )
- {
- bit_fracf += 0.1f;
- nb_bands_max--;
- }
+ *pvq_len = 112;
+ move16();
+ st_band = 7;
+ move16();
- if ( GSC_IVAS_mode == 3 )
- {
- bit_fracf -= 0.1f;
- nb_bands_max += 3;
- }
+ IF( LE_32( core_brate, ACELP_9k60 ) )
+ {
+ *pvq_len = 80;
+ move16();
+ st_band = 5;
+ move16();
- /* First find how much we want to share between LF and HF, at low bitrate, a miminum of bits is needed in LF by limitating the number of bands*/
- /* Adjust the number of band based on the content type and bitrate */
- nb_bands_adj = 1.0f;
- if ( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG )
- {
- nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;
- }
- else if ( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG )
+ IF( Diff_len == 0 )
{
- nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;
+ nb_bands_max = add( nb_bands_max, 2 );
+ bit_tmp = sub( bit_tmp, 13 );
}
- nb_bands_max = (int16_t) ( nb_bands_max * nb_bands_adj + 0.5f );
- nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands );
+ }
- bit_fracf *= SWB_bit_budget;
+ ELSE IF( Diff_len == 0 )
+ {
+ nb_bands_max = add( nb_bands_max, 2 );
+ bit_tmp = sub( bit_tmp, 17 );
+ }
- /* Estimation of the number of bit used in HF */
- /* with only the first weigthing The number of bits in max_ener_band[st_band-1] = 17% of bit_fracf */
- mb = .17f * bit_fracf;
- mp = ( 2.0f * DSR_NB_PULSE );
- if ( core_brate < GSC_L_RATE_STG && GSC_IVAS_mode == 3 )
- {
- mp = 1.5f * DSR_NB_PULSE;
- }
- else if ( core_brate < GSC_L_RATE_STG )
+ nb_bands = shr( *pvq_len, 4 );
+
+ /*------------------------------------------------------------------------
+ * Ajustement of the maximum number of bands in function of the
+ * dynamics of the spectrum (more or less speech like)
+ *-----------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) )
+ {
+ /* Probably classification error -> concentrate bits on LF */
+ if ( GE_32( core_brate, ACELP_8k00 ) )
{
- mp = DSR_NB_PULSE;
+ nb_bands_max = add( nb_bands, 1 );
}
-
- /* We want max_ener_band[st_band] <= max_ener_band[st_band-1] and max_ener_band[nb_bands_max-1] <= max_ener_band[st_band]*/
- /* We will estimate the number of bits to allocate of HF and put the remaining bits, if any, back on LF */
- /* compute the total possible number of band to be coded */
- nb_tot_bands = (int16_t) ( ( SWB_bit_budget - bit_fracf ) / ( mp + ( mb - mp ) / 2.0f ) );
- mp = min( mp, mb );
- if ( nb_tot_bands + st_band > nb_bands_max )
+ else
{
- bit_adj = ( ( mb + mp ) / 2 ) * ( nb_tot_bands + st_band - nb_bands_max );
- bit_adj = max( 0, bit_adj );
- nb_tot_bands = nb_bands_max - st_band;
- bit_fracf += bit_adj;
+ nb_bands_max = nb_bands;
+ move16();
}
- nb_tot_bands += st_band;
+ }
+ ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP2 ) ||
+ ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */
+ {
+ nb_bands_max = sub( nb_bands_max, 2 );
+ }
+ ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP1 ) ) /* Very low dynamic, tend to speech, code less HF */
+ {
+ nb_bands_max = sub( nb_bands_max, 1 );
+ }
- /* Allocate bits to LF */
- etmp = 0.23f;
- for ( j = 0; j < st_band; j++ )
- {
- i = j;
- max_ener_band[j] = i;
- ener_vec[i] = MIN16B;
- bits_per_bands[j] = etmp * bit_fracf;
- etmp -= 0.015f;
- }
+ test();
+ if ( ( EQ_16( bwidth, NB ) ) && GT_16( nb_bands_max, 10 ) )
+ {
+ nb_bands_max = 10;
+ move16();
+ }
- SWB_bit_budget -= bit_fracf;
+ /*------------------------------------------------------------------------
+ * Find extra number of band to code according to bit rate availables
+ *-----------------------------------------------------------------------*/
+ test();
+ WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) )
+ {
+ test();
+ bit_tmp = sub( bit_tmp, bit_new_bands );
+ nb_bands = add( nb_bands, 1 );
+ }
- /* Find low energy band in HF */
- set_s( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k );
- for ( i = st_band + 2; i < nb_tot_bands - 1; i++ )
- {
- if ( ener_vec[i] < ener_vec[i - 1] && ener_vec[i] < ener_vec[i + 1] )
- {
- nb_pulse_per_band[i] = 1;
- }
- }
- for ( j = st_band; j < nb_tot_bands; j++ )
- {
- if ( j > 6 )
- {
- i = maximum( ener_vec, nb_tot_bands, &etmp );
- }
- else
- {
- i = j;
- }
+ /*------------------------------------------------------------------------
+ * Fractional bits to distribute on the first x bands
+ *-----------------------------------------------------------------------*/
- max_ener_band[j] = i;
- ener_vec[i] = MIN16B;
- }
+ {
+ bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */
+ }
+ /*------------------------------------------------------------------------
+ * Complete the bit allocation per frequency band
+ *-----------------------------------------------------------------------*/
+ imax = 5;
+ move16();
- /* Recompute the final bit distribution for HF */
- if ( nb_tot_bands > st_band )
- {
- bit_fracf = DSR_NB_PULSE;
- mb = ( SWB_bit_budget * 2 / ( nb_tot_bands - st_band ) ) - mp;
- bit_fracf = ( mb - mp ) / ( nb_tot_bands - st_band );
- mb -= bit_fracf;
- /* Do the distribution */
- for ( j = st_band; j < nb_tot_bands; j++ )
- {
- if ( nb_pulse_per_band[max_ener_band[j]] > 1 )
- {
- bits_per_bands[max_ener_band[j]] = mb;
- }
- else
- {
- bits_per_bands[max_ener_band[j]] = 4.5f;
- }
- mb -= bit_fracf;
- SWB_bit_budget -= bits_per_bands[max_ener_band[j]];
- }
- }
+ if ( GT_32( core_brate, ACELP_9k60 ) )
+ {
+ imax = 7;
+ move16();
+ }
+ FOR( i = 0; i < imax; i++ )
+ {
+ bits_per_bands[i] = L_add( GSC_freq_bits_fx[bit_index], bit_fracf );
+ move32(); /* Q18 */
+ bit_index = add( bit_index, 1 );
+ }
- /* Series of verification in case bit allocated != the budget */
- if ( SWB_bit_budget > 0 )
+ IF( Diff_len == 0 )
+ {
+ bit_index = add( bit_index_mem, 10 );
+ FOR( i = 0; i < 7; i++ )
{
- i = st_band - 1;
- while ( SWB_bit_budget > 0 )
- {
- bits_per_bands[i]++;
- SWB_bit_budget--;
- i--;
- if ( i == -1 )
- {
- i = st_band - 1;
- }
- }
+ bits_per_bands[i] = L_add( bits_per_bands[i], GSC_freq_bits_fx[bit_index] );
+ move32(); /*chk Q18 */
+ bit_index = add( bit_index, 1 );
}
+ }
- nb_bands = nb_tot_bands;
-
- sum_bit = 0;
- j = 0;
- for ( i = 0; i < nb_bands; i++ )
- {
- if ( bits_per_bands[i] > 112 )
- {
- sum_bit += bits_per_bands[i] - 112;
- bits_per_bands[i] = 112;
- j = i + 1;
- }
-
- /* safety check for overage bit reallocation */
- else if ( bits_per_bands[i] + sum_bit / 3 > 112 )
- {
- j = i + 1;
- }
- }
+ /*--------------------------------------------------------------------------
+ * Complete the bit allocation per frequency band for 16kHz high brate mode
+ *--------------------------------------------------------------------------*/
- if ( sum_bit != 0 )
+ {
+ FOR( j = st_band; j < nb_bands; j++ )
{
- sum_bit /= ( nb_bands - j );
- for ( i = j; i < nb_bands; i++ )
- {
- bits_per_bands[i] += sum_bit;
- }
+ bits_per_bands[j] = L_shl( bit_new_bands, 18 );
+ move32(); /*chk Q18 */
}
}
- else
-#endif
- IF( EQ_16( GSC_noisy_speech, 1 ) )
- {
- SWB_bit_budget = *bit;
- move16();
- nb_bands = 5;
- move16();
-
-#ifdef ADD_LRTD
-
- fzero_val = 0.0f;
- if ( element_mode > EVS_MONO )
- {
- fzero_val = MIN16B_FLT;
- }
- if ( coder_type == UNVOICED && element_mode > EVS_MONO )
- {
- nb_bands = 3;
- if ( SWB_bit_budget > 20 )
- {
- nb_bands = 5;
- }
- }
- else if ( bwidth < SWB )
- {
- nb_bands = 7;
- }
-
-#endif
+ /*--------------------------------------------------------------------------
+ * Compute a maximum band (band offset) for the search on maximal energy
+ * This is function of the spectral dynamic and the bitrate
+ *--------------------------------------------------------------------------*/
- st_band = nb_bands;
- move16();
+ bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) );
- set32_fx( bits_per_bands, 0, MBANDS_GN );
- /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */
- bit_fracf = L_mult( div_s( 1, nb_bands ), shl( SWB_bit_budget, 2 ) ); /* Q18 */
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( LE_16( noise_lev, NOISE_LEVEL_SP1a ) )
+ {
+ bandoffset = sub( bandoffset, 1 );
+ }
+ ELSE IF( ( LE_32( core_brate, ACELP_13k20 ) && ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) ) ||
+ ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) )
+ {
+ bandoffset = add( bandoffset, 1 );
+ }
- nb_tot_bands = sub( nb_bands_max, 6 );
- nb_tot_bands = s_min( nb_tot_bands, 16 );
+ bandoffset = s_max( bandoffset, 0 );
- FOR( j = 0; j < 2; j++ )
- {
- i = j;
- move16();
- max_ener_band[j] = i;
- move16();
- ener_vec[i] = 0;
- move16();
- }
-#ifdef ADD_LRTD
- if ( bwidth < SWB )
- {
- if ( coder_type == UNVOICED && element_mode > EVS_MONO )
- {
- nb_tot_bands = 5;
- }
-#endif
- FOR( ; j < nb_bands; j++ )
- {
- i = maximum_fx( ener_vec, nb_tot_bands, &etmp );
- max_ener_band[j] = i;
- move16();
- ener_vec[i] = 0;
- move16();
- }
-#ifdef ADD_LRTD
- }
- else
- {
- for ( ; j < nb_bands; j++ )
- {
- i = maximum( ener_vec, nb_tot_bands, &etmp );
- max_ener_band[j] = i;
- ener_vec[i] = fzero_val;
- }
- }
-#endif
- set32_fx( bits_per_bands, bit_fracf, nb_bands );
- }
- ELSE
+ /*--------------------------------------------------------------------------
+ * Initiazed sorted vector
+ * For the first x bands to be included in th final sorted vector
+ * Sort the remaining bands in decrease energy order
+ *--------------------------------------------------------------------------*/
+ FOR( j = 0; j < nb_tot_bands; j++ )
{
- bit_index++;
- bit_tmp = sub( *bit, GSC_freq_bits[bit_index] );
- bit_index++;
- nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] );
- bit_index++;
-
- *pvq_len = 112;
+ max_ener_band[j] = -10;
move16();
- st_band = 7;
+ }
+ FOR( j = 0; j < st_band; j++ )
+ {
+ max_ener_band[j] = j;
move16();
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 )
- {
- *pvq_len = 160;
- st_band = 10;
- nb_bands = *pvq_len / 16;
- bit_tmp -= 35;
- bit_new_bands = 5;
- }
-#endif
- IF( LE_32( core_brate, ACELP_9k60 ) )
- {
- *pvq_len = 80;
- move16();
- st_band = 5;
- move16();
-
- IF( Diff_len == 0 )
- {
- nb_bands_max = add( nb_bands_max, 2 );
- bit_tmp = sub( bit_tmp, 13 );
- }
- }
-
- ELSE IF( Diff_len == 0 )
- {
- nb_bands_max = add( nb_bands_max, 2 );
- bit_tmp = sub( bit_tmp, 17 );
- }
-
- nb_bands = shr( *pvq_len, 4 );
-#ifdef ADD_LRTD
- nb_bands_max = min( nb_bands_max, MBANDS_GN_BITALLOC16k );
-#endif
- /*------------------------------------------------------------------------
- * Ajustement of the maximum number of bands in function of the
- * dynamics of the spectrum (more or less speech like)
- *-----------------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) )
- {
- /* Probably classification error -> concentrate bits on LF */
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k && core_brate >= ACELP_24k40 )
- {
- nb_bands_max = nb_tot_bands - 2;
- }
- else if ( core_brate >= ACELP_16k40 )
- {
- nb_bands_max = nb_bands + 2;
- }
- else
-#endif
- if ( GE_32( core_brate, ACELP_8k00 ) )
- {
- nb_bands_max = add( nb_bands, 1 );
- }
- else
- {
- nb_bands_max = nb_bands;
- move16();
- }
- }
- ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP2 ) ||
- ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */
- {
- nb_bands_max = sub( nb_bands_max, 2 );
- }
- ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP1 ) ) /* Very low dynamic, tend to speech, code less HF */
- {
- nb_bands_max = sub( nb_bands_max, 1 );
- }
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k )
- {
- if ( core_brate < ACELP_24k40 )
- {
- nb_bands_max -= 4;
- }
- else if ( core_brate < ACELP_32k )
- {
- if ( Diff_len > 0 || noise_lev >= NOISE_LEVEL_SP2 )
- {
- nb_bands_max -= 2;
- bit_new_bands *= 2;
- }
- }
- else if ( core_brate >= ACELP_32k )
- {
- bit_new_bands *= 2;
- }
- }
-
-#endif
- test();
- if ( ( EQ_16( bwidth, NB ) ) && GT_16( nb_bands_max, 10 ) )
- {
- nb_bands_max = 10;
- move16();
- }
-
- /*------------------------------------------------------------------------
- * Find extra number of band to code according to bit rate availables
- *-----------------------------------------------------------------------*/
- test();
- WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) )
- {
- test();
- bit_tmp = sub( bit_tmp, bit_new_bands );
- nb_bands = add( nb_bands, 1 );
- }
-
- /*------------------------------------------------------------------------
- * Fractional bits to distribute on the first x bands
- *-----------------------------------------------------------------------*/
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k && core_brate > ACELP_32k )
- {
- bit_fracf = 0;
- }
- else
-#endif
- {
- bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */
- }
- /*------------------------------------------------------------------------
- * Complete the bit allocation per frequency band
- *-----------------------------------------------------------------------*/
- imax = 5;
+ ener_vec[j] = -10;
move16();
+ }
+ pos = st_band;
+ move16();
+ FOR( ; j < nb_bands; j++ )
+ {
+ i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp );
+ pos = s_max( pos, i );
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = -10;
+ move16();
+ }
- if ( GT_32( core_brate, ACELP_9k60 ) )
+ /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */
+ test();
+ test();
+ test();
+ IF( GT_16( sub( nb_tot_bands, bandoffset ), nb_bands ) && ( GT_16( pos, 7 ) && EQ_32( core_brate, ACELP_8k00 ) ) && EQ_16( bwidth, WB ) )
+ {
+ band = sub( nb_tot_bands, add( bandoffset, nb_bands ) );
+ FOR( j = 0; j < band; j++ )
{
- imax = 7;
+ i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp );
+ max_ener_band[add( nb_bands, j )] = i;
move16();
+ ener_vec[i] = -10;
+ move16();
+ bits_per_bands[add( nb_bands, j )] = 1310720;
+ move32(); /*Q18 */
}
- FOR( i = 0; i < imax; i++ )
- {
- bits_per_bands[i] = L_add( GSC_freq_bits_fx[bit_index], bit_fracf );
- move32(); /* Q18 */
- bit_index = add( bit_index, 1 );
- }
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 )
- {
- bit_index = 0;
- i = imax - 1;
- bits_per_bands[i] += Compl_GSC_freq_bits[bit_index];
- i++;
- bit_index++;
+ nb_bands = add( nb_bands, band );
- for ( ; i < 10; i++ )
- {
- bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf;
- bit_index++;
- }
- }
-#endif
- IF( Diff_len == 0 )
- {
- bit_index = add( bit_index_mem, 10 );
- FOR( i = 0; i < 7; i++ )
- {
- bits_per_bands[i] = L_add( bits_per_bands[i], GSC_freq_bits_fx[bit_index] );
- move32(); /*chk Q18 */
- bit_index = add( bit_index, 1 );
- }
- }
-#ifdef ADD_LRTD
- if ( bit_fracf < 0 )
- {
- for ( j = 0; j < nb_tot_bands; j++ )
- {
- bits_per_bands[j] = max( bits_per_bands[j], 0 );
- }
- }
+ bit_tmp = i_mult2( band, 5 );
-#endif
- /*--------------------------------------------------------------------------
- * Complete the bit allocation per frequency band for 16kHz high brate mode
- *--------------------------------------------------------------------------*/
-#ifdef ADD_LRTD
- if ( L_frame == L_FRAME16k && core_brate > ACELP_32k )
+ IF( LE_16( band, 2 ) )
{
- for ( j = st_band; j < nb_bands; j++ )
+ FOR( j = sub( st_band, 1 ); j < nb_bands; j++ )
{
- bits_per_bands[j] = bit_new_bands;
+ bits_per_bands[j] = L_add( bits_per_bands[j], 262144 ); /*Q18 */
+ move32();
}
-
- bit_fracf = ( 1.0f / nb_bands ) * ( bit_tmp );
-
- etmp = 2.0f * bit_fracf / ( nb_bands + 1 );
- bit_fracf = etmp;
- for ( j = nb_bands - 1; j >= 0; j-- )
- {
- bits_per_bands[j] += etmp;
- etmp += bit_fracf;
- }
- }
- else
-#endif
- {
- FOR( j = st_band; j < nb_bands; j++ )
- {
- bits_per_bands[j] = L_shl( bit_new_bands, 18 );
- move32(); /*chk Q18 */
- }
- }
-
- /*--------------------------------------------------------------------------
- * Compute a maximum band (band offset) for the search on maximal energy
- * This is function of the spectral dynamic and the bitrate
- *--------------------------------------------------------------------------*/
-
- bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) );
-
- test();
- test();
- test();
- test();
- test();
- IF( LE_16( noise_lev, NOISE_LEVEL_SP1a ) )
- {
- bandoffset = sub( bandoffset, 1 );
- }
- ELSE IF( ( LE_32( core_brate, ACELP_13k20 ) && ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) ) ||
- ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) )
- {
- bandoffset = add( bandoffset, 1 );
+ bit_tmp = add( bit_tmp, add( sub( nb_bands, st_band ), 1 ) );
}
- bandoffset = s_max( bandoffset, 0 );
-
- /*--------------------------------------------------------------------------
- * Initiazed sorted vector
- * For the first x bands to be included in th final sorted vector
- * Sort the remaining bands in decrease energy order
- *--------------------------------------------------------------------------*/
- FOR( j = 0; j < nb_tot_bands; j++ )
- {
- max_ener_band[j] = -10;
- move16();
- }
- FOR( j = 0; j < st_band; j++ )
- {
- max_ener_band[j] = j;
- move16();
- ener_vec[j] = -10;
- move16();
- }
- pos = st_band;
+ i = 0;
move16();
- FOR( ; j < nb_bands; j++ )
- {
- i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp );
- pos = s_max( pos, i );
- max_ener_band[j] = i;
- move16();
- ener_vec[i] = -10;
- move16();
- }
-
- /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */
- test();
- test();
- test();
- IF( GT_16( sub( nb_tot_bands, bandoffset ), nb_bands ) && ( GT_16( pos, 7 ) && EQ_32( core_brate, ACELP_8k00 ) ) && EQ_16( bwidth, WB ) )
+ j = 0;
+ move16();
+ FOR( ; bit_tmp > 0; bit_tmp-- )
{
- band = sub( nb_tot_bands, add( bandoffset, nb_bands ) );
- FOR( j = 0; j < band; j++ )
+ bits_per_bands[j] = L_sub( bits_per_bands[j], 262144 ); /*Q18 */
+ j = add( j, 1 );
+ if ( EQ_16( j, sub( st_band, i ) ) )
{
- i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp );
- max_ener_band[add( nb_bands, j )] = i;
+ j = 0;
move16();
- ener_vec[i] = -10;
- move16();
- bits_per_bands[add( nb_bands, j )] = 1310720;
- move32(); /*Q18 */
- }
- nb_bands = add( nb_bands, band );
-
- bit_tmp = i_mult2( band, 5 );
-
- IF( LE_16( band, 2 ) )
- {
- FOR( j = sub( st_band, 1 ); j < nb_bands; j++ )
- {
- bits_per_bands[j] = L_add( bits_per_bands[j], 262144 ); /*Q18 */
- move32();
- }
- bit_tmp = add( bit_tmp, add( sub( nb_bands, st_band ), 1 ) );
}
-
- i = 0;
- move16();
- j = 0;
- move16();
- FOR( ; bit_tmp > 0; bit_tmp-- )
+ test();
+ if ( j == 0 && LT_16( i, sub( st_band, 1 ) ) )
{
- bits_per_bands[j] = L_sub( bits_per_bands[j], 262144 ); /*Q18 */
- j = add( j, 1 );
- if ( EQ_16( j, sub( st_band, i ) ) )
- {
- j = 0;
- move16();
- }
- test();
- if ( j == 0 && LT_16( i, sub( st_band, 1 ) ) )
- {
- i = add( i, 1 );
- }
+ i = add( i, 1 );
}
}
}
- /*--------------------------------------------------------------------------
- * Bit sum verification for GSC inactive at very high rate
- * The maximum number of bits per band of length 16 is 112
- * Redistribute the overage bits if needed
- *--------------------------------------------------------------------------*/
- sum_bit = 0;
- move16();
- j = 0;
- move16();
- FOR( i = 0; i < nb_bands; i++ )
- {
- L_tmp = Mult_32_16( sum_bit, 10923 );
-
- IF( GT_32( bits_per_bands[i], 29360128 ) ) /* 112 in Q18 */
- {
- sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) ); /* Q18 */
- bits_per_bands[i] = 29360128;
- move32();
- j = add( i, 1 );
- }
- ELSE IF( GT_32( L_add( bits_per_bands[i], L_tmp ), 29360128 ) ) /* Q18 */
- {
- j = add( i, 1 );
- }
- }
+ }
+ /*--------------------------------------------------------------------------
+ * Bit sum verification for GSC inactive at very high rate
+ * The maximum number of bits per band of length 16 is 112
+ * Redistribute the overage bits if needed
+ *--------------------------------------------------------------------------*/
+ sum_bit = 0;
+ move16();
+ j = 0;
+ move16();
+ FOR( i = 0; i < nb_bands; i++ )
+ {
+ L_tmp = Mult_32_16( sum_bit, 10923 );
- IF( sum_bit != 0 )
- {
- tmp = sub( nb_bands, j );
- sum_bit = Mult_32_16( sum_bit, div_s( 1, tmp ) ); /* Q18 */
- FOR( i = j; i < nb_bands; i++ )
- {
- bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit );
- move32(); /* Q18 */
- }
- }
- /*--------------------------------------------------------------------------
- * second step of bit sum verification, normally sum_bit == *bit
- *--------------------------------------------------------------------------*/
- w_sum_bit = 0;
- move16();
- FOR( i = 0; i < nb_bands; i++ )
+ IF( GT_32( bits_per_bands[i], 29360128 ) ) /* 112 in Q18 */
{
- out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 );
- move16();
- w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */
+ sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) ); /* Q18 */
+ bits_per_bands[i] = 29360128;
+ move32();
+ j = add( i, 1 );
}
- tmp = shl( *bit, 3 );
-#ifdef ADD_LRTD
- if ( GSC_IVAS_mode != 0 && sum_bit < *bit ) /* If we need to add bits, we are doing it on the LF */
+ ELSE IF( GT_32( L_add( bits_per_bands[i], L_tmp ), 29360128 ) ) /* Q18 */
{
- reajust_bits( bits_per_bands, 0, nb_bands, (int16_t) sum_bit, *bit );
+ j = add( i, 1 );
}
- else
+ }
+
+ IF( sum_bit != 0 )
+ {
+ tmp = sub( nb_bands, j );
+ sum_bit = Mult_32_16( sum_bit, div_s( 1, tmp ) ); /* Q18 */
+ FOR( i = j; i < nb_bands; i++ )
{
- reajust_bits( bits_per_bands, nb_bands - 1, 0, (int16_t) sum_bit, *bit );
+ bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit );
+ move32(); /* Q18 */
}
-#else
+ }
+ /*--------------------------------------------------------------------------
+ * second step of bit sum verification, normally sum_bit == *bit
+ *--------------------------------------------------------------------------*/
+ w_sum_bit = 0;
+ move16();
+ FOR( i = 0; i < nb_bands; i++ )
+ {
+ out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 );
+ move16();
+ w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */
+ }
+ tmp = shl( *bit, 3 );
+
IF( GT_16( tmp, w_sum_bit ) )
{
i = sub( nb_bands, 1 );
@@ -866,88 +493,24 @@ void bands_and_bit_alloc_fx(
}
}
}
-#endif
- /*--------------------------------------------------------------------------
- * Recompute the real number/length of frequency bands to encode
- *--------------------------------------------------------------------------*/
- *nb_subbands = nb_bands;
- move16();
- *pvq_len = shl( *nb_subbands, 4 );
- /*--------------------------------------------------------------------------
- * Concatenate bands (encoder only)
- *--------------------------------------------------------------------------*/
- IF( exc_diff != NULL )
- {
- FOR( j = 0; j < nb_bands; j++ )
- {
- Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 );
- }
- }
-#ifdef ADD_LRTD
- }
- else /* *bit == 0 */
- {
- set_s( bits_per_bands_s, 0, nb_tot_bands );
- *nb_subbands = 0;
- *pvq_len = 0;
- }
-#endif
- return;
-}
-#ifdef ADD_LRTD
-/*-------------------------------------------------------------------*
- * reajust_bits()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void reajust_bits(
- float *bits_per_bands,
- const int16_t st_band,
- const int16_t end_band,
- const int16_t sum_bit_in,
- const int16_t bit_bdgt_in )
-{
- int16_t i, amount_to_add, incr;
- int16_t bit_bdgt, sum_bit;
-
- incr = 1;
- if ( end_band < st_band )
- {
- incr = -1;
- }
-
- if ( bit_bdgt_in < sum_bit_in )
- {
- amount_to_add = -1;
- bit_bdgt = sum_bit_in;
- sum_bit = bit_bdgt_in;
- }
- else
- {
- bit_bdgt = bit_bdgt_in;
- sum_bit = sum_bit_in;
- amount_to_add = 1;
- }
+ /*--------------------------------------------------------------------------
+ * Recompute the real number/length of frequency bands to encode
+ *--------------------------------------------------------------------------*/
+ *nb_subbands = nb_bands;
+ move16();
+ *pvq_len = shl( *nb_subbands, 4 );
- i = st_band;
- while ( bit_bdgt > sum_bit )
+ /*--------------------------------------------------------------------------
+ * Concatenate bands (encoder only)
+ *--------------------------------------------------------------------------*/
+ IF( exc_diff != NULL )
{
- if ( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 1 ) )
+ FOR( j = 0; j < nb_bands; j++ )
{
- bits_per_bands[i] += amount_to_add;
- sum_bit += (int16_t) abs( amount_to_add );
- }
-
- i += incr;
- if ( i == end_band )
- {
- i = st_band;
+ Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 );
}
}
return;
}
-
-#endif
diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c
index 0ab1670151c5e748105ad5463fa21ba9232e3ed3..9243f640e890348f577688a0dc77aff03e10a148 100644
--- a/lib_com/gs_bitallocation_ivas_fx.c
+++ b/lib_com/gs_bitallocation_ivas_fx.c
@@ -2,13 +2,11 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot.h" /* Function prototypes */
-#include "prot_fx.h" /* Function prototypes */
-#include "ivas_prot.h" /* Function prototypes */
-#include "assert.h" /* Debug prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "assert.h" /* Debug prototypes */
#include "stl.h"
#include "ivas_prot_fx.h"
@@ -103,8 +101,8 @@ void bands_and_bit_alloc_ivas_fx(
Word16 etmp;
Word16 tmp;
Word16 pos, band;
- Word32 SWB_bit_budget; // Q0 -> Q18
- Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; // Q18
+ Word32 SWB_bit_budget; /* Q0 -> Q18 */
+ Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; /* Q18 */
Word16 w_sum_bit;
Word16 fzero_val;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
@@ -148,7 +146,7 @@ void bands_and_bit_alloc_ivas_fx(
move16();
bit_new_bands = 5;
move16();
-#if 1 // def ADD_LRTD
+
test();
if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) )
{
@@ -183,9 +181,6 @@ void bands_and_bit_alloc_ivas_fx(
}
bit_index = i_mult2( BRATE2IDX_fx( brate_intermed_tbl[i] ), 17 );
-#else
- bit_index = i_mult2( BRATE2IDX_fx( core_brate ), 17 );
-#endif
bit_index_mem = bit_index;
move16();
@@ -221,7 +216,6 @@ void bands_and_bit_alloc_ivas_fx(
move16();
}
-#if 1 // def ADD_LRTD
IF( EQ_16( L_frame, L_FRAME16k ) )
{
*bit = sub( *bit, 8 );
@@ -242,18 +236,12 @@ void bands_and_bit_alloc_ivas_fx(
nb_tot_bands = Find_bit_alloc_IVAS_fx( core_brate, GSC_IVAS_mode, Diff_len, nb_tot_bands, bit, max_ener_band, ener_vec, bits_per_bands );
nb_bands = nb_tot_bands;
}
- ELSE
-#endif
- IF( EQ_16( GSC_noisy_speech, 1 ) )
+ ELSE IF( EQ_16( GSC_noisy_speech, 1 ) )
{
SWB_bit_budget = *bit; /*Q0*/
move32();
nb_bands = 5;
move16();
-
-#if 1 // def ADD_LRTD
-
- // fzero_val = 0.0f;
fzero_val = 0;
move16();
@@ -281,8 +269,6 @@ void bands_and_bit_alloc_ivas_fx(
move16();
}
-#endif
-
st_band = nb_bands;
move16();
@@ -298,11 +284,10 @@ void bands_and_bit_alloc_ivas_fx(
move16();
max_ener_band[j] = i;
move16();
- // ener_vec[i] = 0;
ener_vec[i] = fzero_val;
move16();
}
-#if 1 // def ADD_LRTD
+
IF( LT_16( bwidth, SWB ) )
{
test();
@@ -311,17 +296,15 @@ void bands_and_bit_alloc_ivas_fx(
nb_tot_bands = 5;
move16();
}
-#endif
+
FOR( ; j < nb_bands; j++ )
{
i = maximum_fx( ener_vec, nb_tot_bands, &etmp );
max_ener_band[j] = i;
move16();
- // ener_vec[i] = 0;
ener_vec[i] = fzero_val;
move16();
}
-#if 1 // def ADD_LRTD
}
ELSE
{
@@ -334,7 +317,7 @@ void bands_and_bit_alloc_ivas_fx(
move16();
}
}
-#endif
+
set32_fx( bits_per_bands, bit_fracf, nb_bands );
}
ELSE
@@ -349,7 +332,7 @@ void bands_and_bit_alloc_ivas_fx(
move16();
st_band = 7;
move16();
-#if 1 // def ADD_LRTD
+
test();
IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) )
{
@@ -362,7 +345,7 @@ void bands_and_bit_alloc_ivas_fx(
bit_new_bands = 5;
move16();
}
-#endif
+
IF( LE_32( core_brate, ACELP_9k60 ) )
{
*pvq_len = 80;
@@ -384,9 +367,8 @@ void bands_and_bit_alloc_ivas_fx(
}
nb_bands = shr( *pvq_len, 4 );
-#if 1 // def ADD_LRTD
nb_bands_max = s_min( nb_bands_max, MBANDS_GN_BITALLOC16k );
-#endif
+
/*------------------------------------------------------------------------
* Ajustement of the maximum number of bands in function of the
* dynamics of the spectrum (more or less speech like)
@@ -398,7 +380,6 @@ void bands_and_bit_alloc_ivas_fx(
IF( coder_type == INACTIVE || GE_16( noise_lev, NOISE_LEVEL_SP3 ) )
{
/* Probably classification error -> concentrate bits on LF */
-#if 1 // def ADD_LRTD
IF( EQ_16( L_frame, L_FRAME16k ) && GE_32( core_brate, ACELP_24k40 ) )
{
nb_bands_max = sub( nb_tot_bands, 2 );
@@ -407,9 +388,7 @@ void bands_and_bit_alloc_ivas_fx(
{
nb_bands_max = add( nb_bands, 2 );
}
- ELSE
-#endif
- IF( GE_32( core_brate, ACELP_8k00 ) )
+ ELSE IF( GE_32( core_brate, ACELP_8k00 ) )
{
nb_bands_max = add( nb_bands, 1 );
}
@@ -428,7 +407,7 @@ void bands_and_bit_alloc_ivas_fx(
{
nb_bands_max = sub( nb_bands_max, 1 );
}
-#if 1 // def ADD_LRTD
+
IF( EQ_16( L_frame, L_FRAME16k ) )
{
IF( LT_32( core_brate, ACELP_24k40 ) )
@@ -450,7 +429,6 @@ void bands_and_bit_alloc_ivas_fx(
}
}
-#endif
test();
if ( ( bwidth == NB ) && GT_16( nb_bands_max, 10 ) )
{
@@ -472,7 +450,7 @@ void bands_and_bit_alloc_ivas_fx(
/*------------------------------------------------------------------------
* Fractional bits to distribute on the first x bands
*-----------------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
test();
IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) )
{
@@ -480,10 +458,10 @@ void bands_and_bit_alloc_ivas_fx(
move32();
}
ELSE
-#endif
{
bit_fracf = Find_bit_frac_fx( st_band, bit_tmp ); /*Q18*/
}
+
/*------------------------------------------------------------------------
* Complete the bit allocation per frequency band
*-----------------------------------------------------------------------*/
@@ -501,13 +479,12 @@ void bands_and_bit_alloc_ivas_fx(
move32(); /* Q18 */
bit_index = add( bit_index, 1 );
}
-#if 1 // def ADD_LRTD
+
IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) )
{
bit_index = 0;
move16();
i = sub( imax, 1 );
- // bits_per_bands[i] += Compl_GSC_freq_bits[bit_index];
bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( Compl_GSC_freq_bits[bit_index], Q18 ) ); /*Q18*/
move32();
i = add( i, 1 );
@@ -515,13 +492,12 @@ void bands_and_bit_alloc_ivas_fx(
FOR( ; i < 10; i++ )
{
- // bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf;
bits_per_bands[i] = L_add( bits_per_bands[i], L_add( L_shl( Compl_GSC_freq_bits[bit_index], Q18 ), bit_fracf ) ); /*Q18*/
move32();
bit_index = add( bit_index, 1 );
}
}
-#endif
+
IF( Diff_len == 0 )
{
bit_index = add( bit_index_mem, 10 );
@@ -532,7 +508,7 @@ void bands_and_bit_alloc_ivas_fx(
bit_index = add( bit_index, 1 );
}
}
-#if 1 // def ADD_LRTD
+
IF( bit_fracf < 0 )
{
FOR( j = 0; j < nb_tot_bands; j++ )
@@ -542,39 +518,33 @@ void bands_and_bit_alloc_ivas_fx(
}
}
-#endif
/*--------------------------------------------------------------------------
* Complete the bit allocation per frequency band for 16kHz high brate mode
*--------------------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
test();
IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) )
{
FOR( j = st_band; j < nb_bands; j++ )
{
- // bits_per_bands[j] = bit_new_bands;
bits_per_bands[j] = L_shl( bit_new_bands, Q18 );
move32();
}
- // bit_fracf = (1.0f / nb_bands) * (bit_tmp);
bit_fracf = L_shl( L_mult0( idiv1616( 16384, nb_bands ), bit_tmp ), 4 ); /*Q18*/
- // etmp = 2.0f * bit_fracf / (nb_bands + 1);
- etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); // Q15
- // bit_fracf = etmp;
- bit_fracf = L_shl( etmp, Q3 ); // Q18
+ etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); /* Q15 */
+
+ bit_fracf = L_shl( etmp, Q3 ); /* Q18 */
+
FOR( j = nb_bands - 1; j >= 0; j-- )
{
- // bits_per_bands[j] = etmp;
- // etmp += bit_fracf;
- bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); // Q18
+ bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); /* Q18 */
move32();
etmp = extract_l( L_add( etmp, L_shr( bit_fracf, Q3 ) ) );
}
}
ELSE
-#endif
{
FOR( j = st_band; j < nb_bands; j++ )
{
@@ -688,6 +658,7 @@ void bands_and_bit_alloc_ivas_fx(
}
}
}
+
/*--------------------------------------------------------------------------
* Bit sum verification for GSC inactive at very high rate
* The maximum number of bits per band of length 16 is 112
@@ -724,19 +695,20 @@ void bands_and_bit_alloc_ivas_fx(
move32(); /* Q18 */
}
}
+
/*--------------------------------------------------------------------------
* second step of bit sum verification, normally sum_bit == *bit
*--------------------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
sum_bit = 0;
move32();
FOR( i = 0; i < nb_bands; i++ )
{
- // bits_per_bands[i] = (float)floor(bits_per_bands[i]);
bits_per_bands[i] = L_shl( L_shr( bits_per_bands[i], Q18 ), Q18 );
move32();
sum_bit = L_add( sum_bit, L_shr( bits_per_bands[i], Q18 ) ); /*Q0*/
}
+
test();
IF( GSC_IVAS_mode != 0 && LT_32( sum_bit, *bit ) ) /* If we need to add bits, we are doing it on the LF */
{
@@ -755,23 +727,7 @@ void bands_and_bit_alloc_ivas_fx(
w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */
}
tmp = shl( *bit, 3 );
-#else
- IF( GT_16( tmp, w_sum_bit ) )
- {
- i = sub( nb_bands, 1 );
- move16();
- FOR( ; tmp > w_sum_bit; w_sum_bit += ( 1 << 3 ) )
- {
- out_bits_per_bands[i] = add( out_bits_per_bands[i], 1 << 3 );
- move16();
- i = sub( i, 1 );
- IF( i == 0 )
- {
- i = sub( nb_bands, 1 );
- }
- }
- }
-#endif
+
/*--------------------------------------------------------------------------
* Recompute the real number/length of frequency bands to encode
*--------------------------------------------------------------------------*/
@@ -790,7 +746,6 @@ void bands_and_bit_alloc_ivas_fx(
Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 );
}
}
-#if 1 // def ADD_LRTD
}
ELSE /* *bit == 0 */
{
@@ -800,10 +755,11 @@ void bands_and_bit_alloc_ivas_fx(
*pvq_len = 0;
move16();
}
-#endif
+
return;
}
-#if 1 // def ADD_LRTD
+
+
/*-------------------------------------------------------------------*
* reajust_bits()
*
@@ -924,26 +880,28 @@ static Word32 Find_bit_frac_fx(
return ( L_out );
}
-static Word16 Find_bit_alloc_IVAS_fx( /*o: Number of band to encode */
- const Word32 core_brate, /* i : core bit rate */
- const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
- const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/
- const Word16 nb_tot_bands_in, /* i : total number of band */
- Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
- Word16 *max_ener_band, /* i/o: Energy based sorted order */
- Word16 *ener_vec, /* i/o: Energy per band order */
- Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband Q18 */
+
+/* o : Number of band to encode */
+static Word16 Find_bit_alloc_IVAS_fx(
+ const Word32 core_brate, /* i : core bit rate */
+ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
+ const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/
+ const Word16 nb_tot_bands_in, /* i : total number of band */
+ Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
+ Word16 *max_ener_band, /* i/o: Energy based sorted order */
+ Word16 *ener_vec, /* i/o: Energy per band order */
+ Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband Q18 */
)
{
Word32 mp, mb, nb_bands_adj, bit_adj;
Word16 nb_pulse_per_band[MBANDS_GN_BITALLOC16k];
- Word32 SWB_bit_budget; // Q0 -> Q18
+ Word32 SWB_bit_budget; /* Q0 -> Q18 */
Word16 i, j, nb_bands_max, st_band, nb_tot_bands_loc, etmp;
Word32 sum_bit /*Q18*/, bit_fracf /*Q18*/;
Word16 d_tmp, e_div, tmp16;
Word32 Ltmp, etmp_32fx;
- SWB_bit_budget = *bit; // Q0
+ SWB_bit_budget = *bit; /* Q0 */
st_band = 5;
nb_bands_max = nb_tot_bands_in;
@@ -993,12 +951,12 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number
IF( EQ_16( GSC_IVAS_mode, 1 ) && LT_32( core_brate, GSC_L_RATE_STG ) )
{
/* nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;*/
- nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, Q18 ) ), Q18_0_75 ); // Q18
+ nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, Q18 ) ), Q18_0_75 ); /* Q18 */
}
ELSE IF( NE_16( GSC_IVAS_mode, 2 ) && GT_32( core_brate, GSC_H_RATE_STG ) )
{
/*nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;*/
- nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, Q18 ) ), Q18_1_2 ); // Q18
+ nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, Q18 ) ), Q18_1_2 ); /* Q18 */
}
/*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/
@@ -1131,7 +1089,7 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number
move32();
}
mb = L_sub( mb, bit_fracf );
- SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); // Q18
+ SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); /* Q18 */
}
}
@@ -1192,17 +1150,23 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number
move32();
}
}
+
return nb_tot_bands_loc;
}
-static Word16 Find_norm_inv_fx( const Word32 ToDivide, Word16 *e_div ) /* Find normalized 1 / ToDivide */
+
+/* Find normalized 1 / ToDivide */
+static Word16 Find_norm_inv_fx(
+ const Word32 ToDivide,
+ Word16 *e_div )
{
Word16 d_tmp, e_tmp;
+
e_tmp = norm_l( ToDivide );
d_tmp = round_fx( L_shl( ToDivide, e_tmp ) );
d_tmp = div_s( 16384, d_tmp ); /* 1.0 in Q14, dividend is normalize so >= 16384 as required for the division */
*e_div = sub( 14, e_tmp );
move16();
+
return d_tmp;
}
-#endif
diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c
index 9adb448a4b21203625d0bd16617464f47c9096f7..8fa7694755c7c5ac9f912f26abdff9211895ff07 100644
--- a/lib_com/gs_gains.c
+++ b/lib_com/gs_gains.c
@@ -39,7 +39,6 @@
#include
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
#include "prot_fx.h"
#include "wmc_auto.h"
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
index c0feb91f53993f4027fe1d1f6818023af94b5e13..54fef9e37ca4a881fd62c05b38e13e81d641476f 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -158,23 +158,18 @@ void Inac_swtch_ematch_fx(
void Inac_switch_ematch_ivas_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
-#ifdef NONBE_FIX_GSC_BSTR
+ Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
+ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
+ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
+ const Word16 coder_type, /* i : Coding mode */
const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
-#endif
- const Word16 L_frame, /* i : Frame lenght */
-#ifndef NONBE_FIX_GSC_BSTR
- const Word32 total_brate, /* i : total bit rate */
-#endif
- const Word16 Q_exc, /* i : input and output format of exc2 */
- const Word16 bfi, /* i : frame lost indicator */
- const Word16 last_core, /* i : Last core used */
- const Word16 last_codec_mode, /* i : Last codec mode */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const Word16 element_mode /* i : element mode */
+ const Word16 L_frame, /* i : Frame lenght */
+ const Word16 Q_exc, /* i : input and output format of exc2 */
+ const Word16 bfi, /* i : frame lost indicator */
+ const Word16 last_core, /* i : Last core used */
+ const Word16 last_codec_mode, /* i : Last codec mode */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
+ const Word16 element_mode /* i : element mode */
)
{
Word16 Ener_per_bd[MBANDS_GN16k];
@@ -224,11 +219,7 @@ void Inac_switch_ematch_ivas_fx(
move16();
}
}
-#ifdef NONBE_FIX_GSC_BSTR
ELSE IF( ( coder_type == INACTIVE ) && inactive_coder_type_flag )
-#else
- ELSE IF( ( coder_type == INACTIVE ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) )
-#endif
{
/* Find spectrum and energy per band for inactive frames */
edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode );
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
index d2a576dbe94521f4280f2ad50e0b3b6fbdf77a37..2e00e4641e177d2e17d2bbecbe6c93f93c522e1a 100644
--- a/lib_com/gs_noisefill_fx.c
+++ b/lib_com/gs_noisefill_fx.c
@@ -793,7 +793,6 @@ void highband_exc_dct_in_fx(
{
IF( exc_diffQ[i] == 0 )
{
- // PMT("code below to be validated for IVAS use")
/* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/
tmp = mult( shl( noisepb[0], 1 ), Random( seed_tcx ) ); /*Q15 */
tmp = shr( tmp, sub( 15, Qexc_diffQ ) ); /*qNoise_fac */
@@ -876,66 +875,7 @@ void highband_exc_dct_in_fx(
/*--------------------------------------------------------------------------------------*
* Apply decoded gain onto the difference signal
*--------------------------------------------------------------------------------------*/
-#ifdef ADD_LRTD
- if ( GSC_IVAS_mode >= 1 )
- {
- float scale_factLF = 0.9f;
- float scale_factHF = 0.9f;
-
- if ( GSC_IVAS_mode == 1 && GSC_noisy_speech == 0 )
- {
- scale_factHF = 0.8f;
- }
- else if ( GSC_IVAS_mode == 2 || GSC_noisy_speech == 1 )
- {
- scale_factHF = 0.71f;
- }
- else if ( GSC_IVAS_mode == 3 )
- {
- scale_factHF = 0.9f;
- }
- for ( i = 0; i < pit_band_idx * 16; i++ )
- {
- exc_diffQ[i] *= scale_factLF;
- }
- for ( ; i < L_frame; i++ )
- {
- exc_diffQ[i] *= scale_factHF;
- }
- }
- else if ( GSC_noisy_speech )
- {
- float scale_fact = 0.9f;
-
- if ( element_mode == IVAS_CPE_TD )
- {
- if ( coder_type == INACTIVE )
- {
- scale_fact = 1.0f;
- }
- else
- {
- scale_fact = 0.95f;
- }
- }
- else if ( element_mode > IVAS_SCE )
- {
- scale_fact = 0.71f;
- }
- for ( i = 0; i < L_frame; i++ )
- {
- exc_diffQ[i] *= scale_fact;
- }
- }
- if ( GSC_noisy_speech && element_mode > IVAS_SCE && core_brate < ACELP_7k20 )
- {
- for ( i = 80; i < L_frame; i++ )
- {
- exc_diffQ[i] *= ( +0.0024f * (float) i + 1.192f );
- }
- }
-#else
IF( GSC_noisy_speech )
{
FOR( i = 0; i < L_frame; i++ )
@@ -944,7 +884,7 @@ void highband_exc_dct_in_fx(
move16();
}
}
-#endif
+
Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc );
IF( exc_wo_nf != NULL )
@@ -1232,7 +1172,6 @@ void highband_exc_dct_in_ivas_fx(
{
IF( exc_diffQ[i] == 0 )
{
- // PMT("code below to be validated for IVAS use")
/* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/
tmp = mult( shl( noisepb[0], 1 ), Random( seed_tcx ) ); /*Q15 */
tmp = shr( tmp, sub( 15, Qexc_diffQ ) ); /*qNoise_fac */
@@ -1313,105 +1252,86 @@ void highband_exc_dct_in_ivas_fx(
}
}
}
+
/*--------------------------------------------------------------------------------------*
* Apply decoded gain onto the difference signal
*--------------------------------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
IF( GSC_IVAS_mode >= 1 )
{
- // float scale_factLF = 0.9f;
- Word16 scale_factLF = 29491;
+ Word16 scale_factLF = 29491; /* 0.9f */
move16();
- // float scale_factHF = 0.9f;
- Word16 scale_factHF = 29491;
+ Word16 scale_factHF = 29491; /* 0.9f */
move16();
test();
test();
IF( EQ_16( GSC_IVAS_mode, 1 ) && GSC_noisy_speech == 0 )
{
- // scale_factHF = 0.8f;
scale_factHF = 26214;
move16();
}
ELSE IF( EQ_16( GSC_IVAS_mode, 2 ) || EQ_16( GSC_noisy_speech, 1 ) )
{
- // scale_factHF = 0.71f;
- scale_factHF = 23265;
+ scale_factHF = 23265; /* 0.71f */
move16();
}
ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) )
{
- // scale_factHF = 0.9f;
- scale_factHF = 29491;
+ scale_factHF = 29491; /* 0.9f */
move16();
}
FOR( i = 0; i < pit_band_idx * 16; i++ )
{
- // exc_diffQ[i] *= scale_factLF;
exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factLF );
}
FOR( ; i < L_frame; i++ )
{
- // exc_diffQ[i] *= scale_factHF;
exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factHF );
move16();
}
}
ELSE IF( GSC_noisy_speech )
{
- // float scale_fact = 0.9f;
- Word16 scale_fact = 29491;
+ Word16 scale_fact = 29491; /* 0.9f */
move16();
IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
IF( coder_type == INACTIVE )
{
- // scale_fact = 1.0f;
- scale_fact = 32767;
+ scale_fact = 32767; /* 1.0f */
move16();
}
ELSE
{
- // scale_fact = 0.95f;
- scale_fact = 31129;
+ scale_fact = 31129; /* 0.95f */
move16();
}
}
ELSE IF( GT_16( element_mode, IVAS_SCE ) )
{
- // scale_fact = 0.71f;
- scale_fact = 23265;
+ scale_fact = 23265; /* 0.71f */
move16();
}
FOR( i = 0; i < L_frame; i++ )
{
- // exc_diffQ[i] *= scale_fact;
exc_diffQ[i] = mult_r( exc_diffQ[i], scale_fact );
move16();
}
}
+
IF( GSC_noisy_speech && GT_16( element_mode, IVAS_SCE ) && LT_32( core_brate, ACELP_7k20 ) )
{
FOR( i = 80; i < L_frame; i++ )
{
- // exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f);
+ /* exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f); */
exc_diffQ[i] = mult_r( shl( exc_diffQ[i], 1 ) /*Q16*/, (Word16) L_shr( L_add( 629 * i, 312475 ) /*Q18*/, Q4 ) /*Q14*/ );
move16();
}
}
-#else
- IF( GSC_noisy_speech )
- {
- FOR( i = 0; i < L_frame; i++ )
- {
- exc_diffQ[i] = mult_r( exc_diffQ[i], 29491 );
- move16();
- }
- }
-#endif
+
Word16 Q_tmp = *Q_exc;
move16();
Word16 Q_old = *Q_exc;
diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c
deleted file mode 100644
index 58b49172d76f012203cbab808f6f64fb103d74d5..0000000000000000000000000000000000000000
--- a/lib_com/gs_preech.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * Local constants
- *-------------------------------------------------------------------*/
-
-#define ATT_LENGHT16k 80
-#ifndef IVAS_FLOAT_FIXED
-#define INV_L_FRAME16k ( 1.0f / L_FRAME16k )
-#endif
-
-#define ATT_LENGHT 64
-#define ATT_SEG_LEN ( L_FRAME / ATT_LENGHT )
-
-#ifndef IVAS_FLOAT_FIXED
-#define INV_ATT_SEG_LEN ( 1.0f / ATT_SEG_LEN )
-#define INV_L_FRAME ( 1.0f / L_FRAME )
-#endif
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * pre_echo_att()
- *
- * Attenuation of the pre-echo when encoder specifies an attack
- *-------------------------------------------------------------------*/
-
-void pre_echo_att(
- float *Last_frame_ener, /* i/o: Energy of the last frame */
- float *exc, /* i/o: Excitation of the current frame */
- const int16_t attack_flag, /* i : attack flag (GSC or TC) */
- const int16_t last_coder_type, /* i : Last coder type */
- const int16_t L_frame /* i : frame length */
-)
-{
- float etmp;
- float etmp1;
- float finc[ATT_LENGHT16k], ratio_float, inv_l_frame;
- int16_t att_len;
- int16_t attack_pos, i;
-
- if ( attack_flag > 0 && last_coder_type == AUDIO )
- {
- /*-------------------------------------------------------------------------*
- * Find where the onset (attack) occurs by computing the energy per section
- * The inverse weighting aims to favor the first maxima in case of
- * gradual onset
- *-------------------------------------------------------------------------*/
-
- att_len = ATT_LENGHT;
- if ( L_frame == L_FRAME16k )
- {
- att_len = ATT_LENGHT16k;
- }
- for ( i = 0; i < att_len; i++ )
- {
- finc[i] = sum2_f( exc + i * ATT_SEG_LEN, ATT_SEG_LEN ) * ( (float) ( att_len - i ) / ( att_len ) );
- }
- etmp = -1;
- attack_pos = maximum( finc, att_len, &etmp );
-
- /* Scaled the maximum energy and allowed 6 dB increase*/
- etmp *= INV_ATT_SEG_LEN;
- etmp1 = etmp;
- *Last_frame_ener *= 4.0f;
-
- /* If the maximum normalized energy > last frame energy + 6dB */
- if ( etmp > *Last_frame_ener && attack_pos > 0 )
- {
- /* Find the average energy before the attack */
- etmp = sum_f( finc, attack_pos ) + 0.01f;
- etmp /= ( attack_pos * ATT_SEG_LEN );
-
- /* Find the correction factor and apply it before the attack */
- ratio_float = (float) sqrt( *Last_frame_ener / etmp );
-
-
- /* Pre-echo atttenuation should never increase the energy */
- ratio_float = min( ratio_float, 1.0f );
- for ( i = 0; i < attack_pos * ATT_SEG_LEN; i++ )
- {
- exc[i] *= ratio_float;
- }
- }
- *Last_frame_ener = etmp1;
- }
- else
- {
- /*-------------------------------------------------------*
- * In normal cases, just compute the energy of the frame
- *-------------------------------------------------------*/
-
- etmp = sum2_f( exc, L_frame ) + 0.01f;
- inv_l_frame = INV_L_FRAME;
- if ( L_frame == L_FRAME16k )
- {
- inv_l_frame = INV_L_FRAME16k;
- }
- etmp *= inv_l_frame;
- *Last_frame_ener = etmp;
- }
-
- return;
-}
-#endif
-
-void pre_echo_att_fx(
- Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
- Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
- const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/
- const Word16 Q_new,
- const Word16 last_coder_type, /* i : Last coding mode Q0*/
- const Word16 L_frame /* i : Frame length Q0*/
-)
-{
- Word32 etmp_fx;
- Word32 finc_fx[ATT_LENGHT16k] = { 0 };
- move16();
- Word16 ratio_fx;
- Word16 attack_pos_fx, i;
- Word32 L_tmp, L_tmp1;
- Word16 tmp, n1, n2, exp, frac1, frac2;
- Word32 etmp1_fx;
- Word16 att_len;
-
- test();
- IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */
- {
- /*-------------------------------------------------------------------------*
- * Find where the onset (attack) occurs by computing the energy per section
- * The inverse weighting aims to favor the first maxima in case of
- * gradual onset
- *-------------------------------------------------------------------------*/
- att_len = ATT_LENGHT; /* Q0 */
- move16();
- if ( EQ_16( L_frame, L_FRAME16k ) )
- {
- att_len = ATT_LENGHT16k; /* Q0 */
- move16();
- }
- FOR( i = 0; i < att_len; i++ )
- {
- L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/
- tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */
- L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */
- finc_fx[i] = L_tmp;
- move32(); /*2*Q_new+1 */
- }
-
- attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx );
-
- /* Scaled the maximum energy and allowed 6 dB increase*/
- etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */
- etmp1_fx = etmp_fx;
- move32();
- *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 );
- move32(); /*2*Q_new+1 */
-
- /* If the maximum normalized energy > last frame energy + 6dB */
- test();
- IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 )
- {
- /* Find the average energy before the attack */
- L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */
- L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */
- tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */
- L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */
- etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */
-
- etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */
- /* Find the correction factor and apply it before the attack */
- /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/
- /* = isqrt(etmp/(*Last_frame_ener)) */
- etmp_fx = L_max( etmp_fx, 1 );
- *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
- move32();
- n1 = norm_l( etmp_fx );
- n2 = norm_l( *Last_frame_ener_fx );
-
- n1 = sub( n1, 1 );
- exp = sub( n1, n2 );
-
- frac1 = round_fx( L_shl( etmp_fx, n1 ) );
- frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) );
- L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */
- L_tmp = L_shr( L_tmp, exp ); /* add exponent */
-
- L_tmp = Isqrt( L_tmp );
- ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */
-
- /* Pre-echo atttenuation should never increase the energy */
- ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */
- FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ )
- {
- /*exc_fx[i] *= ratio_fx;*/
- exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) );
- move16();
- }
- }
- *Last_frame_ener_fx = etmp1_fx; /*2*Q_new+1*/
- move32();
- }
- ELSE
- {
- /*-------------------------------------------------------*
- * In normal cases, just compute the energy of the frame
- *-------------------------------------------------------*/
-
- etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */
-#ifdef ADD_LRTD
- PMTE()
- etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
-#else
- etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
-#endif
- *Last_frame_ener_fx = etmp_fx;
- move32(); /*2*Q_new+1*/
- }
-
- return;
-}
-
-
-void pre_echo_att_ivas_fx(
- Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
- Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
- const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/
- const Word16 Q_new,
- const Word16 last_coder_type, /* i : Last coding mode Q0*/
- const Word16 L_frame /* i : Frame length Q0*/
-)
-{
- Word32 etmp_fx;
- Word32 finc_fx[ATT_LENGHT16k] = { 0 };
- move16();
- Word16 ratio_fx;
- Word16 attack_pos_fx, i;
- Word32 L_tmp, L_tmp1;
- Word16 tmp, n1, n2, exp, frac1, frac2;
- Word32 etmp1_fx;
- Word16 att_len;
-
- test();
- IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */
- {
- /*-------------------------------------------------------------------------*
- * Find where the onset (attack) occurs by computing the energy per section
- * The inverse weighting aims to favor the first maxima in case of
- * gradual onset
- *-------------------------------------------------------------------------*/
- att_len = ATT_LENGHT; /* Q0 */
- move16();
- if ( EQ_16( L_frame, L_FRAME16k ) )
- {
- att_len = ATT_LENGHT16k; /* Q0 */
- move16();
- }
- FOR( i = 0; i < att_len; i++ )
- {
- L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/
- tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */
- L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */
- finc_fx[i] = L_tmp;
- move32(); /*2*Q_new+1 */
- }
-
- attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx );
-
- /* Scaled the maximum energy and allowed 6 dB increase*/
- etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */
- etmp1_fx = etmp_fx;
- move32();
- *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 );
- move32(); /*2*Q_new+1 */
-
- /* If the maximum normalized energy > last frame energy + 6dB */
- test();
- IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 )
- {
- /* Find the average energy before the attack */
- L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */
- L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */
- tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */
- L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */
- etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */
-
- etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */
- /* Find the correction factor and apply it before the attack */
- /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/
- /* = isqrt(etmp/(*Last_frame_ener)) */
- etmp_fx = L_max( etmp_fx, 1 );
- *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
- move32();
- n1 = norm_l( etmp_fx );
- n2 = norm_l( *Last_frame_ener_fx );
-
- n1 = sub( n1, 1 );
- exp = sub( n1, n2 );
-
- frac1 = round_fx( L_shl( etmp_fx, n1 ) );
- frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) );
- L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */
- L_tmp = L_shr( L_tmp, exp ); /* add exponent */
-
- L_tmp = Isqrt( L_tmp );
- ratio_fx = round_fx( L_shl( L_tmp, 9 ) );
-
- /* Pre-echo atttenuation should never increase the energy */
- ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */
- FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ )
- {
- /*exc_fx[i] *= ratio_fx;*/
- exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) );
- move16();
- }
- }
- *Last_frame_ener_fx = etmp1_fx; /* 2 * Q_new + 1 */
- move32();
- }
- ELSE
- {
- /*-------------------------------------------------------*
- * In normal cases, just compute the energy of the frame
- *-------------------------------------------------------*/
- Word16 exp_etmp = sub( 15, Q_new );
- etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */
-
- etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/
- }
- *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/
- move32(); /*2*Q_new+1*/
- }
-
- return;
-}
diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c
index 9d905bcf290d87170d612499c3fa426e167d7a99..3b3eaa7776b9ff3c7403e4cb7f30decf8bf77a2b 100644
--- a/lib_com/gs_preech_fx.c
+++ b/lib_com/gs_preech_fx.c
@@ -39,9 +39,8 @@
#include
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
/*-------------------------------------------------------------------*
* Local constants
@@ -154,13 +153,8 @@ void pre_echo_att_fx(
* In normal cases, just compute the energy of the frame
*-------------------------------------------------------*/
- etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */
-#ifdef ADD_LRTD
- PMTE()
- etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
-#else
+ etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */
etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
-#endif
*Last_frame_ener_fx = etmp_fx;
move32(); /*2*Q_new+1*/
}
diff --git a/lib_com/hp50.c b/lib_com/hp50.c
deleted file mode 100644
index 6920063d42ab74e6fa769c49dbc4ea397580ba2d..0000000000000000000000000000000000000000
--- a/lib_com/hp50.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-/*
- * hp20
- *
- * Function:
- * 2nd order high pass filter with nominal cut off frequency at 20 Hz.
- *
- * Returns:
- * void
- */
-
-#ifndef IVAS_FLOAT_FIXED
-void hp20_flt(
- Float32 signal[],
- const Word16 lg,
- Float32 mem[],
- const Word32 Fs )
-{
- Word16 i;
- Float32 x0, x1, x2, y0, y1, y2;
- Float32 a1, a2, b1, b2;
-
- y1 = mem[0];
- y2 = mem[1];
- x0 = mem[2];
- x1 = mem[3];
-
- if ( Fs == 8000 )
- {
- /* hp filter 20Hz at 3dB for 8000KHz input sampling rate
- [b,a] = butter(2, 20.0/4000.0, 'high');
- b = [0.988954248067140 -1.977908496134280 0.988954248067140]
- a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/
- a1 = 1.977786483776764f;
- a2 = -0.978030508491796f;
- b1 = -1.977908496134280f;
- b2 = 0.988954248067140f;
- }
- else if ( Fs == 16000 )
- {
- /* hp filter 20Hz at 3dB for 16000KHz sampling rate
- [b,a] = butter(2, 20.0/8000.0, 'high');
- b =[ 0.994461788958195 -1.988923577916390 0.994461788958195]
- a =[1.000000000000000 -1.988892905899653 0.988954249933127] */
- a1 = 1.988892905899653f;
- a2 = -0.988954249933127f;
- b1 = -1.988923577916390f;
- b2 = 0.994461788958195f;
- }
- else if ( Fs == 32000 )
- {
- /* hp filter 20Hz at 3dB for 32000KHz sampling rate
- [b,a] = butter(2, 20.0/16000.0, 'high');
- b =[0.997227049904470 -1.994454099808940 0.997227049904470]
- a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/
- a1 = 1.994446410541927f;
- a2 = -0.994461789075954f;
- b1 = -1.994454099808940f;
- b2 = 0.997227049904470f;
- }
- else
- {
- /* hp filter 20Hz at 3dB for 48000KHz sampling rate
- [b,a] = butter(2, 20.0/24000.0, 'high');
- b =[ 0.998150511190452 -1.996301022380904 0.998150511190452]
- a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
- a1 = 1.996297601769122f;
- a2 = -0.996304442992686f;
- b1 = -1.996301022380904f;
- b2 = 0.998150511190452f;
- }
-
- for ( i = 0; i < lg; i++ )
- {
- x2 = x1;
- x1 = x0;
- x0 = signal[i];
- y0 = ( y1 * a1 ) + ( y2 * a2 ) + ( x0 * b2 ) + ( x1 * b1 ) + ( x2 * b2 );
- signal[i] = y0;
- y2 = y1;
- y1 = y0;
- }
-
- mem[0] = ( ( y1 > 1e-10 ) | ( y1 < -1e-10 ) ) ? y1 : 0;
- mem[1] = ( ( y2 > 1e-10 ) | ( y2 < -1e-10 ) ) ? y2 : 0;
- mem[2] = ( ( x0 > 1e-10 ) | ( x0 < -1e-10 ) ) ? x0 : 0;
- mem[3] = ( ( x1 > 1e-10 ) | ( x1 < -1e-10 ) ) ? x1 : 0;
-
- return;
-}
-#endif
-
-
-#define HP20_COEFF_SCALE ( 2 )
-/*
- * hp20
- *
- * Function:
- * 2nd order high pass filter with nominal cut off frequency at 20 Hz.
- *
- * Returns:
- * void
- */
-
-static Word32 HP50_Mode2_Mpy_32_16_fix( Word32 a, Word16 b )
-{
- Word32 result = Mpy_32_16_1( a, b );
- /* perform rounding towards lower value for negative results */
- if ( result < 0 )
- result = L_add( result, 1 );
- return result;
-}
-
-static Word32 HP50_Mpy_32_32_fix( Word32 a, Word32 b )
-{
- Word32 result = Mpy_32_32( a, b );
- /* perform rounding towards lower value for negative results */
- if ( result < 0 )
- result = L_add( result, 1 );
- return result;
-}
-
-
-static void filter_2nd_order(
- Word16 signal[],
- const Word16 stride,
- const Word16 prescale,
- const Word16 lg,
- Word32 mem[4],
- Word32 a1,
- Word32 a2,
- Word32 b1,
- Word32 b2 )
-{
-
- Word16 i;
- Word16 x2, x1;
- Word32 L_sum, L_y1, L_y2;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
-#endif
-
-
- /*
- * Saturation: The states of the filter, namely L_y1 and L_y2 shall
- * never saturate, because that causes error in the filter feedback.
- * The final output written into signal[] might saturate because of
- * unavoidable filter overshoot.
- */
-
- /* Execute first 2 iterations with 32-bit x anx y memory values */
- BASOP_SATURATE_ERROR_ON_EVS
- L_sum = HP50_Mpy_32_32_fix( b2, mem[2] ); /* b2*x2 */
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( b1, mem[3] ) ); /* b1*x1 */
- x2 = shr( signal[0], prescale );
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) ); /* b2*x0 */
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) ); /* y2*a2 */
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) ); /* y1*a1 */
-
- L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
- BASOP_SATURATE_ERROR_OFF_EVS
- BASOP_SATURATE_WARNING_OFF_EVS
- signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
- BASOP_SATURATE_WARNING_ON_EVS
-
- BASOP_SATURATE_ERROR_ON_EVS
- L_sum = HP50_Mpy_32_32_fix( b2, mem[3] ); /* b2*x2 */
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); /* b1*x1 */
- x1 = shr( signal[stride], prescale );
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) ); /* b2*x0 */
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) ); /* y2*a2 */
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); /* y1*a1 */
-
- L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
- BASOP_SATURATE_ERROR_OFF_EVS
- BASOP_SATURATE_WARNING_OFF_EVS
- signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
- BASOP_SATURATE_WARNING_ON_EVS
- move16();
-
- /* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */
- FOR( i = 2; i < lg; i += 2 )
- {
- /* y[i+0] = b2*x[i-2] + b1*x[i-1] + b2*x[i-0] + a2*y[i-2] + a1*y[i-1]; */
- BASOP_SATURATE_ERROR_ON_EVS
- L_sum = HP50_Mode2_Mpy_32_16_fix( b2, x2 );
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x1 ) );
- x2 = shr( signal[i * stride], prescale );
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) );
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a2 ) );
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a1 ) );
-
- L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
- BASOP_SATURATE_ERROR_OFF_EVS
- BASOP_SATURATE_WARNING_OFF_EVS
- signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
- BASOP_SATURATE_WARNING_ON_EVS
- /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */
- BASOP_SATURATE_ERROR_ON_EVS
- L_sum = HP50_Mode2_Mpy_32_16_fix( b2, x1 );
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) );
- x1 = shr( signal[( i + 1 ) * stride], prescale );
- L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) );
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a2 ) );
- L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) );
-
- L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
- BASOP_SATURATE_ERROR_OFF_EVS
- BASOP_SATURATE_WARNING_OFF_EVS
- signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
- BASOP_SATURATE_WARNING_ON_EVS
- move16();
- }
- /* update static filter memory from variables */
- mem[0] = L_y2;
- move32();
- mem[1] = L_y1;
- move32();
- mem[2] = L_deposit_h( x2 );
- move32();
- mem[3] = L_deposit_h( x1 );
- move32();
-
-
- return;
-}
-
-
-void hp20( Word16 signal[], /* i/o: signal to filter any */
- const Word16 stride, /* i : stride to be applied accessing signal */
- const Word16 lg, /* i : length of signal (integer) Q0 */
- Word32 mem[5], /* i/o: static filter memory with this layout: */
- /* mem[0]: y[-2] (32-bit) */
- /* mem[1]; y[-1] (32-bit) */
- /* mem[2]: x[-2] << 16 */
- /* mem[3]: x[-1] << 16 */
- /* Note: mem[0..3] need to be scaled per frame */
- /* mem[4]: states scale */
- const Word32 sFreq ) /* i : input sampling rate Q0 */
-{
- Word32 a1, b1, a2, b2;
- Word16 prescale, prescaleOld, diff;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
-#endif
-
-
- prescale = getScaleFactor16( signal, lg );
- prescaleOld = extract_l( mem[4] );
- diff = norm_l( L_shl_sat( mem[2], prescaleOld ) );
- if ( mem[2] != 0 )
- {
- prescale = s_min( prescale, diff );
- }
- diff = norm_l( L_shl_o( mem[3], prescaleOld, &Overflow ) );
- if ( mem[3] != 0 )
- {
- prescale = s_min( prescale, diff );
- }
- /* Take into account the left shift performed into the loop + 1 bit headroom*/
- prescale = s_max( -12, sub( 1 + HP20_COEFF_SCALE, prescale ) );
- IF( prescale != prescaleOld )
- {
- diff = sub( prescale, prescaleOld );
- mem[0] = L_shr_o( mem[0], diff, &Overflow );
- move32();
- mem[1] = L_shr_o( mem[1], diff, &Overflow );
- move32();
- mem[2] = L_shr_o( mem[2], diff, &Overflow );
- move32();
- mem[3] = L_shr_o( mem[3], diff, &Overflow );
- move32();
- mem[4] = L_deposit_l( prescale );
- }
-
- IF( EQ_32( sFreq, 8000 ) )
- {
- /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate
- [b,a] = butter(2, 20.0/4000.0, 'high');
- b = [0.988954248067140 -1.977908496134280 0.988954248067140]
- a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/
- a1 = 1061816033l /* 1.977786483776764 Q29*/;
- move32();
- a2 = -525076131l /*-0.978030508491796 Q29*/;
- move32();
- b1 = -1061881538l /*-1.977908496134280 Q29*/;
- move32();
- b2 = 530940769l /* 0.988954248067140 Q29*/;
- move32();
- }
- ELSE IF( EQ_32( sFreq, 16000 ) )
- {
- /* hp filter 20Hz at 3dB for 16000KHz sampling rate
- [b,a] = butter(2, 20.0/8000.0, 'high');
- b = [0.994461788958195 -1.988923577916390 0.994461788958195]
- a = [1.000000000000000 -1.988892905899653 0.988954249933127] */
- a1 = 1067778748l /* 1.988892905899653 Q29*/;
- move32();
- a2 = -530940770l /*-0.988954249933127 Q29*/;
- move32();
- b1 = -1067795215l /*-1.988923577916390 Q29*/;
- move32();
- b2 = 533897608l /* 0.994461788958195 Q29*/;
- move32();
- }
- ELSE IF( EQ_32( sFreq, 32000 ) )
- {
- /* hp filter 20Hz at 3dB for 32000KHz sampling rate
- [b,a] = butter(2, 20.0/16000.0, 'high');
- b = [0.997227049904470 -1.994454099808940 0.997227049904470]
- a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/
- a1 = 1070760263l /* 1.994446410541927 Q29*/;
- move32();
- a2 = -533897608l /*-0.994461789075954 Q29*/;
- move32();
- b1 = -1070764392l /*-1.994454099808940 Q29*/;
- move32();
- b2 = 535382196l /* 0.997227049904470 Q29*/;
- move32();
- }
- ELSE
- {
- assert( sFreq == 48000 );
- /* hp filter 20Hz at 3dB for 48000KHz sampling rate
- [b,a] = butter(2, 20.0/24000.0, 'high');
- b =[0.998150511190452 -1.996301022380904 0.998150511190452]
- a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
- a1 = 1071754114l /* 1.996297601769122 Q29*/;
- move32();
- a2 = -534886875l /*-0.996304442992686 Q29*/;
- move32();
- b1 = -1071755951l /*-1.996301022380904 Q29*/;
- move32();
- b2 = 535877975l /* 0.998150511190452 Q29*/;
- move32();
- }
-
-
- filter_2nd_order( signal, stride, prescale, lg,
- mem, a1, a2, b1, b2 );
-
- return;
-}
-
-
-#ifdef HP20_FIX32_RECODING
-void hp20_fx_32(
- Word32 signal_fx[],
- const Word16 lg,
- Word32 mem_fx[],
- const Word32 Fs )
-{
- Word32 i;
- Word32 a1_fx, a2_fx, b1_fx, b2_fx;
- Word32 diff_pos, diff_neg;
- Flag Overflow = 0;
- Word16 prescale, prescaleOld, prescale_current_frame, diff;
-
- prescale = getScaleFactor32( signal_fx, lg );
- prescale_current_frame = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) );
-
-
- prescaleOld = extract_l( mem_fx[4] );
-
- diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) );
- diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) );
-
- diff = L_max( diff_pos, diff_neg );
-
- IF( NE_16( diff, 0 ) )
- {
- prescale = s_min( prescale, diff );
- }
-
- prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) );
-
- diff = sub( prescale, prescaleOld );
- mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow );
- move32();
- mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow );
- move32();
- mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow );
- move32();
- mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow );
- move32();
- mem_fx[4] = L_deposit_l( prescale_current_frame );
- move32();
-
- IF( EQ_32( Fs, 8000 ) )
- {
- /* hp filter 20Hz at 3dB for 8000KHz input sampling rate
- [b,a] = butter(2, 20.0/4000.0, 'high');
- b = [0.988954248067140 -1.977908496134280 0.988954248067140]
- a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/
- a1_fx = 1061816033l /* 1.977786483776764 Q29*/;
- a2_fx = -525076131l /*-0.978030508491796 Q29*/;
- b1_fx = -1061881538l /*-1.977908496134280 Q29*/;
- b2_fx = 530940769l /* 0.988954248067140 Q29*/;
- }
- ELSE IF( EQ_32( Fs, 16000 ) )
- {
- /* hp filter 20Hz at 3dB for 16000KHz sampling rate
- [b,a] = butter(2, 20.0/8000.0, 'high');
- b =[ 0.994461788958195 -1.988923577916390 0.994461788958195]
- a =[1.000000000000000 -1.988892905899653 0.988954249933127] */
- a1_fx = 1067778748l /* 1.988892905899653 Q29*/;
- a2_fx = -530940770l /*-0.988954249933127 Q29*/;
- b1_fx = -1067795215l /*-1.988923577916390 Q29*/;
- b2_fx = 533897608l /* 0.994461788958195 Q29*/;
- }
- ELSE IF( EQ_32( Fs, 32000 ) )
- {
- /* hp filter 20Hz at 3dB for 32000KHz sampling rate
- [b,a] = butter(2, 20.0/16000.0, 'high');
- b =[0.997227049904470 -1.994454099808940 0.997227049904470]
- a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/
- a1_fx = 1070760263l /* 1.994446410541927 Q29*/;
- a2_fx = -533897608l /*-0.994461789075954 Q29*/;
- b1_fx = -1070764392l /*-1.994454099808940 Q29*/;
- b2_fx = 535382196l /* 0.997227049904470 Q29*/;
- }
- ELSE
- {
- /* hp filter 20Hz at 3dB for 48000KHz sampling rate
- [b,a] = butter(2, 20.0/24000.0, 'high');
- b =[ 0.998150511190452 -1.996301022380904 0.998150511190452]
- a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
- a1_fx = 1071754114l /* 1.996297601769122 Q29*/;
- a2_fx = -534886875l /*-0.996304442992686 Q29*/;
- b1_fx = -1071755951l /*-1.996301022380904 Q29*/;
- b2_fx = 535877975l /* 0.998150511190452 Q29*/;
- }
- move32();
- move32();
- move32();
- move32();
- Word64 W_sum, W_y0, W_y1, W_y2;
- Word32 x0, x1, x2;
-
- W_sum = W_mult_32_32( b2_fx, mem_fx[2] ); /* b2*x2 */
- W_sum = W_mac_32_32( W_sum, b1_fx, mem_fx[3] ); /* b1*x1 */
- x2 = L_shr( signal_fx[0], prescale );
- W_sum = W_mac_32_32( W_sum, b2_fx, x2 ); /* b2*x0 */
- W_sum = W_mac_32_32( W_sum, mem_fx[0], a2_fx ); /* y2*a2 */
- W_sum = W_mac_32_32( W_sum, mem_fx[1], a1_fx ); /* y1*a1 */
- W_y2 = W_shl( W_sum, HP20_COEFF_SCALE );
- signal_fx[0] = W_extract_h( W_shl( W_y2, prescale ) );
- move32();
-
- W_sum = W_mult_32_32( b2_fx, mem_fx[3] ); /* b2*x2 */
- W_sum = W_mac_32_32( W_sum, b1_fx, x2 ); /* b1*x1 */
- x1 = L_shr( signal_fx[1], prescale );
- W_sum = W_mac_32_32( W_sum, b2_fx, x1 ); /* b2*x0 */
- W_sum = W_mac_32_32( W_sum, mem_fx[1], a2_fx ); /* y2*a2 */
- W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a1_fx ); /* y1*a1 */
- W_y1 = W_shl( W_sum, HP20_COEFF_SCALE );
- signal_fx[1] = W_extract_h( W_shl( W_y1, prescale ) );
- move32();
-
- diff = sub( prescale_current_frame, prescale );
- W_y1 = W_shr( W_y1, diff );
- W_y2 = W_shr( W_y2, diff );
- x2 = L_shr( x2, diff );
- x1 = L_shr( x1, diff );
-
- FOR( i = 2; i < lg; i++ )
- {
- W_sum = W_mult_32_32( b2_fx, x2 ); /* b2*x2 */
- W_sum = W_mac_32_32( W_sum, b1_fx, x1 ); /* b1*x1 */
- x0 = L_shr( signal_fx[i], prescale_current_frame );
- W_sum = W_mac_32_32( W_sum, b2_fx, x0 ); /* b2*x0 */
- W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a2_fx ); /* y2*a2 */
- W_sum = W_mac_32_32( W_sum, W_extract_h( W_y1 ), a1_fx ); /* y1*a1 */
- W_y0 = W_shl( W_sum, HP20_COEFF_SCALE );
-
- signal_fx[i] = W_extract_h( W_shl( W_y0, prescale_current_frame ) );
- move32();
-
- x2 = x1;
- x1 = x0;
- W_y2 = W_y1;
- W_y1 = W_y0;
-
- move32();
- move32();
- move64();
- move64();
- }
-
- mem_fx[0] = W_extract_h( W_y2 );
- mem_fx[1] = W_extract_h( W_y1 );
- mem_fx[2] = x2;
- mem_fx[3] = x1;
-
- move32();
- move32();
- move32();
- move32();
-
- return;
-}
-#else
-void hp20_fx_32(
- Word32 signal_fx[],
- const Word16 lg,
- Word32 mem_fx[],
- const Word32 Fs )
-{
- Word16 i;
- Word32 a1_fx, a2_fx, b1_fx, b2_fx;
- Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin;
- Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5;
-
- IF( EQ_32( Fs, 8000 ) )
- {
- /* hp filter 20Hz at 3dB for 8000KHz input sampling rate
- [b,a] = butter(2, 20.0/4000.0, 'high');
- b = [0.988954248067140 -1.977908496134280 0.988954248067140]
- a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/
- a1_fx = 1061816033l /* 1.977786483776764 Q29*/;
- a2_fx = -525076131l /*-0.978030508491796 Q29*/;
- b1_fx = -1061881538l /*-1.977908496134280 Q29*/;
- b2_fx = 530940769l /* 0.988954248067140 Q29*/;
- }
- ELSE IF( EQ_32( Fs, 16000 ) )
- {
- /* hp filter 20Hz at 3dB for 16000KHz sampling rate
- [b,a] = butter(2, 20.0/8000.0, 'high');
- b =[ 0.994461788958195 -1.988923577916390 0.994461788958195]
- a =[1.000000000000000 -1.988892905899653 0.988954249933127] */
- a1_fx = 1067778748l /* 1.988892905899653 Q29*/;
- a2_fx = -530940770l /*-0.988954249933127 Q29*/;
- b1_fx = -1067795215l /*-1.988923577916390 Q29*/;
- b2_fx = 533897608l /* 0.994461788958195 Q29*/;
- }
- ELSE IF( EQ_32( Fs, 32000 ) )
- {
- /* hp filter 20Hz at 3dB for 32000KHz sampling rate
- [b,a] = butter(2, 20.0/16000.0, 'high');
- b =[0.997227049904470 -1.994454099808940 0.997227049904470]
- a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/
- a1_fx = 1070760263l /* 1.994446410541927 Q29*/;
- a2_fx = -533897608l /*-0.994461789075954 Q29*/;
- b1_fx = -1070764392l /*-1.994454099808940 Q29*/;
- b2_fx = 535382196l /* 0.997227049904470 Q29*/;
- }
- ELSE
- {
- /* hp filter 20Hz at 3dB for 48000KHz sampling rate
- [b,a] = butter(2, 20.0/24000.0, 'high');
- b =[ 0.998150511190452 -1.996301022380904 0.998150511190452]
- a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
- a1_fx = 1071754114l /* 1.996297601769122 Q29*/;
- a2_fx = -534886875l /*-0.996304442992686 Q29*/;
- b1_fx = -1071755951l /*-1.996301022380904 Q29*/;
- b2_fx = 535877975l /* 0.998150511190452 Q29*/;
- }
- move32();
- move32();
- move32();
- move32();
-
- Qprev_y1 = extract_l( mem_fx[4] );
- Qprev_y2 = extract_l( mem_fx[5] );
- y1_fx64 = W_deposit32_l( mem_fx[0] );
- y2_fx64 = W_deposit32_l( mem_fx[1] );
- x0_fx64 = W_deposit32_l( mem_fx[2] );
- x1_fx64 = W_deposit32_l( mem_fx[3] );
-
- FOR( i = 0; i < lg; i++ )
- {
- x2_fx64 = x1_fx64;
- move64();
- x1_fx64 = x0_fx64;
- move64();
- x0_fx64 = W_deposit32_l( signal_fx[i] );
-
- Qy1 = W_norm( y1_fx64 );
- if ( y1_fx64 == 0 )
- {
- Qy1 = 62;
- move16();
- }
- Qy1 = sub( Qy1, 34 );
- R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx );
- Qy1 = add( Qy1, Qprev_y1 );
-
- Qy2 = W_norm( y2_fx64 );
- if ( y2_fx64 == 0 )
- {
- Qy2 = 62;
- move16();
- }
- Qy2 = sub( Qy2, 34 );
- R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx );
- Qy2 = add( Qy2, Qprev_y2 );
-
- Qx0 = W_norm( x0_fx64 );
- if ( x0_fx64 == 0 )
- {
- Qx0 = 62;
- move16();
- }
- Qx0 = sub( Qx0, 34 );
- R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx );
-
- Qx1 = W_norm( x1_fx64 );
- if ( x1_fx64 == 0 )
- {
- Qx1 = 62;
- move16();
- }
- Qx1 = sub( Qx1, 34 );
- R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx );
-
- Qx2 = W_norm( x2_fx64 );
- if ( x2_fx64 == 0 )
- {
- Qx2 = 62;
- move16();
- }
- Qx2 = sub( Qx2, 34 );
- R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx );
-
- Qmin = s_min( Qy1, Qy2 );
-
- y0_fx64 = W_add( W_shr( R1, sub( Qy1, Qmin ) ), W_shr( R2, sub( Qy2, Qmin ) ) );
-
- Qmin = s_min( Qmin, Qx0 );
- Qmin = s_min( Qmin, Qx1 );
- Qmin = s_min( Qmin, Qx2 );
-
- y0_fx64 = W_add( W_shr( y0_fx64, sub( s_min( Qy1, Qy2 ), Qmin ) ), W_add( W_shr( R3, sub( Qx0, Qmin ) ), W_add( W_shr( R4, sub( Qx1, Qmin ) ), W_shr( R5, sub( Qx2, Qmin ) ) ) ) );
-
- y0_fx64 = W_shr( y0_fx64, 29 );
-
- signal_fx[i] = W_extract_l( W_shr( y0_fx64, Qmin ) );
- move32();
- IF( signal_fx[i] < 0 )
- {
- signal_fx[i] = L_add( signal_fx[i], 1 );
- move32();
- }
-
- y2_fx64 = y1_fx64;
- y1_fx64 = y0_fx64;
- Qprev_y2 = Qprev_y1;
- Qprev_y1 = Qmin;
- move64();
- move64();
- move16();
- move16();
- }
-
- Qy1 = W_norm( y1_fx64 );
- test();
- IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) )
- {
- y1_fx64 = W_shr( y1_fx64, sub( 32, Qy1 ) );
- Qprev_y1 = sub( Qprev_y1, sub( 32, Qy1 ) );
- }
-
- Qy2 = W_norm( y2_fx64 );
- test();
- IF( y2_fx64 != 0 && LT_16( Qy2, 32 ) )
- {
- y2_fx64 = W_shr( y2_fx64, sub( 32, Qy2 ) );
- Qprev_y2 = sub( Qprev_y2, sub( 32, Qy2 ) );
- }
-
- mem_fx[0] = W_extract_l( y1_fx64 );
- mem_fx[1] = W_extract_l( y2_fx64 );
- mem_fx[2] = W_extract_l( x0_fx64 );
- mem_fx[3] = W_extract_l( x1_fx64 );
- mem_fx[4] = Qprev_y1;
- mem_fx[5] = Qprev_y2;
- move32();
- move32();
- move32();
- move32();
- move32();
- move32();
-
- return;
-}
-#endif
diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c
index 84bbf8b3c3c94aefd82d69344e4fa5d9362c0408..f5e7105cfcf9dfeebad0e4bff0d5a262cc8a7dd8 100644
--- a/lib_com/hp50_fx.c
+++ b/lib_com/hp50_fx.c
@@ -37,19 +37,8 @@
#include
#include
#include "options.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
-
-/*
- * hp20
- *
- * Function:
- * 2nd order high pass filter with nominal cut off frequency at 20 Hz.
- *
- * Returns:
- * void
- */
+#include "wmc_auto.h"
#define HP20_COEFF_SCALE ( 2 )
@@ -469,8 +458,14 @@ void hp20_fx_32(
{
Word16 i;
Word32 a1_fx, a2_fx, b1_fx, b2_fx;
+#ifdef OPT_STEREO_32KBPS_V1
+ Word16 Qy1, Qy2, Qmin;
+ Word64 y0_fx64, y1_fx64, y2_fx64;
+ Word32 x0, x1, x2;
+#else /* OPT_STEREO_32KBPS_V1 */
Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin;
Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5;
+#endif /* OPT_STEREO_32KBPS_V1 */
IF( EQ_32( Fs, 8000 ) )
{
@@ -521,15 +516,64 @@ void hp20_fx_32(
move32();
move32();
+#ifdef OPT_STEREO_32KBPS_V1
+ y1_fx64 = W_add( W_deposit32_l( mem_fx[0] ), W_deposit32_h( mem_fx[1] ) );
+ y2_fx64 = W_add( W_deposit32_l( mem_fx[2] ), W_deposit32_h( mem_fx[3] ) );
+
+ x0 = mem_fx[4];
+ move32();
+ x1 = mem_fx[5];
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
Qprev_y1 = extract_l( mem_fx[4] );
Qprev_y2 = extract_l( mem_fx[5] );
y1_fx64 = W_deposit32_l( mem_fx[0] );
y2_fx64 = W_deposit32_l( mem_fx[1] );
x0_fx64 = W_deposit32_l( mem_fx[2] );
x1_fx64 = W_deposit32_l( mem_fx[3] );
+#endif /* OPT_STEREO_32KBPS_V1 */
FOR( i = 0; i < lg; i++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ x2 = x1;
+ move32();
+ x1 = x0;
+ move32();
+ x0 = signal_fx[i];
+ move32();
+
+ Qy1 = W_norm( y1_fx64 );
+ if ( y1_fx64 == 0 )
+ {
+ Qy1 = 62;
+ move16();
+ }
+
+ Qy2 = W_norm( y2_fx64 );
+ if ( y2_fx64 == 0 )
+ {
+ Qy2 = 62;
+ move16();
+ }
+
+ Qmin = s_min( Qy1, Qy2 );
+
+ Qmin = sub( Qmin, 34 );
+
+ y0_fx64 = W_mac_32_32( W_mult_32_32( W_shl_sat_l( y1_fx64, Qmin ), a1_fx ), W_shl_sat_l( y2_fx64, Qmin ), a2_fx ); // Qmin + Q29 + Q30 + 1
+
+ Word64 temp = W_mac_32_32( W_mac_32_32( W_mult_32_32( x2, b2_fx ), x1, b1_fx ), x0, b2_fx ); // Q30
+ Word64 y0_fx = W_shr( y0_fx64, add( Qmin, Q30 ) ); // Q30
+ y0_fx64 = W_add( temp, y0_fx ); // Q30
+ signal_fx[i] = W_shl_sat_l( y0_fx64, -Q30 );
+ move32();
+
+ y2_fx64 = y1_fx64;
+ move64();
+ y1_fx64 = y0_fx64;
+ move64();
+#else /* OPT_STEREO_32KBPS_V1 */
x2_fx64 = x1_fx64;
move64();
x1_fx64 = x0_fx64;
@@ -611,8 +655,17 @@ void hp20_fx_32(
move64();
move16();
move16();
+#endif /* OPT_STEREO_32KBPS_V1 */
}
+#ifdef OPT_STEREO_32KBPS_V1
+ mem_fx[0] = W_extract_l( y1_fx64 );
+ mem_fx[1] = W_extract_h( y1_fx64 );
+ mem_fx[2] = W_extract_l( y2_fx64 );
+ mem_fx[3] = W_extract_h( y2_fx64 );
+ mem_fx[4] = x0;
+ mem_fx[5] = x1;
+#else /* OPT_STEREO_32KBPS_V1 */
Qy1 = W_norm( y1_fx64 );
test();
IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) )
@@ -635,6 +688,8 @@ void hp20_fx_32(
mem_fx[3] = W_extract_l( x1_fx64 );
mem_fx[4] = Qprev_y1;
mem_fx[5] = Qprev_y2;
+#endif /* OPT_STEREO_32KBPS_V1 */
+
move32();
move32();
move32();
diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c
index bc4edb8693cb17aed07ff08d218a7eaa169673ec..121dae06a1ef18c4cd878c09921758a9d0ced65e 100644
--- a/lib_com/hq2_core_com.c
+++ b/lib_com/hq2_core_com.c
@@ -39,7 +39,7 @@
#include
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "basop_proto_func.h"
#include "wmc_auto.h"
diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c
index c139a493c8601785881ef08bd5a5a781704d1955..90a256ceab3e43b00c51885fe3e3ac35efea1113 100644
--- a/lib_com/hq_conf.c
+++ b/lib_com/hq_conf.c
@@ -38,9 +38,8 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
void hq_configure_fx(
diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c
index 4426f85d98d0b79248d5308c349ecef0561ad8ad..cf3ce202e0f0951c92b3610319cb5e7db95146b8 100644
--- a/lib_com/hq_tools_fx.c
+++ b/lib_com/hq_tools_fx.c
@@ -39,7 +39,6 @@
#include "rom_com.h" /* Static table prototypes FIP version */
#include "stl.h" /* required for wmc_tool */
#include "prot_fx.h"
-#include "prot.h"
#include "ivas_prot_fx.h"
/*--------------------------------------------------------------------------*
diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c
index 423eea46d7f8d5965fb9c002f3096d4d2efde2df..9e64a4e254f17bd36d456d3d45bf35d36612720d 100644
--- a/lib_com/ifft_rel.c
+++ b/lib_com/ifft_rel.c
@@ -36,10 +36,9 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/*-----------------------------------------------------------------*
* Local constants
*-----------------------------------------------------------------*/
diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c
index 0f673b8fd610188a6dc014914aaa54fac9ce713d..570e9ebd987527155d240e94341b7224aa876224 100644
--- a/lib_com/int_lsp.c
+++ b/lib_com/int_lsp.c
@@ -37,10 +37,9 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
void int_lsp_fx(
diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c
index 745ee6ac3d7da541cf8d62ac6fc71e2386ed5f05..5c4c98e291e33db70a7fa6a8763926f963fe485c 100644
--- a/lib_com/interleave_spectrum.c
+++ b/lib_com/interleave_spectrum.c
@@ -37,10 +37,9 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/interpol.c b/lib_com/interpol.c
index 45021f1c274004c456b85e5eddbe8a84982f4d3c..a490a755269c9fa7d3f9bdeb440b60bf7f483253 100644
--- a/lib_com/interpol.c
+++ b/lib_com/interpol.c
@@ -36,10 +36,9 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
#include "rom_com.h"
-#include "prot_fx.h"
#include "prot_fx_enc.h"
diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c
index b2c09fa073e524dfbc82dcaa88db2e910746b719..3f6e181efb2154cf8fc2ce949321b0959c1dab90 100644
--- a/lib_com/ivas_agc_com_fx.c
+++ b/lib_com/ivas_agc_com_fx.c
@@ -34,11 +34,10 @@
#include "options.h"
#include "cnst.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include
#include "wmc_auto.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
/*------------------------------------------------------------------------------------------*
* Local constants
diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith_fx.c
similarity index 99%
rename from lib_com/ivas_arith.c
rename to lib_com/ivas_arith_fx.c
index 2f729bbd4e6d4b9675349adb8ec2bcc998628734..311bccff8e206cbdb862bba20cd4f6e89d62ecc2 100644
--- a/lib_com/ivas_arith.c
+++ b/lib_com/ivas_arith_fx.c
@@ -33,8 +33,6 @@
#include
#include "options.h"
#include "wmc_auto.h"
-#include "prot.h"
-#include "ivas_prot.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "stat_dec.h"
diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com_fx.c
similarity index 99%
rename from lib_com/ivas_avq_pos_reorder_com.c
rename to lib_com/ivas_avq_pos_reorder_com_fx.c
index ac539b7879b99ccf2941f6768be01caba574fdbb..25f8be3ad2ae64b4b05bc88bfc19b22043377621 100644
--- a/lib_com/ivas_avq_pos_reorder_com.c
+++ b/lib_com/ivas_avq_pos_reorder_com_fx.c
@@ -32,7 +32,7 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
/*-----------------------------------------------------------------*
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index 6612fac1fb86e071aca955949ba2002477dfaffd..9243b3f508b02be0f20e6006f8c768413d4b37ce 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -1285,7 +1285,7 @@ enum
#define MASA_RATIO_THRESHOLD 0.1f
#define MASA_ANGLE_TOLERANCE 0.5f
#define MASA_RATIO_THRESHOLD_FX 214748365 // 0.1 in Q31
-#define MASA_RATIO_TOLERANCE_FX 214748364/*0.1 Q30*/
+#define MASA_RATIO_TOLERANCE_FX 107374182 // 0.1 in Q30
#define MASA_ANGLE_TOLERANCE_FX ONE_IN_Q21 // 0.5 in Q22
#define MASA_LIMIT_NO_BANDS_SUR_COH 8
#define MINIMUM_BIT_BUDGET_NORMAL_META 100
@@ -1440,12 +1440,12 @@ typedef enum _COV_SMOOTHING_TYPE
} COV_SMOOTHING_TYPE;
typedef struct {
- const int32_t *value;
- const uint16_t *length;
+ const Word32 *value;
+ const UWord16 *length;
} HUFF_TAB;
typedef struct {
- int32_t value[81];
+ Word32 value[81];
unsigned short length[81];
} HUFF_ELEMENTS;
@@ -1467,8 +1467,8 @@ typedef struct {
typedef struct
{
- const int16_t (*alpha)[2];
- const int16_t (*beta)[2];
+ const Word16 (*alpha)[2];
+ const Word16 (*beta)[2];
} HUFF_NODE_TABLE;
/*----------------------------------------------------------------------------------*
diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth_fx.c
similarity index 99%
rename from lib_com/ivas_cov_smooth.c
rename to lib_com/ivas_cov_smooth_fx.c
index 445ea8c78e22e5e04815372b1df63d22601dc3a8..3a93ed1f577c0a8f2536607f5d25256674bd4f5c 100644
--- a/lib_com/ivas_cov_smooth.c
+++ b/lib_com/ivas_cov_smooth_fx.c
@@ -33,9 +33,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "ivas_prot.h"
#include "wmc_auto.h"
-#include "prot.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com_fx.c
similarity index 97%
rename from lib_com/ivas_dirac_com.c
rename to lib_com/ivas_dirac_com_fx.c
index 0e8050451601ebba06d5bf001a680e4a5b9202e3..b16b94f1d7c114b451fd63165883dcfef009947f 100644
--- a/lib_com/ivas_dirac_com.c
+++ b/lib_com/ivas_dirac_com_fx.c
@@ -36,11 +36,9 @@
#include
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
-#include "ivas_prot.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
@@ -611,11 +609,8 @@ void computeDirectionVectors_fixed(
Word32 *direction_vector_y, /* o: Q30*/
Word32 *direction_vector_z, /* o: Q30*/
Word16 i_e /*Exponent of all the intensity buffers*/
-#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
,
- Word16 *i_e_band
-#endif
-)
+ Word16 *i_e_band )
{
Word16 i;
Word32 intensityNorm;
@@ -633,7 +628,6 @@ void computeDirectionVectors_fixed(
scaled_x = L_shl( *intensity_real_x, norm_x );
scaled_y = L_shl( *intensity_real_y, norm_y );
scaled_z = L_shl( *intensity_real_z, norm_z );
-#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
IF( i_e_band != NULL )
{
e_x = sub( Q31, add( i_e_band[i - enc_param_start_band], norm_x ) );
@@ -646,12 +640,6 @@ void computeDirectionVectors_fixed(
e_y = sub( i_e, norm_y );
e_z = sub( i_e, norm_z );
}
-#else
-
- e_x = sub( i_e, norm_x );
- e_y = sub( i_e, norm_y );
- e_z = sub( i_e, norm_z );
-#endif
temp1 = BASOP_Util_Add_Mant32Exp( Mult_32_32( scaled_x, scaled_x ), shl( e_x, 1 ), Mult_32_32( scaled_y, scaled_y ), shl( e_y, 1 ), &exp1 );
intensityNorm = BASOP_Util_Add_Mant32Exp( temp1, exp1, Mult_32_32( scaled_z, scaled_z ), shl( e_z, 1 ), &intensityNorm_e );
@@ -968,13 +956,12 @@ void computeDiffuseness_fixed(
q_tmp = add( q_factor_energy[i], min_q_shift1 );
-#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS
Word16 shift_q = sub( q_tmp, q_ene );
Word32 shiftEquiv = L_add( 0, 0 );
Word16 shift_qtotal;
if ( shift_q < 0 )
{
- shiftEquiv = L_lshl( 0x80000000, shift_q );
+ shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q );
}
if ( shift_q >= 0 )
{
@@ -988,27 +975,6 @@ void computeDiffuseness_fixed(
energy_slow[k] = Madd_32_32_r( tmp, energy_slow[k], shiftEquiv );
move32();
}
-#else
- Word16 shift_q = sub( q_tmp, q_ene );
- IF( shift_q < 0 )
- {
- FOR( k = 0; k < num_freq_bands; k++ )
- {
- tmp = L_shl( p_tmp_c[k], min_q_shift1 );
- energy_slow[k] = L_add( L_shl( energy_slow[k], shift_q ), tmp );
- move32();
- }
- }
- ELSE
- {
- FOR( k = 0; k < num_freq_bands; k++ )
- {
- tmp = L_shl( p_tmp_c[k], min_q_shift1 );
- energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, shift_q ) );
- move32();
- }
- }
-#endif
q_ene = s_min( q_ene, q_tmp );
@@ -1017,10 +983,9 @@ void computeDiffuseness_fixed(
q_tmp = add( q_factor_intensity[i], min_q_shift2 );
shift_q = sub( q_tmp, q_intensity );
-#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS
if ( shift_q < 0 )
{
- shiftEquiv = L_lshl( 0x80000000, shift_q );
+ shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q );
}
if ( shift_q >= 0 )
{
@@ -1038,34 +1003,6 @@ void computeDiffuseness_fixed(
move32();
}
}
-#else
- IF( shift_q > 0 )
- {
- FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
- {
- p_tmp = buffer_intensity[j][i];
- FOR( k = 0; k < num_freq_bands; k++ )
- {
- tmp = L_shl( p_tmp[k], min_q_shift2 );
- intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shr( tmp, shift_q ) );
- move32();
- }
- }
- }
- ELSE
- {
- FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
- {
- p_tmp = buffer_intensity[j][i];
- FOR( k = 0; k < num_freq_bands; k++ )
- {
- tmp = L_shl( p_tmp[k], min_q_shift2 );
- intensity_slow[j * num_freq_bands + k] = L_add( L_shl( intensity_slow[j * num_freq_bands + k], shift_q ), tmp );
- move32();
- }
- }
- }
-#endif
q_intensity = s_min( q_intensity, q_tmp );
}
diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common_fx.c
similarity index 99%
rename from lib_com/ivas_entropy_coder_common.c
rename to lib_com/ivas_entropy_coder_common_fx.c
index d28828d6f4d20b163ab0e4a57faaf83391e359c8..f52d59859e7833964f125b0837b23a7d18c91dce 100644
--- a/lib_com/ivas_entropy_coder_common.c
+++ b/lib_com/ivas_entropy_coder_common_fx.c
@@ -32,10 +32,9 @@
#include
#include "options.h"
-#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "math.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer_fx.c
similarity index 99%
rename from lib_com/ivas_fb_mixer.c
rename to lib_com/ivas_fb_mixer_fx.c
index 498de0188e11b973567acde6d1771ffe56d3b866..d5cd8d4f17875b44cbcecb447e9bf0463a25f056 100644
--- a/lib_com/ivas_fb_mixer.c
+++ b/lib_com/ivas_fb_mixer_fx.c
@@ -34,13 +34,11 @@
#include
#include
#include "options.h"
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx.h"
#include "ivas_rom_com_fx.h"
@@ -1289,7 +1287,7 @@ static ivas_error ivas_filterbank_setup_fx(
ivas_get_active_bins_fx( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate );
- IF( EQ_16( pCfg->fb_latency, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) )
+ IF( EQ_16( pCfg->fb_latency, NS2SA_FX2( sampling_rate, DELAY_FB_1_NS ) ) )
{
pAll_fb_fr_fx[0] = ivas_fb_fr_12band_1ms_re_fx; // Q30
move32();
@@ -1478,7 +1476,7 @@ static ivas_error ivas_fb_mixer_get_window_fx(
error = IVAS_ERR_OK;
move32();
- IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_4_NS ) ) )
+ IF( EQ_16( fade_len, NS2SA_FX2( sampling_rate, DELAY_FB_4_NS ) ) )
{
SWITCH( sampling_rate )
{
@@ -1495,7 +1493,7 @@ static ivas_error ivas_fb_mixer_get_window_fx(
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" );
}
}
- ELSE IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) )
+ ELSE IF( EQ_16( fade_len, NS2SA_FX2( sampling_rate, DELAY_FB_1_NS ) ) )
{
SWITCH( sampling_rate )
{
diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters_fx.c
similarity index 99%
rename from lib_com/ivas_filters.c
rename to lib_com/ivas_filters_fx.c
index 7705deb6afba76acb6c496fbe4851ac27358379b..1e9aaf0c20771fffa77bbebf43f7109a95cc50b5 100644
--- a/lib_com/ivas_filters.c
+++ b/lib_com/ivas_filters_fx.c
@@ -32,7 +32,6 @@
#include
#include "options.h"
-#include "ivas_prot.h"
#include "ivas_cnst.h"
#include "ivas_stat_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com_fx.c
similarity index 99%
rename from lib_com/ivas_ism_com.c
rename to lib_com/ivas_ism_com_fx.c
index 74e9641aaa290fb689cd3a0ceb4b414d024c05c5..5f1a13afb7ca1a431d823a6d5461813e136c34a0 100644
--- a/lib_com/ivas_ism_com.c
+++ b/lib_com/ivas_ism_com_fx.c
@@ -35,15 +35,12 @@
#include "cnst.h"
#include "ivas_cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
/*-----------------------------------------------------------------------*
* Local constants
diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com_fx.c
similarity index 99%
rename from lib_com/ivas_lfe_com.c
rename to lib_com/ivas_lfe_com_fx.c
index 4d993d64f1b23234bb43c5b46800a632f92b1e2a..3d1e7aee66e4b495f8aadbff57788cacdcc5389c 100644
--- a/lib_com/ivas_lfe_com.c
+++ b/lib_com/ivas_lfe_com_fx.c
@@ -34,8 +34,7 @@
#include "math.h"
#include "options.h"
#include "ivas_stat_com.h"
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "cnst.h"
diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com_fx.c
similarity index 99%
rename from lib_com/ivas_masa_com.c
rename to lib_com/ivas_masa_com_fx.c
index 35db926d0a60f6ac52e7e35bdaab20bac34de81c..cfed06357fe908e6c3fda28720aa7272ca67adb0 100644
--- a/lib_com/ivas_masa_com.c
+++ b/lib_com/ivas_masa_com_fx.c
@@ -34,14 +34,12 @@
#include
#include "options.h"
#include
-#include "prot.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "ivas_stat_dec.h"
#include "wmc_auto.h"
#include "ivas_rom_com_fx.h"
-#include "prot_fx.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com_fx.c
similarity index 99%
rename from lib_com/ivas_mc_com.c
rename to lib_com/ivas_mc_com_fx.c
index 88d6c1b5ec8526ac9afc06ac569ae91fc1a4d4f2..8201037a1a5f89eb53acb0e81787b0a87f68da5c 100644
--- a/lib_com/ivas_mc_com.c
+++ b/lib_com/ivas_mc_com_fx.c
@@ -34,8 +34,7 @@
#include
#include "options.h"
#include
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com_fx.c
similarity index 99%
rename from lib_com/ivas_mc_param_com.c
rename to lib_com/ivas_mc_param_com_fx.c
index d69da849a4450816e9bb35fe78facfc4c6e96833..4469e7f93d82856a3e2db90e362e3e02265108be 100644
--- a/lib_com/ivas_mc_param_com.c
+++ b/lib_com/ivas_mc_param_com_fx.c
@@ -35,9 +35,7 @@
#include
#include "options.h"
#include "ivas_cnst.h"
-#include "prot.h"
#include "prot_fx.h"
-#include "ivas_prot.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com-fx.c
similarity index 99%
rename from lib_com/ivas_mcmasa_com.c
rename to lib_com/ivas_mcmasa_com-fx.c
index da0b8f1c4f20898d92d6a9106e0f25ca495de058..23a3800fb792ba9eeee06ef4cd26001a9b54d5e6 100644
--- a/lib_com/ivas_mcmasa_com.c
+++ b/lib_com/ivas_mcmasa_com-fx.c
@@ -31,7 +31,6 @@
*******************************************************************************************************/
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "options.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com_fx.c
similarity index 99%
rename from lib_com/ivas_mct_com.c
rename to lib_com/ivas_mct_com_fx.c
index b220d69a7651fbe29593101d76d17ad20d306022..81a56df146d9ba7378dbcadacb6aeb39b98f28b0 100644
--- a/lib_com/ivas_mct_com.c
+++ b/lib_com/ivas_mct_com_fx.c
@@ -33,8 +33,8 @@
#include
#include "options.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
-#include "prot.h"
+#include "prot_fx.h"
+#include "ivas_prot_fx.h"
#include "wmc_auto.h"
#include
diff --git a/lib_com/ivas_mdct_core_com.c b/lib_com/ivas_mdct_core_com_fx.c
similarity index 99%
rename from lib_com/ivas_mdct_core_com.c
rename to lib_com/ivas_mdct_core_com_fx.c
index a5cfb8673abbf845b4938d48d8a14dd73cdc3b49..fe313eecdd7c3be915f9d9aa73c37081e79b61ac 100644
--- a/lib_com/ivas_mdct_core_com.c
+++ b/lib_com/ivas_mdct_core_com_fx.c
@@ -33,10 +33,8 @@
#include
#include "options.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
/*--------------------------------------------------------------------------*
diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft_fx.c
similarity index 99%
rename from lib_com/ivas_mdft_imdft.c
rename to lib_com/ivas_mdft_imdft_fx.c
index 0f24fba817b5c3f3781266a7e8dc55033bfc01a0..5d7bee1a6929347ac19968f7d8996878878f8897 100644
--- a/lib_com/ivas_mdft_imdft.c
+++ b/lib_com/ivas_mdft_imdft_fx.c
@@ -33,14 +33,12 @@
#include
#include "options.h"
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "ivas_rom_com.h"
#include
#include "wmc_auto.h"
#include
#include
-#include "prot_fx.h"
#include "debug.h"
#include "ivas_rom_com_fx.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com_fx.c
similarity index 99%
rename from lib_com/ivas_omasa_com.c
rename to lib_com/ivas_omasa_com_fx.c
index eb230b224a57dd7e58e083a97dbef256d2577c19..1c1d4bf6cb6ca87def78b29f60c793547d2f3e4d 100644
--- a/lib_com/ivas_omasa_com.c
+++ b/lib_com/ivas_omasa_com_fx.c
@@ -33,13 +33,11 @@
#include "options.h"
#include
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "ivas_prot_fx.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "ivas_rom_com.h"
#include "rom_com.h"
#include
-#include "prot_fx.h"
/*---------------------------------------------------------------
* Local constants
diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools_fx.c
similarity index 99%
rename from lib_com/ivas_pca_tools.c
rename to lib_com/ivas_pca_tools_fx.c
index 5689e81c01988cc20f6fb56879945270a0b03788..c84078a7d4291080687cfe2597eafe8af3aba784 100644
--- a/lib_com/ivas_pca_tools.c
+++ b/lib_com/ivas_pca_tools_fx.c
@@ -32,13 +32,11 @@
#include
#include "options.h"
-#include "ivas_prot.h"
#include "ivas_cnst.h"
#include
#include
#include "ivas_rom_com.h"
#include "wmc_auto.h"
-#include "prot.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
deleted file mode 100644
index 2493add2847dbcb2e565e2c6b36641e2eb4acded..0000000000000000000000000000000000000000
--- a/lib_com/ivas_prot.h
+++ /dev/null
@@ -1,4066 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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 IVAS_PROT_H
-#define IVAS_PROT_H
-
-#include
-#include "options.h"
-#include
-#include "typedef.h"
-#include "stat_enc.h"
-#include "stat_dec.h"
-#include "stat_com.h"
-#include "ivas_stat_enc.h"
-#include "ivas_stat_dec.h"
-#include "ivas_stat_com.h"
-#include "ivas_error_utils.h"
-
-#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
-
-/* clang-format off */
-
-/*----------------------------------------------------------------------------------*
- * General IVAS prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_enc(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- const int16_t *data, /* i : input signal */
- const int16_t n_samples /* i : number of input samples */
-);
-
-void stereo_dmx_evs_enc(
- STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */
- const int32_t input_Fs, /* i : input sampling rate */
- int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */
- const int16_t n_samples, /* i : number of input samples */
- const bool is_binaural /* i : indication that input is binaural audio */
-);
-
-/*! r: number of channels to be analysed */
-
-void copy_encoder_config_ivas_fx(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- Encoder_State *st, /* o : encoder state structure */
- const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
-);
-
-
-
-ivas_error create_sce_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const int16_t sce_id, /* i : SCE # identifier */
- const int32_t element_brate /* i : element bitrate */
-);
-
-ivas_error create_cpe_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const int16_t cpe_id, /* i : CPE # identifier */
- const int32_t element_brate /* i : element bitrate */
-);
-
-ivas_error create_mct_enc_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-void destroy_cpe_enc(
- CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
-);
-
-void ivas_mct_enc_close_fx(
- MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
-);
-
-ivas_error ivas_corecoder_enc_reconfig(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const int16_t nSCE_old, /* i : number of SCEs in previous frame */
- const int16_t nCPE_old, /* i : number of CPEs in previous frame */
- const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
- const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */
- const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */
- const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */
-);
-
-ivas_error ivas_sce_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const int16_t sce_id, /* i : SCE # identifier */
- const float data_f[], /* i : input signal for single channel */
- const int16_t input_frame, /* i : input frame length per channel */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-
-ivas_error ivas_cpe_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 cpe_id, /* i : CPE # identifier */
- float data_f_ch0[], /* i : input signal for channel 0 */
- float data_f_ch1[], /* i : input signal for channel 1 */
- const Word16 input_frame, /* i : input frame length per channel */
- const Word16 nb_bits_metadata /* i : number of metadata bits */
-);
-
-ivas_error ivas_mct_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- float *data[MCT_MAX_CHANNELS], /* i : input signal buffers */
- const int16_t input_frame, /* i : input frame length per channel */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-ivas_error pre_proc_front_ivas(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const int32_t element_brate, /* i : SCE/CPE element bitrate */
- const int16_t nb_bits_metadata, /* i : number of metadata bits */
- const int16_t input_frame, /* i : frame length */
- const int16_t n, /* i : channel number */
- float old_inp_12k8[], /* o : buffer of old input signal */
- float old_inp_16k[], /* o : buffer of old input signal @16kHz */
- float *ener, /* o : residual energy from Levinson-Durbin */
- float *relE, /* o : frame relative energy */
- float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */
- float Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */
- float epsP[M + 1], /* o : LP prediction errors */
- float lsp_new[M], /* o : LSPs at the end of the frame */
- float lsp_mid[M], /* o : LSPs in the middle of the frame */
- int16_t *vad_hover_flag, /* o : VAD hangover flag */
- int16_t *attack_flag, /* o : flag signaling attack */
- float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
- float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
- float old_wsp[], /* o : weighted input signal buffer */
- float pitch_fr[NB_SUBFR], /* o : fractional pitch values */
- float voicing_fr[NB_SUBFR], /* o : fractional pitch gains */
- int16_t *loc_harm, /* o : harmonicity flag */
- float *cor_map_sum, /* o : speech/music clasif. parameter */
- int16_t *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
- float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- float fft_buff[2 * L_FFT], /* o : FFT buffer */
- const float tdm_A_PCh[M + 1], /* i : unq. LP coeff. of primary channel */
- const float tdm_lsp_new_PCh[M], /* i : unq. LSPs of primary channel */
- const float currFlatness, /* i : flatness parameter */
- const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */
- float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */
- const float Etot_LR[], /* i : total energy Left & Right channel */
- float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */
- const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
- float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */
- const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
- const int16_t force_front_vad, /* i : flag to force VAD decision */
- const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int32_t ivas_total_brate /* i : IVAS total bitrate */
-);
-
-ivas_error pre_proc_front_ivas_fx(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
- const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
- const Word16 input_frame, /* i : frame length Q0*/
- const Word16 n, /* i : channel number Q0*/
- Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
- Word16 *relE_fx, /* o : frame relative energy Q8*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
- Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
- Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
- Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
- Word16 *attack_flag, /* o : flag signaling attack Q0*/
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
- Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
- Word16 *loc_harm, /* o : harmonicity flag Q0*/
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
- const Word16 currFlatness_fx, /* i : flatness parameter Q7*/
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
- Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
- Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
- Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
- const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
-#ifdef NONBE_1211_DTX_BR_SWITCHING
- const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
-#endif
- const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
- Word16 *Q_new
-#ifdef DEBUG_MODE_INFO
- ,
- const Word16 ch_idx
-#endif
-);
-ivas_error pre_proc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 last_element_mode, /* i : last element mode Q0*/
- const Word32 element_brate, /* i : element bitrate Q0*/
- const Word32 last_element_brate, /* i : last element bitrate Q0*/
- const Word16 input_frame, /* i : frame length Q0*/
- Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
- Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
- Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
- Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
- Word16 *epsP_fx_q, /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
- Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
- Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
- Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
- Word16 e_old_wsp,
- const Word16 loc_harm, /* i : harmonicity flag Q0*/
- const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
- const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
- Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT], /* Qx */
- Word16 cor_map_sum_fx, /* Q8 */
- Word16 *Q_new
-);
-/*! r: number of clipped samples */
-void ivas_initialize_handles_enc_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-ivas_error ivas_init_encoder(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-void ivas_destroy_enc_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-ivas_error ivas_initialize_MD_bstr_enc_fx(
- BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-void ivas_destroy_MD_bstr_enc_fx(
- BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */
-);
-
-ivas_error ivas_init_decoder_front(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_init_decoder(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_output_buff_dec(
- float *p_output_f[], /* i/o: output audio buffers */
- const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/
- const int16_t nchan_out_buff /* i : number of output channels */
-);
-#endif
-
-ivas_error stereo_dmx_evs_init_encoder(
- STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS, /* o : Stereo downmix for EVS encoder handle */
- const int32_t input_Fs /* i : input sampling rate */
-);
-
-void stereo_dmx_evs_close_encoder(
- STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */
-);
-
-ivas_error ivas_dec(
- Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
- int16_t *data /* o : output synthesis signal */
-);
-
-
-ivas_error mct_dec_reconfigure(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const uint16_t b_nchan_change /* i : flag indicating different channel count */
-);
-
-
-void ivas_mct_dec_close(
- MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */
-);
-
-ivas_error ivas_corecoder_dec_reconfig(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t nSCE_old, /* i : number of SCEs in previous frame */
- int16_t nCPE_old, /* i : number of CPEs in previous frame */
- const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
- const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */
- const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */
- const int32_t brate_CPE /* i : bitrate to be set for the CPEs */
-);
-
-ivas_error ivas_hp20_dec_reconfig(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame*/
-);
-
-ivas_error ivas_sce_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t sce_id, /* i : SCE # identifier */
- float *output[1], /* o : output synthesis signal */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-ivas_error ivas_cpe_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t cpe_id, /* i : CPE # identifier */
- float *output[CPE_CHANNELS], /* o : output synthesis signal */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-ivas_error ivas_mct_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- float *output[], /* o : output synthesis signal */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-/*! r: number of channels to be synthesised */
-
-void copy_decoder_config(
- Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
- Decoder_State *st /* o : decoder state structure */
-);
-
-void destroy_core_dec(
- DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */
-);
-
-
-void ivas_initialize_handles_dec(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_core_enc_fx(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/
- Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/
- Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/
- Word16 Q_new[],
- Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/
- Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/
- Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/
- Word16 epsP_fx_q[], /* i : LP prediction errors */
- Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/
- Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/
- const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/
- Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/
- Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/
- Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/
- Word16 *q_re_im_buf,
- Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/
- Word16 e_old_wsp[],
- const Word16 loc_harm[], /* i : harmonicity flag Q0*/
- const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/
- const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/
- Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
- Word16 enerBuffer_fx_exp[], /* o : energy buffer */
- Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/
- const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/
- const Word16 ivas_format, /* i : IVAS format Q0*/
- const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
-);
-
-
-
-void decod_gen_2sbfr(
- Decoder_State *st, /* i/o: decoder static memory */
- const int16_t sharpFlag, /* i : formant sharpening flag */
- const float *Aq, /* i : LP filter coefficient */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *exc, /* i/o: adapt. excitation exc */
- float *exc2, /* i/o: adapt. excitation/total exc */
- float *bwe_exc, /* o : excitation for SWB TBE */
- float *gain_buf, /* o : floating pitch gain for each subframe */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const float tdm_Pri_pitch_buf[] /* i : pitch values for primary channel */
-);
-
-void synchro_synthesis(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *output[CPE_CHANNELS], /* i/o: output synthesis signal */
- const int16_t output_frame, /* i : Number of samples */
- const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-);
-
-void synchro_synthesis_fixed(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *output[CPE_CHANNELS], /* i/o: output synthesis signal */
- const int16_t output_frame, /* i : Number of samples */
- const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-);
-
-void stereo_tcx_init_enc(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-
-
-
-void stereo_tcx_init_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int16_t last_element_mode /* i : element mode of previous frame */
-);
-
-/*! r: S/M decision (0 = speech or noise, 1 = unclear, 2 = music) */
-int16_t ivas_smc_gmm(
- Encoder_State *st, /* i/o: encoder state structure */
- STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
- const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
- const float Etot, /* i : total frame energy */
- const float lsp_new[M], /* i : LSPs in current frame */
- const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */
- const float epsP[M + 1], /* i : LP prediciton error */
- const float PS[], /* i : energy spectrum */
- const float non_sta, /* i : unbound non-stationarity */
- const float relE, /* i : relative frame energy */
- int16_t *high_lpn_flag, /* i/o: sp/mus LPN flag */
- const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
-);
-
-void ivas_smc_mode_selection(
- Encoder_State *st, /* i/o: encoder state structure */
- const int32_t element_brate, /* i : element bitrate */
- int16_t smc_dec, /* i : raw decision of the 1st stage classifier */
- const float relE, /* i : relative frame energy */
- const float Etot, /* i : total frame energy */
- int16_t *attack_flag, /* i/o: attack flag (GSC or TC) */
- const float *inp, /* i : input signal */
- const float S_map[], /* i : short-term correlation map */
- const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
-);
-
-/*! r: S/M decision (0=speech or noise,1=unclear,2=music) */
-int16_t ivas_acelp_tcx20_switching(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *inp, /* i : new input signal */
- const float *wsp, /* i : input weighted signal */
- const float non_staX, /* i : unbound non-stationarity for sp/mu clas */
- const float *pitch_fr, /* i : fraction pitch values */
- const float *voicing_fr, /* i : fractional voicing values */
- const float currFlatness, /* i : flatness */
- const float lsp_mid[M], /* i : LSPs at the middle of the frame */
- const float stab_fac, /* i : LP filter stability */
- float *res_cod_SNR_M,
- const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
-);
-
-
-
-void ivas_decision_matrix_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t *sharpFlag, /* o : formant sharpening flag */
- int16_t *core_switching_flag, /* o : ACELP->HQ switching frame flag */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t nchan_out /* i : Number of output channels */
-);
-
-void set_bw_stereo(
- CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structures */
-);
-
-/*! r: flag indicating whether the coded BW has changed */
-int16_t set_bw_mct(
- CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */
- const int16_t nCPE /* i : number of CPEs */
-);
-void dec_acelp_fast(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t cdk_index, /* i : codebook index */
- float code[], /* o : algebraic (fixed) codebook excitation */
- const int16_t L_subfr /* i : subframe length */
-);
-
-void set_transient_stereo(
- CPE_ENC_HANDLE hCPE, /* i : CPE structure */
- float currFlatness[] /* i/o: current flatness */
-);
-
-/*! r: preliminary flag to force ACELP */
-int16_t transient_analysis(
- TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */
- const float cor_map_LT[], /* i : LT correlation map */
- const float multi_harm_limit /* i : multi harminic threshold */
-);
-
-void ivas_post_proc(
- SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const int16_t n, /* i : channel number */
- float synth[], /* i/o: output synthesis signal */
- float *output[CPE_CHANNELS], /* i/o: output synthesis signal */
- const int16_t output_frame, /* i : output frame length */
- const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-);
-
-void ivas_renderer_select(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_mc_enc_config_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-ivas_error ivas_mc_dec_config(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t idx, /* i : LS config. index */
- uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */
- int16_t *data /* o : output synthesis signal */
-);
-
-/*! r: MC format mode (MCT, McMASA, ParamMC) */
-MC_MODE ivas_mc_mode_select(
- const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */
- const int32_t total_brate /* i : IVAS total bitrate */
-);
-
-/*! r: number of loudspeaker channels */
-int16_t ivas_mc_ls_setup_get_num_channels(
- const MC_LS_SETUP mc_ls_setup /* i : loudspeaker setup (CICP) */
-);
-
-/*! r: output configuration*/
-AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config(
- const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */
-);
-
-/*! r: multi channel loudspeaker setup */
-MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup(
- const AUDIO_CONFIG output_config /* i : output audio configuration */
-);
-
-void smooth_dft2td_transition(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */
- const int16_t output_frame /* i : output frame length */
-);
-
-
-/*! r: flag indicating a valid bitrate */
-Word16 is_IVAS_bitrate_fx(
- const Word32 ivas_total_brate /* i : IVAS total bitrate */
-);
-
-int16_t is_DTXrate(
- const int32_t ivas_total_brate /* i : IVAS total bitrate */
-);
-
-
-void TonalMdctConceal_create_concealment_noise_ivas(
- float concealment_noise[L_FRAME48k],
- CPE_DEC_HANDLE hCPE,
- const int16_t L_frameTCX,
- const int16_t L_frame,
- const int16_t idchan,
- const int16_t subframe_idx,
- const int16_t core,
- const float crossfade_gain,
- const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode
-);
-
-void TonalMdctConceal_whiten_noise_shape_ivas(
- Decoder_State *st,
- const int16_t L_frame,
- const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE
-);
-
-void dtx_read_padding_bits(
- DEC_CORE_HANDLE st,
- const int16_t num_bits
-);
-
-
-
-/*----------------------------------------------------------------------------------*
- * JBM prototypes
- *----------------------------------------------------------------------------------*/
-
-
-
-ivas_error ivas_jbm_dec_flush_renderer(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t tc_granularity_new, /* i : new renderer granularity */
- const RENDERER_TYPE renderer_type_old, /* i : old renderer type */
- const AUDIO_CONFIG intern_config_old, /* i : old internal config */
- const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */
- const MC_MODE mc_mode_old, /* i : old MC mode */
- const ISM_MODE ism_mode_old, /* i : old ISM mode */
- uint16_t *nSamplesRendered, /* o : number of samples flushed */
- int16_t *data /* o : output synthesis signal */
-);
-
-void ivas_jbm_dec_feed_tc_to_renderer(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */
- int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
- float *data /* i/o: transport channels/output synthesis signal */
-);
-
-ivas_error ivas_jbm_dec_set_discard_samples(
- Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
-);
-
-void ivas_jbm_dec_get_adapted_linear_interpolator(
- const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */
- const int16_t interp_length, /* i : length of the interpolator to be created */
- float *interpolator /* o : the interpolator */
-);
-
-
-
-int16_t ivas_jbm_dec_get_num_tc_channels(
- Decoder_Struct *st_ivas /* i : IVAS decoder handle */
-);
-
-void ivas_jbm_dec_copy_tc_no_tsm(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- float *tc[], /* i : transport channels */
- const int16_t output_frame /* i : output frame size */
-);
-
-
-TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode(
- Decoder_Struct *st_ivas /* i : IVAS decoder handle */
-);
-
-/*! r: render granularity */
-int16_t ivas_jbm_dec_get_render_granularity_flt(
- const RENDERER_TYPE rendererType, /* i : renderer type */
- const IVAS_FORMAT ivas_format, /* i : ivas format */
- const MC_MODE mc_mode, /* i : MC mode */
- const int32_t output_Fs /* i : sampling rate */
-);
-
-ivas_error ivas_jbm_dec_tc_buffer_open(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */
- const int16_t nchan_transport_jbm, /* i : number of real transport channels */
- const int16_t nchan_transport_internal, /* i : number of totally buffered channels */
- const int16_t nchan_full, /* i : number of channels to fully store */
- const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */
-);
-
-ivas_error ivas_jbm_dec_tc_buffer_reconfigure(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */
- const int16_t nchan_transport_jbm, /* i : new number of real transport channels */
- const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */
- const int16_t nchan_full, /* i : new number of channels to fully store */
- const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */
-);
-
-void ivas_jbm_dec_tc_buffer_close(
- DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
-);
-
-void ivas_jbm_dec_td_renderers_adapt_subframes(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_jbm_dec_metadata_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_jbm_masa_sf_to_sf_map(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * ISM prototypes
- *----------------------------------------------------------------------------------*/
-
-void bitbudget_to_brate(
- const Word16 x[], /* i : bitbudgets Q0 */
- Word32 y[], /* o : bitrates Q0 */
- const Word16 N /* i : number of entries to be converted */
-);
-
-void ivas_ism_reset_metadata(
- ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */
-);
-
-void ivas_ism_reset_metadata_enc(
- ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */
-);
-void ivas_ism_reset_metadata_API(
- ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */
-);
-
-/*! r: index of the winning codeword */
-Word16 ism_quant_meta_fx(
- const Word32 val, /* i : scalar value to quantize Q22 */
- Word32 *valQ, /* o : quantized value Q22 */
- const Word32 borders_fx[], /* i : level borders Q22 */
- const Word32 q_step_fx, /* i : quantization step Q22 */
- const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */
- const Word16 cbsize /* i : codebook size */
-);
-
-ivas_error ivas_ism_metadata_enc_create_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const int16_t n_ISms, /* i : number of objects */
- int32_t element_brate_tmp[] /* o : element bitrate per object */
-);
-
-ivas_error ivas_ism_metadata_dec_create(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t n_ISms, /* i : number of objects */
- int32_t element_brate_tmp[] /* o : element bitrate per object */
-);
-
-ivas_error ivas_ism_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- float *data[], /* i : input signal [channels][samples] */
- const int16_t input_frame, /* i : input frame length per channel */
- int16_t *nb_bits_metadata, /* i : number of metadata bits */
- const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */
-);
-
-ivas_error ivas_ism_metadata_dec(
- const int32_t ism_total_brate, /* i : ISM total bitrate */
- const int16_t nchan_ism, /* i : number of ISM channels */
- int16_t *nchan_transport, /* o : number of transport channels */
- ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */
- const int16_t bfi, /* i : bfi flag */
- int16_t nb_bits_metadata[], /* o : number of metadata bits */
- ISM_MODE ism_mode, /* i : ISM mode */
- ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */
- const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */
- int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */
- int16_t *ism_extmeta_cnt, /* i/o: Number of change frames observed */
- DEC_CORE_HANDLE st0 /* i : core-coder handle */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Parametric ISM prototypes
- *----------------------------------------------------------------------------------*/
-
-/*! r: ISM format mode */
-
-ivas_error ivas_param_ism_enc_open_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-void ivas_param_ism_enc_close_fx(
- PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
- const int32_t input_Fs /* i : input sampling_rate */
-);
-
-void ivas_ism_metadata_close(
- ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */
- const int16_t first_idx /* i : index of first handle to deallocate */
-);
-
-
-ivas_error ivas_ism_enc_config(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-
-
-
-void ivas_param_ism_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */
-);
-
-void ivas_ism_dec_digest_tc(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-
-
-void ivas_param_ism_dec_render(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
- uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
- uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- float *output_f[] /* o : rendered time signal */
-);
-
-void ivas_param_ism_params_to_masa_param_mapping(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * ISM DTX prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_ism_dtx_open(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-/*! r: indication of DTX frame */
-int16_t ivas_ism_dtx_enc(
- ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
- SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t nchan_ism, /* i : number of objects */
- const int16_t nchan_transport, /* i : number of transport channels */
- int16_t vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag */
- ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- int16_t md_diff_flag[], /* o : metadata differential flag */
- int16_t *sid_flag /* o : indication of SID frame */
-);
-
-void ivas_ism_dtx_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- int16_t *nb_bits_metadata /* o : number of metadata bits */
-);
-
-void ivas_ism_metadata_sid_enc_fx(
- ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
- const int16_t flag_noisy_speech, /* i : noisy speech flag */
- const int16_t nchan_ism, /* i : number of objects */
- const int16_t nchan_transport, /* i : number of transport channels */
- const ISM_MODE ism_mode, /* i : ISM mode */
- ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- const int16_t sid_flag, /* i : indication of SID frame */
- const int16_t md_diff_flag[], /* i : metadata differental flag */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- int16_t nb_bits_metadata[] /* o : number of metadata bits */
-);
-
-void ivas_ism_metadata_sid_dec(
- SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */
- const int32_t ism_total_brate, /* i : ISM total bitrate */
- const int16_t bfi, /* i : bfi flag */
- const int16_t nchan_ism, /* i : number of objects */
- const int16_t nchan_transport, /* i : number of transport channels */
- const ISM_MODE ism_mode, /* i : ISM mode */
- int16_t *flag_noisy_speech, /* o : noisy speech flag */
- int16_t *sce_id_dtx, /* o : SCE DTX ID */
- ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- int16_t nb_bits_metadata[] /* o : number of metadata bits */
-);
-
-
-void ivas_param_ism_compute_noisy_speech_flag_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-
-void update_last_metadata(
- const int16_t nchan_ism, /* i : number of objects */
- ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- const int16_t updt_flag[] /* i : last metadata update flag */
-);
-
-void ivas_ism_dtx_limit_noise_energy_for_near_silence(
- SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */
- const int16_t sce_id_dtx, /* i : SCE DTX ID */
- const int16_t nchan_transport /* i : number of transport channels */
-);
-
-/*----------------------------------------------------------------------------------*
- * DFT Stereo prototypes
- *----------------------------------------------------------------------------------*/
-
-
-void stereo_dft_enc_analyze(
- Encoder_State **sts, /* i/o: encoder state structure */
- const int16_t n_channels, /* i : number of input channels */
- const int16_t input_frame, /* i : input frame length */
- STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: encoder MDCT stereo handle */
- float DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */
- float *input_mem[CPE_CHANNELS] /* i/o: input buffer memory */
-);
-
-float stereo_dft_enc_synthesize(
- STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */
- float *output, /* o : output synthesis */
- const int16_t chan, /* i : channel number */
- const int32_t input_Fs, /* i : input sampling rate */
- const int32_t output_sampling_rate, /* i : output sampling rate */
- const int16_t L_frame /* i : frame length at internal Fs */
-);
-
-
-
-
-void stereo_dtf_cng(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */
- const int16_t output_frame /* i : output frame size */
-);
-
-void stereo_dft_cng_side_gain(
- STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo encoder handle */
- STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */
- const int32_t core_brate, /* i : core bitrate */
- const int32_t last_core_brate, /* i : last core bitrate */
- const int16_t bwidth /* i : audio band-width */
-);
-
-
-void stereo_dft_dequantize_itd(
- int16_t *ind,
- float *out,
- const int32_t output_Fs
-);
-
-
-
-void stereo_dft_dec_sid_coh(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t nbands, /* i : number of DFT stereo bands */
- float *coh, /* i/o: coherence */
- int16_t *nb_bits /* i/o: number of bits read */
-);
-
-ivas_error stereo_dft_dec_create(
- STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */
- const int32_t element_brate, /* i : element bitrate */
- const int32_t output_Fs, /* i : output sampling rate */
- const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */
- const int16_t nchan_transport /* i : number of transport channels */
-);
-
-void stereo_dft_dec_reset(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */
-);
-
-void stereo_dft_dec_update(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
- const int16_t output_frame, /* i : output frame length */
- const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-);
-
-void stereo_dft_dec_destroy(
- STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */
-);
-
-void stereo_dft_dec_analyze(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const float *input, /* i : input signal */
- float out_DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */
- const int16_t chan, /* i : channel number */
- const int16_t input_frame, /* i : input frame size */
- const int16_t output_frame, /* i : output frame size */
- const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : signal type to analyze */
- const int16_t k_offset, /* i : offset of DFT */
- const int16_t delay /* i : delay in samples for input signal */
-);
-
-void stereo_dft_dec_synthesize(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i : DFT buffers */
- const int16_t chan, /* i : channel number */
- float output[L_FRAME48k], /* o : output synthesis signal */
- const int16_t output_frame /* i : output frame length */
-);
-
-
-void stereo_dft_res_ecu(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */
- float *pDFT_RES, /* i/o: residual signal */
- float *const DFT_PRED_RES, /* i/o: residual prediction signal */
- const int16_t k, /* i : Subframe index */
- const int16_t output_frame, /* i : Output frame length */
- const int16_t prev_bfi, /* i : Previous BFI */
- const float dmx_nrg, /* i : Down-mix energy */
- int16_t *num_plocs, /* i/o: Number of peak locations */
- int16_t *plocs, /* i/o: Peak locations (bin) */
- float *plocsi, /* i/o: Peak locations (fractional) */
- float *input_mem /* o : Residual DFT buffer input mem */
-);
-
-void stereo_dft_res_subst_spec(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */
- float *pDFT_RES, /* i/o: residual signal */
- const float *const DFT_PRED_RES, /* i : residual prediction signal */
- const int16_t time_offs, /* i : Time offset for phase adjustm. */
- const int16_t L_res, /* i : bandwidth of residual signal */
- const int16_t L_ana, /* i : Length of FFT analysis */
- const int16_t k, /* i : Subframe index */
- int16_t *num_plocs, /* i/o: Number of peak locations */
- int16_t *plocs, /* i/o: Peak locations (bin) */
- float *plocsi, /* i/o: Peak locations (fractional) */
- const int16_t analysis_flag /* i : Flag for running peak analysis */
-);
-
-void stereo_dft_res_ecu_burst_att(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */
- float *pDFT_RES, /* i/o: residual signal /att. residual */
- const float dmx_nrg, /* i : dmx energy of current frame */
- const int16_t L_res, /* i : Bandwidth of residual */
- const int16_t L_ana /* i : Length of FFT analysis */
-);
-
-/*! r: total energy of downmix with maximum swb bandwidth max */
-float stereo_dft_dmx_swb_nrg(
- const float *dmx_k0, /* i : first subframe spectrum */
- const float *dmx_k1, /* i : second subframe spectrum */
- const int16_t frame_length /* i : frame lanegth */
-);
-
-int16_t stereo_dft_sg_recovery(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: Decoder DFT stereo handle */
-);
-
-void stereo_dft_dec_res(
- CPE_DEC_HANDLE hCPE, /* i/o: decoder CPE handle */
- float res_buf[STEREO_DFT_N_8k], /* i : residual buffer */
- float *output /* o : output frame */
-);
-
-/*! r: Decision to enable or disable BPF on DFT stereo residual */
-
-void bpf_pitch_coherence(
- Decoder_State *st, /* i/o: decoder state structure */
- const float pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */
-);
-
-void stereo_dft_dec_read_BS(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int32_t element_brate, /* i : element bitrate */
- int32_t *total_brate, /* o : total bitrate */
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
- const int16_t bwidth, /* i : bandwidth */
- const int16_t output_frame, /* i : output frame length */
- float res_buf[STEREO_DFT_N_8k], /* o : residual buffer */
- int16_t *nb_bits, /* o : number of bits read */
- float *coh, /* i/o: Coherence */
- const int16_t ivas_format /* i : ivas format */
-);
-
-void stereo_dft_dec_smooth_parameters(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
- const int16_t prev_sid_nodata, /* i : Previous SID/No data indicator */
- const int16_t active_frame_counter, /* i : Active frame counter */
- const int32_t element_brate /* i : Element bitrate */
-);
-
-void stereo_dft_generate_res_pred(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
- const float samp_ratio, /* i : sampling ratio */
- float *pDFT_DMX, /* i : downmix signal */
- float *DFT_PRED_RES, /* o : residual prediction signal */
- float *pPredGain, /* i : residual prediction gains */
- const int16_t k, /* i : subframe index */
- float *ap_filt_DMX, /* i : enhanced stereo filling signal */
- int16_t *stop, /* o : last FD stereo filling bin */
- const int16_t bfi /* i : BFI flag */
-);
-
-void stereo_dft_dec_core_switching(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float output[], /* i/o: synthesis @internal Fs */
- float synth[], /* i : synthesis @output Fs */
- float hb_synth[], /* i/o: hb synthesis */
- float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */
- const int16_t output_frame, /* i : output frame length */
- const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const int16_t sba_dirac_stereo_dtx_flag /* i : DTX indicator for SBA DirAC stereo */
-);
-
-void init_basic_allpass(
- basic_allpass_t *ap, /* i/o: basic allpass structure */
- const float *gains, /* i : allpass filter gains */
- const int16_t *delays /* i : allpass filter delays */
-);
-
-void filter_with_allpass(
- const float *sig, /* i : allpass input signal */
- float *out, /* o : filtered output */
- const int16_t len, /* i : length of input */
- basic_allpass_t *ap /* i/o: basic allpass structure */
-);
-
-/*! r: used GR order */
-
-/*! r: used GR order */
-
-
-/*! r: number of bits written */
-
-/*! r: number of bits written */
-
-
-void stereo_dft_enc_compute_itd(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- float *DFT_L,
- float *DFT_R,
- const int16_t k_offset,
- const int16_t input_frame,
- const int16_t vad_flag_dtx[],
- const int16_t vad_hover_flag[],
- float *bin_nrgL,
- float *bin_nrgR
-);
-
-void stereo_dft_config(
- STEREO_DFT_CONFIG_DATA_HANDLE hConfig, /* o : DFT stereo configuration */
- const int32_t brate, /* i : IVAS/CPE/nominal total bitrate */
- int16_t *bits_frame_nominal, /* o : primary channel nominal bits per frame */
- int16_t *bits_frame_nominal_2 /* o : secondary channel nominal bits per frame*/
-);
-
-int16_t stereo_dft_band_config(
- int16_t *band_limits, /* o : DFT band limits */
- const int16_t band_res, /* i : DFT band resolution */
- const int16_t NFFT, /* i : analysis/synthesis window length */
- const int16_t enc_dec /* i : flag to indicate enc vs dec */
-);
-
-void stereo_dft_dmx_out_reset(
- STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */
-);
-
-void stereo_dft_unify_dmx(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */
- Decoder_State *st0, /* i/o: decoder state structure */
- float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */
- float *input_mem, /* i/o: mem of buffer DFT analysis */
- const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */
-);
-
-void add_HB_to_mono_dmx(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float output[L_FRAME48k], /* i/o: output synthesis */
- float outputHB[L_FRAME48k], /* i : HB synthesis */
- const int16_t last_core, /* i : last core, primary channel */
- const int16_t output_frame /* i : frame length */
-);
-
-/*----------------------------------------------------------------------------------*
- * Range Coder prototypes
- *----------------------------------------------------------------------------------*/
-
-void rc_uni_dec_init(
- RangeUniDecState *rc_st_dec, /* i/o: RC state handle */
- uint16_t *bit_buffer, /* i : Bit buffer */
- const int16_t max_available_bits /* i : Total maximum bits available */
-);
-
-/*! r: Read symbol */
-uint16_t rc_uni_dec_read_symbol_fastS(
- RangeUniDecState *rc_st_dec, /* i/o: Decoder State */
- const uint16_t cum_freq_table[], /* i : Cumulative frequency up to symbol */
- const uint16_t sym_freq_table[], /* i : Symbol frequency */
- const uint16_t alphabet_size, /* i : Number of symbols in the alphabet */
- const uint16_t tot_shift /* i : Total frequency as a power of 2 */
-);
-
-/*! r: Read bit */
-uint16_t rc_uni_dec_read_bit(
- RangeUniDecState *rc_st_dec /* i/o: RC state handle */
-);
-
-/*! r: Read bit */
-uint16_t rc_uni_dec_read_bit_prob_fast(
- RangeUniDecState *rc_st_dec, /* i/o: RC state handle */
- const int16_t freq0, /* i : Frequency for symbol 0 */
- const uint16_t tot_shift /* i : Total frequency as a power of 2 */
-);
-
-/*! r: Read bits */
-uint16_t rc_uni_dec_read_bits(
- RangeUniDecState *rc_st_dec, /* i/o: RC state handle */
- const int16_t bits /* i : Number of bits */
-);
-
-/*! r: Total number of bits consumed */
-int16_t rc_uni_dec_virtual_finish(
- RangeUniDecState *rc_st_dec /* i/o: RC state handle */
-);
-
-/*! r: Total number of bits consumed */
-int16_t rc_uni_dec_finish(
- RangeUniDecState *rc_st_dec /* i/o: RC state handle */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * ECLVQ Stereo prototypes
- *----------------------------------------------------------------------------------*/
-
-float ECSQ_dequantize_gain(
- const int16_t index
-);
-
-
-
-void ECSQ_init_instance(
- ECSQ_instance *ecsq_inst,
- const int16_t config_index,
- void *ac_handle
-);
-
-
-
-void ECSQ_dequantize_vector(
- const int16_t *input,
- const float global_gain,
- const int16_t N,
- float *output
-);
-
-
-/*----------------------------------------------------------------------------------*
- * ICA Stereo prototypes
- *----------------------------------------------------------------------------------*/
-
-void stereo_tca_init_enc(
- STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA encoder handle */
- const int32_t input_Fs /* i : input sampling frequency */
-);
-
-void stereo_tca_enc(
- CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- const int16_t input_frame /* i : length of a frame per channel */
-);
-
-void stereo_tca_init_dec(
- STEREO_TCA_DEC_HANDLE hStereoTCA /* i/o: Stereo TCA handle */
-);
-
-void stereo_tca_dec(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *synth[CPE_CHANNELS], /* i/o: output synth */
- const int16_t output_frame /* i : length of a frame per channel */
-);
-
-void stereo_tca_scale_R_channel(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *output, /* i/o: output synthesis, R channel */
- const int16_t output_frame /* i : frame length */
-);
-
-void adjustTargetSignal(
- float *target,
- const int16_t prevShift,
- const int16_t currShift,
- const int16_t L_shift_adapt,
- const int16_t method
-);
-
-/*----------------------------------------------------------------------------------*
- * IC-BWE Stereo prototypes
- *----------------------------------------------------------------------------------*/
-
-
-void stereo_icBWE_preproc(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const int16_t input_frame, /* i : input frame length */
- float shb_speech_nonref[] /* o : SHB speech non-ref channel */
-);
-
-void stereo_icBWE_enc(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const float shb_speech_ref[], /* i : SHB speech ref channel */
- float shb_speech_nonref[], /* i/o: SHB speech non-ref channel */
- const float *voice_factors /* i : voicing factors */
-);
-
-void stereo_icBWE_init_dec(
- STEREO_ICBWE_DEC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */
-);
-
-void stereo_icBWE_dec(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *synthRef, /* i/o: Reference channel HB synthesis at output Fs */
- float *synth, /* o : Non reference channel HB synthesis at output Fs */
- const float *fb_synth_ref, /* i : ref. high-band synthesis 16-20 kHz */
- const float *voice_factors, /* i : voicing factors */
- const int16_t output_frame /* i : frame length */
-);
-
-void stereo_icBWE_decproc(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *output[CPE_CHANNELS], /* i/o: output symthesis */
- float outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis */
- const int16_t last_core, /* i : last core, primary channel */
- const int16_t last_bwidth, /* i : last bandwidth */
- const int16_t output_frame /* i : frame length */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Stereo classifiers prototypes
- *----------------------------------------------------------------------------------*/
-
-void stereo_classifier_features(
- STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
- const int16_t idchan, /* i : channel ID */
- const int16_t element_mode, /* i : element mode */
- const int16_t vad_flag, /* i : VAD flag */
- const float lsf_new[], /* i : LSFs at the end of the frame */
- const float epsP[], /* i : LP analysis residual energies for each iteration*/
- const int16_t pitch[], /* i : open-loop pitch values for quantiz. */
- const float voicing[], /* i : OL maximum normalized correlation */
- const float cor_map_sum, /* i : speech/music clasif. parameter */
- const float non_staX, /* i : unbound non-stationarity for sp/mu clas. */
- const float sp_div, /* i : spectral diversity feature */
- const int16_t clas /* i : signal class */
-);
-
-
-void xtalk_classifier_dft(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const int16_t itd, /* i : ITD from DFT stereo - used as a feature */
- const float gcc_phat[] /* i : GPHAT cross-channel correlation function */
-);
-
-/*----------------------------------------------------------------------------------*
- * TD Stereo prototypes
- *----------------------------------------------------------------------------------*/
-
-void stereo_td_init_enc(
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- const int16_t last_element_mode /* i : last element mode */
-);
-
-
-
-void stereo_tdm_downmix(
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i : TD stereo IVAS encoder structure */
- float *Left_in, /* i/o: Left channel -> Primary channel */
- float *Right_in, /* i/o: Right channel -> Secondary channel */
- const int16_t input_frame, /* i : Number of samples */
- const int16_t tdm_ratio_idx, /* i : TDM ratio index */
- const int16_t tdm_SM_flag, /* i : channel combination scheme flag */
- const int16_t tdm_ratio_idx_SM /* i : TDM ratio index for SM mode */
-);
-
-void stereo_td_init_dec(
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const int16_t last_element_mode /* i : last element mode */
-);
-
-void tdm_configure_dec(
- const int16_t ivas_format, /* i : IVAS format */
- const int16_t ism_mode, /* i : ISM mode in combined format */
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- int16_t *tdm_ratio_idx, /* o : ratio index */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-void tdm_upmix_plain(
- float Left[], /* o : left channel */
- float Right[], /* o : right channel */
- const float PCh_2_L[], /* i : primary channel */
- const float SCh_2_R[], /* i : secondary channel */
- const float LR_ratio, /* i : mixing ratio */
- const float inv_den_LR_ratio, /* i : inverse mixing ration */
- const int16_t start_index, /* i : start index */
- const int16_t end_index, /* i : end index */
- const int16_t plus_minus_flag /* i : plus/minus flag */
-);
-
-void stereo_tdm_combine(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *PCh_2_L, /* i/o: Primary channel -> output as L channel */
- float *SCh_2_R, /* i/o: Seconday channel -> output as R channel */
- const int16_t output_frame, /* i : Number of samples */
- const int16_t flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis */
- const int16_t tdm_ratio_idx /* i : TDM ratio index */
-);
-
-/*! r: replication decision; 1 = Use old LP */
-void tdm_ol_pitch_comparison(
- CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- float pitch_fr[CPE_CHANNELS][NB_SUBFR], /* i/o: fractional pitch values */
- float voicing_fr[CPE_CHANNELS][NB_SUBFR] /* i/o: fractional pitch gains */
-);
-
-void tdm_configure_enc(
- const int16_t ivas_format, /* i : IVAS format */
- const int16_t ism_mode, /* i : ISM mode in combined format */
- CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */
- const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */
- const int16_t tdm_ratio_idx, /* i : ratio index */
- const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */
- const int16_t attack_flag, /* i : Primary channel attack flag */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-
-void tdm_bit_alloc(
- const int16_t ivas_format, /* i : IVAS format */
- const int16_t ism_mode, /* i : ISM mode in combined format */
- const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */
- const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */
- int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */
- int32_t *total_brate_sec, /* o : Allocated secondary channel bitrate */
- int16_t *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */
- const int16_t coder_type, /* i : secondary channel coder type */
- const int16_t ener_ratio_idx, /* i : correlation ratio indexe */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const int16_t bwidth_pri, /* i : bandwidth of the primary channel */
- const int16_t bwidth_sec, /* i : bandwidth of the secondary channel */
- const int16_t flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */
- const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */
- const int16_t tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */
-);
-
-
-/*! r: value of the indice */
-uint16_t get_indice_st(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t pos, /* i : absolute position in the bitstream */
- const int16_t nb_bits /* i : number of bits to quantize the indice */
-);
-
-void tdm_low_rate_dec(
- Decoder_State *st, /* i/o: decoder static memory */
- float dct_epit[], /* o : GSC excitation in DCT domain */
- float *tmp_noise, /* o : long term temporary noise energy */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *exc, /* i/o: adapt. excitation exc */
- float *exc2, /* i/o: adapt. excitation/total exc */
- float *bwe_exc, /* o : excitation for SWB TBE */
- const float *lsf_new /* i : ISFs at the end of the frame */
-);
-
-void tdm_SCh_LSF_intra_pred(
- const int32_t element_brate, /* i : element bitrate */
- const float *tdm_lsfQ_PCh, /* i : primary channel LSFs */
- float *pred_lsf_SCh /* o : predicted secondary channel LSFs */
-);
-
-
-void first_VQstages(
- const float *const *cb,
- const float u[], /* i : vector to be encoded (prediction and mean removed) */
- const int16_t *levels, /* i : number of levels in each stage */
- const int16_t stagesVQ, /* i : number of stages */
- const float w[], /* i : weights */
- const int16_t N, /* i : vector dimension */
- const int16_t max_inner, /* i : maximum number of swaps in inner loop */
- int16_t indices_VQstage[]
-);
-
-
-void deindex_lvq_SHB(
- UWord32 index,
- float *out,
- const int16_t nbits,
- const int16_t mode
-);
-
-/*----------------------------------------------------------------------------------*
- * MDCT Stereo prototypes
- *----------------------------------------------------------------------------------*/
-
-void stereo_td_itd_mdct_stereo(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */
- const int16_t vad_flag_dtx[], /* i : VAD dtx flags */
- const int16_t vad_hover_flag[], /* i : VAD hangover flags */
- const int16_t input_frame /* i : frame length */
-);
-
-void QuantizeTCXSpectrum(
- Encoder_State *st, /* i : state handle */
- const int16_t frame_cnt, /* i : frame counter in the super_frame */
- const float *x_orig, /* i : shaped MDCT spectrum */
- const float *gainlpc, /* i : FDNS gains */
- const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) */
- const int16_t tnsSize, /* i : number of tns parameters put into prm */
- const int16_t nb_bits, /* i : bit budget */
- const int16_t vad_hover_flag, /* i : VAD hangover flag */
- int16_t *pL_frameTCX, /* o : full frame length */
- int16_t *pL_frame, /* o : frame length */
- int16_t *pL_spec, /* o : length of the coded spectrum */
- int16_t *ptcx_offset, /* o : folding point offset relative to the end of the previous frame */
- int16_t *pnoiseFillingBorder, /* o : noise filling border */
- float spectrum[], /* o : quantized MDCT spectrum */
- CONTEXT_HM_CONFIG *hm_cfg, /* o : Context-based harmonic model configuration */
- int16_t *hm_active, /* o : flag indicating if the harmonic model is active */
- float lf_deemph_fact[], /* o : low frequency deemphasis factors */
- int16_t *nf_seed, /* o : noise filling random seed */
- float *ener, /* o : energy of the quantized spectrum */
- float *gain_tcx, /* o : global gain */
- int16_t prm[] /* o : tcx parameters */
-);
-
-void EstimateStereoTCXNoiseLevel(
- Encoder_State **sts, /* i : state handle */
- float *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */
- float gain_tcx[][NB_DIV], /* i : global gain */
- int16_t L_frame[][NB_DIV], /* i : frame length */
- int16_t noiseFillingBorder[][NB_DIV], /* i : noise filling border */
- int16_t hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */
- const int16_t ignore_chan[], /* i : flag indicating whether the channel should be ignored */
- float fac_ns[][NB_DIV], /* o : noise filling level */
- int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-void TNSAnalysisStereo(
- Encoder_State **sts, /* i : state handle */
- float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum */
- const int16_t bWhitenedDomain, /* i : whitened domain flag */
- int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm */
- int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame */
- int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */
- const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
-);
-
-void InternalTCXDecoder(
- Encoder_State *st, /* i/o: state handle */
- const int16_t frame_cnt, /* i : frame counter in the super_frame */
- const int16_t L_frameTCX, /* i : full frame length */
- const int16_t L_frame, /* i : frame length */
- const int16_t L_spec, /* i : length of the coded spectrum */
- const int16_t tcx_offset, /* i : folding point offset relative to the end of the previous frame */
- const int16_t noiseFillingBorder, /* i : noise filling border */
- const float *x_quant, /* i : quantized spectrum */
- const float ener, /* i : energy of the quantized spectrum */
- float lf_deemph_fact[], /* i/o: low frequency deemphasis factors */
- const float fac_ns, /* i : noise filling level */
- const int16_t nf_seed, /* i : noise filling random seed */
- const float *A, /* i : LPC representation of the FDNS gains */
- float *gainlpc, /* i/o: FDNS gains */
- const int16_t hm_active, /* i : flag indicating if the harmonic model is active */
- float gain_tcx, /* i/o: global gain / quantized global gain */
- float spectrum[], /* o : dequantized spectrum */
- float synth[], /* o : time domain signal */
- int16_t *gain_tcx_q /* o : quantized global gain (at low bitrates) */
-);
-
-void stereo_mdct_core_enc_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
- Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
- Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
-);
-
-void initMdctStereoEncData(
- STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t element_mode, /* i : element mode */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t bwidth, /* i : bandwidth */
- const int16_t igf, /* i : flag indicating IGF activity */
- const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */
- const int16_t mem_init /* i : initialize memory after malloc */
-);
-
-ivas_error initMdctItdHandling(
- STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
- const int32_t input_Fs /* i : input sampling rate */
-);
-
-void stereo_mdct_enc_destroy(
- STEREO_MDCT_ENC_DATA_HANDLE *hStereoMdct /* i/o: encoder MDCT stereo handle */
-);
-
-void initMdctStereoDecData(
- STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
- const int16_t igf, /* i : flag indicating IGF activity */
- const H_IGF_GRID igfGrid, /* i : IGF grid configuration */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void stereo_mdct_init_bands(
- const int16_t L_frame, /* i : frame length */
- const int16_t tmp_tcx_mode, /* i : tcx mode (TCX10, TCX 20), -1 if transition frame */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t igf, /* i : flag indicating if IGF is used */
- const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */
- int16_t *sfbOffset, /* o : sfb offset table */
- int16_t *sfbCnt /* o : number of sfbs */
-);
-
-void stereo_mdct_init_igf_start_band(
- STEREO_MDCT_BAND_PARAMETERS *stbParams, /* i/o: stereo frequency band parameters */
- const float transFac, /* i : transform factor */
- const int16_t bwidth, /* i : audio bandwidth */
- const int32_t element_brate /* i : element bitrate */
-);
-
-void init_tcx_enc_info(
- Encoder_State *st, /* i : coder memory state */
- int16_t *L_frame,
- int16_t *L_frameTCX,
- int16_t *L_spec
-);
-
-void decoder_tcx_invQ(
- Decoder_State *st, /* i/o: coder memory state */
- int16_t prm[], /* i : parameters */
- float A[], /* i : coefficients NxAz[M+1] */
- Word16 Aind[], /* i : frame-independent coefficients Az[M+1] */
- const int16_t L_spec,
- const int16_t L_frame,
- const int16_t L_frameTCX,
- float x[],
- float gainlpc2[],
- float xn_buf[],
- int16_t *fUseTns, /* o : flag that is set if TNS data is present */
- STnsData *tnsData,
- float *gain_tcx,
- const int16_t **prm_sqQ,
- int16_t *nf_seed,
- const int16_t bfi, /* i : Bad frame indicator */
- const int16_t frame_cnt /* i : frame counter in the super frame */
-);
-
-void decoder_tcx_noisefilling(
- Decoder_State *st, /* i/o: coder memory state */
- float concealment_noise[L_FRAME48k],
- const float A[], /* i : coefficients NxAz[M+1] */
- const int16_t L_frameTCX_glob,
- const int16_t L_spec,
- const int16_t L_frame,
- const int16_t L_frameTCX,
- float x[],
- float gainlpc2[],
- int16_t *temp_concealment_method,
- const float gain_tcx,
- const int16_t *prm_sqQ,
- int16_t nf_seed,
- const int16_t bfi, /* i : Bad frame indicator */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int16_t frame_cnt /* i : frame counter in the super frame */
-);
-
-void decoder_tcx_noiseshaping_igf(
- Decoder_State *st, /* i/o: coder memory state */
- const int16_t L_spec,
- const int16_t L_frame,
- const int16_t L_frameTCX,
- const int16_t left_rect,
- float x[],
- const float gainlpc2[],
- int16_t *temp_concealment_method,
- const int16_t bfi /* i : Bad frame indicator */
-);
-
-void decoder_tcx_tns(
- Decoder_State *st, /* i/o: coder memory state */
- const int16_t L_frame_glob,
- const int16_t L_spec,
- const int16_t L_frame,
- const int16_t L_frameTCX,
- float x[N_MAX],
- const int16_t fUseTns, /* i : flag that is set if TNS data is present */
- STnsData *tnsData,
- const int16_t bfi, /* i : Bad frame indicator */
- const int16_t frame_cnt, /* i : frame counter in the super frame */
- const int16_t whitenedDomain
-);
-
-void decoder_tcx_imdct(
- Decoder_State *st, /* i/o: coder memory state */
- const int16_t L_frame_glob, /* i : frame length */
- const int16_t L_frameTCX_glob,
- const int16_t L_spec,
- const int16_t tcx_offset,
- const int16_t tcx_offsetFB,
- const int16_t L_frame,
- const int16_t L_frameTCX,
- const int16_t left_rect,
- float x[N_MAX],
- float xn_buf[],
- const uint16_t kernelType, /* i : TCX transform kernel type */
- const int16_t fUseTns, /* i : flag that is set if TNS data is present */
- float synth[], /* i/o: synth[-M..L_frame] */
- float synthFB[],
- const int16_t bfi, /* i : Bad frame indicator */
- const int16_t frame_cnt, /* i : frame counter in the super frame */
- const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-);
-
-void init_tcx_info(
- Decoder_State *st, /* i/o: coder memory state */
- const int16_t L_frame_glob, /* i : global frame length */
- const int16_t L_frameTCX_glob, /* i : FB global frame length */
- const int16_t frame_cnt, /* i : frame counter in the super_frame */
- const int16_t bfi, /* i : bad frame indicator */
- int16_t *tcx_offset, /* o : folding point offset relative to the end of the previous frame */
- int16_t *tcx_offsetFB, /* o : FB folding point offset relative to the end of the previous frame*/
- int16_t *L_frame, /* o : frame length */
- int16_t *L_frameTCX, /* o : TCX frame length */
- int16_t *left_rect, /* o : left part is rectangular */
- int16_t *L_spec /* o : spectrum length */
-);
-
-void decoder_tcx_IGF_mono(
- Decoder_State *st, /* i/o: coder memory state */
- float x[], /* o : de-quatized coefficients */
- const int16_t L_frame, /* i : frame length */
- const int16_t left_rect, /* i : left part is rectangular */
- const int16_t bfi, /* i : bad frame indicator */
- const int16_t frame_cnt /* i : frame counter in the super_frame */
-);
-
-void decoder_tcx_IGF_stereo(
- Decoder_State **sts, /* i/o: coder memory states */
- STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- float *x[CPE_CHANNELS][NB_DIV], /* o : de-quatized coefficients */
- const int16_t L_frame, /* i : frame length */
- const int16_t left_rect, /* i : left part is rectangular */
- const int16_t k, /* i : Subframe index */
- const int16_t bfi, /* i : bad frame indicator */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-void ms_processing(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */
- Encoder_State **sts, /* i/o: Encoder state structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const int16_t iSubframe, /* i : subframe number */
- float x_0[], /* i/o: spectrum 1 */
- float x_1[], /* i/o: spectrum 2 */
- int16_t maxSfb /* i : number of stereo frequency bands */
-);
-
-void ms_inv_mask_processing(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */
- Encoder_State **sts, /* i/o: Encoder state structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const int16_t iSubframe, /* i : subframe number */
- const float x_0[], /* i : spectrum 1 */
- const float x_1[], /* i : spectrum 2 */
- float x_inv_0[], /* o : inverse spectrum 1 */
- float x_inv_1[], /* o : inverse spectrum 2 */
- int16_t maxSfb /* i : number of stereo frequency bands */
-);
-
-void IGFDecApplyStereo_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */
- const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */
- float *spectrumL, /* i/o: L MDCT spectrum */
- float *spectrumR, /* i/o: R MDCT spectrum */
- const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
- const int16_t *coreMsMask,
- const int16_t restrict_hopsize,
- const int16_t bfi, /* i : frame loss == 1, frame good == 0 */
- const int16_t bfi_apply_damping /* i : decoder element mode */
-);
-
-void IGFEncStereoEncoder(
- STEREO_MDCT_BAND_PARAMETERS *sfbParam, /* i/o: sfb parameters for the right channel */
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : IGF handle */
- const float *mdctSpectrumL, /* i : left spectrum */
- const float *mdctSpectrumR, /* i : right spectrum */
- int16_t *msMask, /* i/o: MS mask */
- int16_t *igfStereoMode, /* o : IGF stereo mode */
- const int16_t mdct_stereo_mode, /* i : MDCT stereo mode */
- const int16_t isTCX20, /* i : flag for indicating TCX20 */
- const int16_t isTransition /* i : flag for transtition */
-);
-
-void IGFDecReplicateTCX10State_flt(
- IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: instance handle of IGF Decoder */
-);
-
-
-void InitPsychLPC(
- const int32_t sr_core, /* i : sampling rate of core-coder */
- const int16_t L_frame, /* i : frame length */
- const TCX_CONFIG_HANDLE hTcxCfg /* i : TCX configuration handle */
-);
-
-
-void stereo_coder_tcx(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */
- Encoder_State **sts, /* i/o: encoder state structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
- float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
- float *inv_mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
- const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
-);
-
-void stereo_decoder_tcx(
- STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: MDCT stereo decoder structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- float *spec_r_0[NB_DIV], /* i/o: spectrum right channel */
- float *spec_l[], /* i/o: spectrum left channel [NB_DIV][N] */
- float *spec_r[], /* i/o: spectrum right channel [NB_DIV][N] */
- const int16_t mdct_stereo_mode[], /* i : stereo mode (FB/band wise MS, dual mono */
- const int16_t core_l, /* i : core for left channel (TCX20/TCX10) */
- const int16_t core_r, /* i : core for right channel (TCX20/TCX10) */
- const int16_t igf, /* i : flag for IGF activity */
- const int16_t L_frameTCX_l, /* i : TCX frame length of left channel */
- const int16_t L_frameTCX_r, /* i : TCX frame length of right channel */
- const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
- const int16_t last_core_l, /* i : last core for left channel */
- const int16_t last_core_r, /* i : last core for right channel */
- const int16_t tmp_plc_upmix /* i : indicates temp upmix for PLC decision */
-);
-
-void stereo_mdct_core_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */
- float signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */
-);
-
-void splitAvailableBits(
- const int16_t total_bits, /* i : total available bits for TCX coding */
- const int16_t split_ratio, /* i : split ratio */
- const int16_t isSBAStereoMode, /* i : signal core coding for SBA */
- int16_t *bits_ch0, /* o : bits for channel 0 */
- int16_t *bits_ch1 /* o : bits for channel 1 */
-);
-
-Word16 write_stereo_to_bitstream_fx
-(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
- Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
- const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
- BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
-);
-
-
-
-void ComputeSpectrumNoiseMeasure(
- const float *powerSpec,
- const int16_t L_frame,
- const int16_t startLine,
- const int16_t resetMemory,
- int8_t *noiseFlags,
- const int16_t lowpassLine
-);
-
-void IGFSaveSpectrumForITF(
- IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */
- const int16_t igfGridIdx, /* i : IGF grid index */
- const float *pITFSpectrum /* i : MDCT spectrum */
-);
-
-void convert_coeffs_to_higher_res(
- const float *in1, /* i : first subframe input */
- const float *in2, /* i : second subframe input */
- float *out, /* o : converted output */
- const int16_t len /* i : length of subframes */
-);
-
-int16_t quantize_sns(
- float sns_in[CPE_CHANNELS][NB_DIV][M],
- float snsQ_out[CPE_CHANNELS][NB_DIV][M],
- Encoder_State **sts,
- int16_t *indices,
- int16_t *zero_side_flag,
- int16_t *sns_stereo_mode
-);
-
-void dequantize_sns(
- int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW],
- float snsQ_out[CPE_CHANNELS][NB_DIV][M],
- Decoder_State **sts
-);
-
-void sns_avq_dec(
- int16_t *index, /* i : Quantization indices */
- float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */
- const int16_t L_frame, /* i : frame length */
- const int16_t numlpc /* i : Number of sets of lpc */
-);
-
-void sns_avq_dec_stereo(
- int16_t *indexl, /* i : Quantization indices (left channel) */
- int16_t *indexr, /* i : Quantization indices (right channe) */
- const int16_t L_frame, /* i : frame length */
- float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */
- float *SNS_Qr /* o : Quantized SNS vectors (right channe) */
-);
-
-void convertToMS(
- const int16_t L_frame, /* i : frame length */
- float x0[], /* i/o: mid/left channel coefficients */
- float x1[], /* i/o: side/right channel coefficients */
- const float norm_fac /* i : normalization factor */
-);
-
-void inverseMS(
- const int16_t L_frame, /* i : frame length */
- float x0[], /* i/o: mid/left channel coefficients */
- float x1[], /* i/o: side/right channel coefficients */
- const float norm_fac /* i : normalization factor */
-);
-
-void stereoFdCngCoherence(
- Encoder_State **sts, /* i/o: core encoder structures */
- const int16_t last_element_mode, /* i : last element mode */
- float fft_buff[CPE_CHANNELS][2 * L_FFT] /* i : fft buffers for L and R channels */
-);
-
-void FdCngEncodeMDCTStereoSID(
- CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */
-);
-
-void FdCngDecodeMDCTStereoSID(
- CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */
-);
-
-ivas_error initMdctStereoDtxData(
- CPE_DEC_HANDLE hCPE /* i/o: CPE decoder handle */
-);
-
-void synchonize_channels_mdct_sid(
- Decoder_State *sts[CPE_CHANNELS], /* i/o: decoder state structure */
- const int16_t n /* i : channel number */
-);
-
-void updateBuffersForDmxMdctStereo(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
- const int16_t output_frame, /* i : output frame length */
- float *output[CPE_CHANNELS], /* i/o: decoder output */
- float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */
-);
-
-void applyDmxMdctStereo(
- const CPE_DEC_HANDLE hCPE, /* i : CPE handle */
- float *output[CPE_CHANNELS], /* o : output from core decoder */
- const int16_t output_frame /* i : output frame length */
-);
-
-/*----------------------------------------------------------------------------------*
- * Front-VAD prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error front_vad_create(
- FRONT_VAD_ENC_HANDLE *hFrontVad, /* i/o: front-VAD handle */
- const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */
-);
-
-void front_vad_destroy(
- FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */
-);
-
-ivas_error front_vad(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */
- Encoder_State *st, /* i/o: encoder state structure */
- const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
- FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: front-VAD handles */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int16_t input_frame, /* i : frame length */
- int16_t vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
- float fr_bands[][2 * NB_BANDS], /* i : energy in frequency bands */
- float Etot_LR[], /* o : total energy Left & Right channel */
- float lf_E[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */
- int16_t localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */
- int16_t vad_hover_flag[], /* o : VAD hangover flag */
- float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */
- float *PS_out, /* o : energy spectrum */
- float *Bin_E_out /* o : log-energy spectrum of the current frame*/
-);
-
-ivas_error front_vad_spar(
- SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */
- const float *omni_in, /* i : omnidirectional input signal */
- ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */
- const int16_t input_frame /* i : input frame length */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Stereo CNG prototypes
- *----------------------------------------------------------------------------------*/
-
-void stereo_enc_cng_init(
- STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */
-);
-
-void stereo_cng_upd_counters(
- STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */
- const int32_t element_mode, /* i : element mode */
- const int16_t nbands, /* i : Number of bands in active */
- const float sidSideGain[], /* i : SID side gains */
- const int16_t burst_ho_count, /* i : Hang-over count */
- int16_t *coh_fade_counter /* i : Coherence fade counter */
-);
-
-void stereo_cng_init_dec(
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */
- const int16_t *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 */
-);
-
-void stereo_cng_compute_PScorr(
- float *output[CPE_CHANNELS], /* i : Output signal */
- float *c_PS_LT, /* i/o: Correlation */
- const int16_t L_frame_0, /* i : L_frame channel 0 */
- const int16_t L_frame_1 /* i : L_frame channel 1 */
-);
-
-void stereo_cng_dec_update(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const int32_t ivas_total_brate /* i : IVAS total bitrate Q0*/
-);
-
-void stereo_cna_update_params(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *output[CPE_CHANNELS], /* i : Output signal */
- const int16_t output_frame, /* i : Output frame length */
- const int16_t tdm_ratio_idx /* i : TDM ratio index */
-);
-
-void dtx_enc_init(
- Encoder_State *st, /* i : Encoder state handle */
- const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */
- const int16_t interval_SID /* i : interval for SID update */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Framework general prototypes
- *----------------------------------------------------------------------------------*/
-
-void mvc2c(
- const uint8_t x[], /* i : input vector */
- uint8_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-/*! r: Adjusted value */
-ivas_error stereo_memory_dec(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */
- const int16_t nb_bits_metadata, /* i : number of metadata bits */
- const int32_t output_Fs, /* i : output sampling rate */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const MC_MODE mc_mode, /* i : MC mode */
- const int16_t nchan_transport /* i : number of transport channels */
-);
-
-void stereo_switching_dec(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/
-);
-
-void stereo_td2dft_update(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const int16_t n, /* i : channel number */
- float output[], /* i/o: synthesis @internal Fs */
- float synth[], /* i/o: synthesis @output Fs */
- float hb_synth[], /* i/o: hb synthesis */
- const int16_t output_frame /* i : frame length */
-);
-
-void stereo_mdct2dft_update(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float output0[], /* i/o: synthesis @internal Fs, ch0 */
- float synth0[] /* i/o: synthesis @output Fs, ch0 */
-);
-
-
-/*! r: number of bits written */
-
-
-
-/*----------------------------------------------------------------------------------*
- * MCT prototypes
- *----------------------------------------------------------------------------------*/
-void ivas_mdct_core_whitening_enc_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */
- Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */
- int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */
- Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */
- int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
- const int16_t nChannels, /* i : total number of coded channels */
-Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV],
-Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV]
-);
-void ivas_mct_core_enc(
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */
- const int16_t nChannels, /* i : number of channels to be coded */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t switch_bw, /* i : flag bandwidth switch occurance */
- const int16_t lfe_bits, /* i : bits spent for LFE */
- const int16_t sba_order /* i : Ambisonic (SBA) order */
-);
-
-void ivas_mdct_quant_coder(
- CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */
- int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */
- int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-void apply_MCT_enc(
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- Encoder_State **sts, /* i/o: encoder state structure */
- float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
- float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
- float *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
- const int16_t nchan /* i : number of channels */
-);
-
-void write_mct_bitstream(
- Encoder_State **sts, /* i/o: encoder state structure */
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const int16_t nchan /* i : number of channels */
-);
-
-void splitAvailableBitsMCT_fx(
- void **sts, /* i/o: encoder/decoder state structure */
- const Word16 total_bits, /* i : total number of available bits */
- const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */
- const Word16 enc_dec, /* i : encoder or decoder flag */
- const Word16 nchan /* i : number of channels */
-);
-
-void getChannelEnergies(
- Encoder_State **sts, /* i : Encoder state structure */
- float nrg[MCT_MAX_CHANNELS], /* o : energies */
- const int16_t nchan /* i : number of channels */
-);
-
-void mctStereoIGF_enc(
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- Encoder_State **sts, /* i/o: encoder state structure */
- float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */
- float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */
- float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect. */
- float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
- const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */
-);
-
-void ivas_mdct_dec_side_bits_frame_channel(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */
- Decoder_State *st0, /* i : pointer to bitstream handle */
- int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */
- int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */
-);
-
-void ivas_mct_side_bits(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */
- const int16_t nCPE, /* i : number of CPEs */
- Decoder_State *st0, /* i : decoder handle for Bstr */
- const int16_t bfi, /* i : BFI flag */
- uint16_t *bitstream, /* o : bitstream indices */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
-);
-
-void ivas_mdct_core_invQ(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
- int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */
- int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */
- int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i : param buffer */
- int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */
- STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */
- float *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
- float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
- float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-void ivas_mdct_core_reconstruct(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */
- float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */
- int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-void ivas_mdct_core_tns_ns(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */
- STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */
- float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */
- float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-
-void ivas_mct_dec_mct(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- Decoder_State **sts, /* i/o: decoder state structure */
- const int16_t nchan /* i : number of channels */
-);
-
-void apply_MCT_dec(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- Decoder_State **sts, /* i/o: decoder state structure */
- float *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */
-);
-
-void mctStereoIGF_dec(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- Decoder_State **sts, /* i/o: decoder state structure */
- float *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequantized spectrum */
- const int16_t bfi /* i : bad frame flag */
-);
-
-void enc_prm_igf_mdct(
- Encoder_State *st, /* i : Encoder state handle */
- BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */
-);
-
-void mdct_read_IGF_bits(
- Decoder_State *st, /* i/o: Encoder state handle */
- Decoder_State *st0 /* i : pointer to handle where bstr is read */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Q Metadata prototypes for DirAC and MASA
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_qmetadata_enc_encode(
- BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */
- IVAS_QMETADATA *hQMetaData, /* i/o: q_metadata handle */
- const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */
-);
-
-ivas_error ivas_qmetadata_enc_encode_hr_384_512(
- BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */
- IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */
- const int16_t bits_sph_idx,
- const int16_t bits_sp_coh
-);
-
-void deindex_sph_idx(
- const uint16_t sphIndex, /* i : Spherical index */
- const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */
- float *theta, /* o : Elevation */
- float *phi /* o : Azimuth */
-);
-
-/*! r: output index for direction */
-uint16_t index_theta_phi_16(
- float * p_theta, /* i/o: input elevation to be indexed */
- float * p_phi, /* i/o: input azimuth to be indexed */
- const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */
-);
-
-void reset_metadata_spatial(
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
- const int32_t element_brate, /* i : element bitrate */
- int32_t *total_brate, /* o : total bitrate */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t nb_bits_metadata /* i : number of meatdata bits */
-);
-
-/*! r: number of bits written */
-
-/*! r: number of bits read */
-int16_t ivas_qmetadata_dec_decode(
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- uint16_t *bitstream, /* i : bitstream */
- int16_t *index, /* i/o: bitstream position */
- const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */
-);
-
-/*! r: number of bits read */
-int16_t ivas_qmetadata_dec_decode_hr_384_512(
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */
- uint16_t *bitstream, /* i : bitstream */
- int16_t *index, /* i/o: bitstream position */
- const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */
- const int16_t bits_sph_idx,
- const int16_t bits_sp_coh,
- const uint8_t ncoding_bands_config
-);
-
-/*! r: number of bits read */
-int16_t ivas_qmetadata_dec_sid_decode(
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- uint16_t *bitstream, /* i : bitstream */
- int16_t *index, /* i/o: bitstream position */
- const int16_t nchan_transport, /* i : number of transport channels */
- int16_t *element_mode, /* o : element mode */
- const int16_t ivas_format /* i : IVAS format */
-);
-
-
-
-
-void restore_metadata_buffer(
- BSTR_ENC_HANDLE hMetaData,
- const int16_t next_ind_start,
- const int16_t bit_pos_start
-);
-
-/*! r: codeword index */
-int16_t masa_sq(
- const float in, /* i : input value */
- const float *threshold, /* i : partition */
- const int16_t cb_sz /* i : codebook size */
-);
-
-void ivas_qmetadata_azimuth_elevation_to_direction_vector(
- const float az, /* i : azimuth */
- const float el, /* i : elevation */
- float *dv /* o : direction vector */
-);
-
-ivas_error only_reduce_bits_direction(
- int16_t *reduce_bits_out,
- IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */
- int16_t reduce_bits,
- const int16_t coding_subbands,
- const int16_t no_subframes,
- int16_t *ind_order
-);
-
-void quantize_direction_frame(
- IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */
- float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
- float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
- const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding*/
-);
-
-/*! r: quantized spherical index */
-uint16_t quantize_direction(
- const float theta, /* i : input elevation value */
- float phi, /* i : input azimuth value */
- const int16_t no_bits, /* i : number of bits */
- float *theta_q, /* o : quantized elevation */
- float *phi_q, /* o : quantized azimuth */
- uint16_t *index_theta, /* o : quantized elevation index */
- uint16_t *index_phi, /* o : quantized azimuth index */
- const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
-);
-
-int16_t quantize_direction2D(
- float phi, /* i : input azimuth value */
- const int16_t no_cw, /* i : number of bits */
- float *phi_q, /* o : quantized azimuth value */
- uint16_t *index_phi, /* o : quantized azimuth index */
- const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
-);
-
-void quantize_direction_frame2D(
- IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */
- float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */
- float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] /* i : input elevation values */
-);
-
-void small_requantize_direction_frame(
- IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */
- float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */
- float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input elevation values */
- const int16_t raw_flag[MASA_MAXIMUM_CODING_SUBBANDS], /* i : raw/EC encoding mode for each subband */
- int16_t bits_dir_bands[MASA_MAXIMUM_CODING_SUBBANDS], /* i/o: number of bits per subband */
- int16_t *diff /* i/o: number of bits to be reduced */
-);
-
-/*! r: index azimuth */
-int16_t quantize_phi(
- float phi, /* i : azimuth value */
- const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */
- float *phi_hat, /* o : quantized azimuth */
- const int16_t n /* i : azimuth codebook size */
-);
-
-/*! r: decoded elevation value */
-float deindex_elevation(
- uint16_t *id_th, /* i : input index */
- const int16_t no_bits, /* i : number of bits for the spherical grid */
- const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
-);
-
-float deindex_azimuth(
- int16_t id_phi, /* i : index */
- const int16_t no_bits, /* i : number of bits for the spherical grid */
- const int16_t id_th, /* i : elevation index */
- const int16_t remap, /* i : remapping flag */
- const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
-);
-
-UWord16 ivas_qmetadata_reorder_generic_fx(
- const Word16 signed_value
-);
-
-void ivas_sba_config(
- const int32_t sba_total_brate, /* i : SBA total bitrate */
- int16_t sba_order, /* i : Ambisonic (SBA) order */
- int16_t nb_channels, /* i : Number of Ambisonic (SBA) channels */
- int16_t *nchan_transport, /* o : number of transport channels */
- const int16_t sba_planar, /* i : SBA planar flag */
- int16_t *nSCE, /* o : number of SCEs */
- int16_t *nCPE, /* o : number of CPEs */
- int16_t *element_mode /* o : element mode of the core coder */
-);
-
-void ivas_sba_set_cna_cng_flag(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_sba_dec_reconfigure(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- uint16_t *nSamplesFlushed, /* o : number of samples flushed */
- int16_t *data /* o : output synthesis signal */
-);
-
-ivas_error ivas_sba_digest_tc(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t nchan_transport, /* i : number of transport channels */
- const int16_t nCldfbSlots, /* i : number of CLDFB slots */
- const int16_t nSamplesForRendering, /* i : number of samples provided */
- float *data[] /* i : transport channel samples */
-);
-
-
-
-/*! r: Ambisonic (SBA) order */
-int16_t ivas_sba_get_order(
- const int16_t nb_channels, /* i : Number of ambisonic channels */
- const int16_t sba_planar /* i : SBA planar flag */
-);
-
-/*! r: number of Ambisonic channels */
-int16_t ivas_sba_get_nchan(
- const int16_t sba_order, /* i : Ambisonic (SBA) order */
- const int16_t sba_planar /* i : SBA planar flag */
-);
-
-/*! r: number of ambisonics metadata channels */
-
-void ivas_sba_getTCs(
- float *sba_data[], /* i : SBA signals */
- Encoder_Struct *st_ivas, /* i/o: Encoder struct */
- const int16_t input_frame /* i : frame length */
-);
-
-int16_t ivas_sba_remapTCs(
- float *sba_data[], /* i/o: SBA signals */
- Decoder_Struct *st_ivas, /* i/o: decoder struct */
- const int16_t output_frame /* i : frame length */
-);
-
-void ivas_sba_dirac_stereo_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output[CPE_CHANNELS], /* o : output synthesis signal */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t mcmasa /* i : McMASA flag */
-);
-
-void ivas_sba_dirac_stereo_config(
- STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */
-);
-
-
-Word16 ivas_get_sba_dirac_stereo_flag(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_sba_dirac_stereo_smooth_parameters(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */
- const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */
- const int32_t output_Fs, /* i : Fs for delay calculation */
- const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * DirAC prototypes
- *----------------------------------------------------------------------------------*/
-
-
-ivas_error ivas_dirac_enc_reconfigure(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
-);
-
-
-
-ivas_error ivas_dirac_config(
- void *st_ivas, /* i/o: IVAS encoder/decoder state structure */
- const int16_t enc_dec /* i : encoder or decoder flag */
-);
-
-void ivas_dirac_config_bands(
- int16_t *band_grouping, /* o : band grouping */
- const int16_t nbands, /* i : number of bands */
- const int16_t max_band, /* i : maximal band index +1 */
- int16_t *dirac_to_spar_md_bands, /* o : mapping of DirAC parameter band index to SPAR FB band index */
- const int8_t useLowerBandRes, /* i : flag indicating lower band resolution for DirAC */
- const int16_t enc_param_start_band, /* i : band index of first DirAC parameter band */
- IVAS_FB_MIXER_HANDLE hFbMdft
-);
-
-void ivas_get_dirac_sba_max_md_bits(
- const int32_t sba_total_brate,
- int16_t *bits_frame_nominal,
- int16_t *metadata_max_bits,
- int16_t *qmetadata_max_bit_req,
- const int16_t nbands
- ,
- IVAS_FORMAT ivas_format
-);
-
-ivas_error ivas_dirac_sba_config(
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- int16_t *element_mode, /* o : element mode of the core coder */
- int32_t sba_total_brate, /* i : SBA total bitrate */
- const int16_t sba_order, /* i : Ambisonic (SBA) order */
- const int16_t nbands /* i : number of frequency bands */
- ,
- IVAS_FORMAT ivas_format
-);
-
-ivas_error ivas_dirac_dec_config(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */
-);
-
-void ivas_dirac_dec_close(
- DIRAC_DEC_HANDLE *hDirAC_out
-);
-
-void ivas_dirac_dec_read_BS(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- Decoder_State *st, /* i/o: decoder Core state structure */
- DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */
- SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */
- int16_t *nb_bits, /* o : number of bits read */
- const int16_t last_bit_pos, /* i : last read bitstream position */
- const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */
- int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
-);
-
-void generate_masking_noise_lb_dirac(
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */
- const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */
- const int16_t cna_flag /* i : CNA flag for LB and HB */
-);
-
-
-void ivas_dirac_dec_render(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t nchan_transport, /* i : number of transport channels */
- const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
- uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
- uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- float *output_f[] /* o : rendered time signal */
-);
-
-void ivas_dirac_dec_render_sf(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t nchan_transport, /* i : number of transport channels */
- float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX],
- float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX]
-);
-
-
-void computeDirectionVectors(
- float *intensity_real_x,
- float *intensity_real_y,
- float *intensity_real_z,
- const int16_t enc_param_start_band,
- const int16_t num_frequency_bands,
- float *direction_vector_x,
- float *direction_vector_y,
- float *direction_vector_z
-);
-
-void computeDiffuseness(
- float *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF],
- const float *buffer_energy,
- const int16_t num_freq_bands,
- float *diffuseness
-);
-
-void ivas_dirac_dec_get_response(
- const int16_t azimuth,
- const int16_t elevation,
- float *response,
- const int16_t ambisonics_order
-);
-
-
-
-ivas_error ivas_mc_paramupmix_enc_open_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
-);
-
-void ivas_mc_paramupmix_enc_close_fx(
- MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
- const int32_t input_Fs /* i : input sampling rate */
-);
-
-ivas_error ivas_mc_paramupmix_dec_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_mc_paramupmix_dec_close(
- MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */
-);
-
-void ivas_mc_paramupmix_dec_read_BS(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- Decoder_State *st, /* i/o: decoder state structure */
- MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */
- int16_t *nb_bits /* o : number of bits written */
-);
-
-void ivas_mc_paramupmix_dec_digest_tc(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */
- const int16_t nSamplesForRendering /* i : number of samples provided */
-);
-
-void ivas_param_mc_set_coded_bands_fx(
- HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */
-);
-
-/*! r: number of IVAS transport channels */
-
-ivas_error ivas_param_mc_enc_open(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
-);
-
-ivas_error ivas_param_mc_enc_reconfig(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
-);
-
-void ivas_param_mc_enc_close(
- PARAM_MC_ENC_HANDLE *hParamMC, /* i/o: Parametric MC encoder handle */
- const int32_t input_Fs /* i : input sampling rate */
-);
-
-void ivas_param_mc_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */
- BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */
- float *data_f[], /* i/o: input/transport MC data */
- const int16_t input_frame /* i : input frame length */
-);
-
-ivas_error ivas_param_mc_dec_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_param_mc_dec_reconfig(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-
-
-void ivas_param_mc_dec_digest_tc(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */
- float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/
-);
-
-void ivas_param_mc_dec_render(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
- uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
- uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- float *output_f[] /* o : rendered time signal */
-);
-
-void ivas_param_mc_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */
-);
-
-/*! r: number of cldfb synthesis instances */
-int16_t param_mc_get_num_cldfb_syntheses(
- Decoder_Struct *st_ivas /* i : IVAS decoder structure */
-);
-
-UWord16 ivas_param_mc_get_configuration_index_fx(
- const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */
- const Word32 ivas_total_brate /* i : IVAS total bitrate */
-);
-
-ivas_error ivas_dirac_dec_output_synthesis_cov_open(
- DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */
- DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */
- const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */
- const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */
- const int16_t num_param_bands, /* i : number of parameter bands */
- const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */
- const int16_t nchan_in, /* i : number of input (transport) channels */
- const int16_t nchan_out, /* i : number of output channels */
- const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */
-);
-
-void ivas_dirac_dec_output_synthesis_get_interpolator(
- DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */
- const uint16_t interp_length /* i : interpolator length */
-);
-
-void ivas_dirac_dec_output_synthesis_cov_init(
- DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */
- const int16_t nchan_in, /* i : number of input (tranport) channels */
- const int16_t nchan_out, /* i : number of output channels */
- const int16_t n_param_bands, /* i : number of total parameter bands */
- const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */
-);
-
-void ivas_dirac_dec_output_synthesis_cov_close(
- DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */
- DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */
-);
-
-
-void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot(
- float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */
- float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */
- float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */
- float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */
- float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */
- float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */
- const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */
- const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */
- const int16_t nX, /* i : number of input channels */
- const int16_t nY, /* i : number of output channels */
- PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */
-);
-
-
-void FdCngEncodeDiracMDCTStereoSID(
- CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */
-);
-
-void FdCngDecodeDiracMDCTStereoSID(
- CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * SPAR prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_spar_enc_open(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */
- const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
-);
-
-ivas_error ivas_spar_enc(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- float *data_f[], /* i/o: input/transport audio channels */
- const int16_t input_frame, /* i : input frame length */
- int16_t *nb_bits_metadata, /* i : number of MD bits written */
- BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */
-);
-
-ivas_error ivas_spar_dec_open(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
-);
-
-
-ivas_error ivas_spar_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
- int16_t *nb_bits_read /* o : number of MD bits read */
-);
-
-void ivas_spar_config(
- int32_t ivas_total_brate, /* i : codec total bitrate */
- const int16_t sba_order, /* i : Ambisonic (SBA) order */
- int16_t *nchan_transport, /* o : number of transport channels */
- int16_t *nSCE, /* o : number of SCEs */
- int16_t *nCPE, /* o : number of CPEs */
- int32_t *core_nominal_brate, /* o : core-coding nominal bitrate */
- const int16_t sid_format /* i : IVAS format indicator from SID frame */
-);
-
-ivas_error ivas_sba_linear_renderer(
- float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nchan_in, /* i : number of input ambisonics channels */
- const int16_t nchan_ism, /* i : number of objects */
- const AUDIO_CONFIG output_config, /* i : output audio configuration */
- const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */
-);
-
-void ivas_sba_mix_matrix_determiner(
- SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
- float *output[], /* i/o: transport/output audio channels */
- const int16_t bfi, /* i : BFI flag */
- const int16_t nchan_remapped, /* i : num channels after remapping of TCs */
- const int16_t output_frame, /* i : output frame length */
- const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */
-);
-
-/* AGC */
-/*! r: AGC enable flag */
-
-ivas_error ivas_spar_agc_enc_open(
- ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */
- const int32_t input_Fs, /* i : input sampling rate */
- const int16_t nchan_inp /* i : number of input channels */
-);
-
-void ivas_spar_agc_enc_close(
- ivas_agc_enc_state_t **hAgcEnc /* i/o: AGC encoder handle */
-);
-
-void ivas_agc_enc_process(
- ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */
- BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */
- float **ppPcm_in, /* i : input audio channels */
- float **ppPcm_out, /* o : output audio channels */
- const int16_t n_channels, /* i : number of channels */
- const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */
-);
-
-ivas_error ivas_spar_agc_dec_open(
- ivas_agc_dec_state_t **hAgcDec, /* i/o: AGC decoder handle */
- const int32_t output_Fs /* i : output sampling rate */
-);
-
-void ivas_spar_agc_dec_close(
- ivas_agc_dec_state_t **hAgcDec /* i/o: AGC decoder handle */
-);
-
-
-void ivas_agc_dec_process(
- ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */
- float *pcm_in[], /* i : input audio channels */
- float *pcm_out[], /* o : output audio channels */
- const int16_t n_channels, /* i : number of channels */
- const int16_t output_Fs /* i : output sampling rate */
-);
-
-void ivas_agc_read_bits(
- ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */
- Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/
- const int16_t n_channels, /* i : number of channels */
- const int16_t AGC_flag /* i : AGC on/off flag */
-);
-
-void ivas_agc_initWindowFunc(
- float *pWinFunc,
- const int16_t length
-);
-
-void ivas_agc_calcGainParams(
- uint16_t *absEmin,
- uint16_t *betaE,
- uint16_t *maxAttExp,
- const int16_t numCoeffs
-);
-
-float ivas_get_mdct_scaling_gain(
- const int16_t dct_len_by_2
-);
-
-void ivas_get_twid_factors(
- const int16_t length,
- const float **pTwid_re,
- const float **pTwid_im
-);
-
-int16_t ivas_get_bw_idx_from_sample_rate(
- const int32_t sampling_rate /* i : sampling rate */
-);
-
-/*! r: config. table index */
-int16_t ivas_get_spar_table_idx(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t sba_order, /* i : IVAS SBA order */
- const int16_t bwidth, /* i : audio bandwidth */
- int16_t *bitlen, /* o : number of bits */
- int16_t *ind /* o : indice */
-);
-
-/*! r: number of transport channels */
-int16_t ivas_get_sba_num_TCs(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t sba_order /* i : IVAS SBA order */
-);
-
-
-void ivas_spar_bitrate_dist(
- int32_t core_brates_act[], /* o : bitrates per core-coder */
- const int16_t nAvailBits, /* i : number of available bits */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t sba_order, /* i : Ambisonic (SBA) order */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void ivas_mdct(
- const float *pIn,
- float *pOut,
- const int16_t length
-);
-
-void ivas_dct_windowing(
- const int16_t fade_len,
- const int16_t full_len,
- const int16_t dct_len,
- const int16_t zero_pad_len,
- const float *pWindow_coeffs,
- const int16_t frame_len,
- float *pOut_buf,
- float *pBuffer_prev,
- float *pTemp_lfe
-);
-
-void ivas_tda(
- const float *pIn,
- float *pOut,
- const int16_t length
-);
-
-void ivas_imdct(
- const float *pIn,
- float *pOut,
- const int16_t length
-);
-
-void ivas_itda(
- const float *re,
- float *pOut,
- const int16_t length
-);
-
-void ivas_spar_get_cldfb_gains(
- SPAR_DEC_HANDLE hSpar,
- HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0,
- HANDLE_CLDFB_FILTER_BANK cldfbSynDec0,
- const DECODER_CONFIG_HANDLE hDecoderConfig
-);
-
-/*! r: 1 if prediction residual channel */
-
-void ivas_spar_dec_agc_pca(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- float *output[], /* i/o: input/output audio channels */
- const Word16 output_frame /* i : output frame length */
-);
-
-void ivas_spar_dec_set_render_map(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int16_t nCldfbTs /* i : number of CLDFB time slots */
-);
-
-void ivas_spar_dec_set_render_params(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */
-);
-
-void ivas_spar_dec_digest_tc(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t nchan_transport, /* i : number of transport channels */
- const int16_t nCldfbSlots, /* i : number of CLDFB slots */
- const int16_t nSamplesForRendering /* i : number of samples provided */
-);
-
-void ivas_sba_dec_digest_tc(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t nCldfbSlots, /* i : number of CLDFB slots */
- const int16_t nSamplesForRendering /* i : number of samples provided */
-);
-
-ivas_error ivas_sba_dec_render(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
- uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
- uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- float *output_f[] /* o : rendered time signal */
-);
-
-void ivas_spar_dec_upmixer_sf(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- float *output[], /* o : output audio channels */
- const int16_t nchan_internal /* i : number of internal channels */
-);
-
-void ivas_spar_dec_upmixer(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- float *output[], /* i/o: input/output audio channels */
- const int16_t nchan_internal, /* i : number of internal channels */
- const int16_t output_frame /* i : output frame length */
-);
-
-/* MD module */
-
-void ivas_spar_md_enc_close(
- ivas_spar_md_enc_state_t **hMdEnc /* i/o: SPAR MD encoder handle */
-);
-
-void ivas_compute_spar_params(
- float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
- float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
- const int16_t i_ts,
- float ***mixer_mat,
- const int16_t start_band,
- const int16_t end_band,
- const int16_t dtx_vad,
- const int16_t num_ch,
- const int16_t bands_bw,
- const int16_t active_w,
- const int16_t active_w_vlbr,
- ivas_spar_md_com_cfg *hSparCfg,
- ivas_spar_md_t *hSparMd,
- float *pWscale,
- const int16_t from_dirac,
- const int16_t dyn_active_w_flag
-);
-
-void ivas_create_fullr_dmx_mat(
- float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
- float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
- float ***mixer_mat,
- const int16_t in_chans,
- const int16_t start_band,
- const int16_t end_band,
- const int16_t active_w,
- ivas_spar_md_com_cfg *hMdCfg
-);
-
-void ivas_calc_c_p_coeffs(
- ivas_spar_md_t *pSparMd,
- float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
- const int16_t i_ts,
- float ***mixer_mat,
- const int16_t num_ch,
- const int16_t num_dmx,
- const int16_t band_idx,
- const int16_t dtx_vad,
- const int16_t compute_p_flag,
- const int16_t dyn_active_w_flag
-);
-
-void ivas_get_spar_md_from_dirac(
- float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
- float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
- float diffuseness[IVAS_MAX_NUM_BANDS],
- const int16_t n_ts,
- float ***mixer_mat,
- ivas_spar_md_t *hSpar_md,
- ivas_spar_md_com_cfg *hSpar_md_cfg,
- const int16_t start_band,
- const int16_t end_band,
- const int16_t order,
- const int16_t dtx_vad,
- float Wscale_d[IVAS_MAX_NUM_BANDS],
- const uint8_t useLowerRes,
- const int16_t active_w_vlbr,
- const int16_t dyn_active_w_flag
-);
-
-/*! r: number of MD subframes */
-
-ivas_error ivas_spar_md_dec_matrix_open(
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t num_md_sub_frames
-);
-
-void ivas_spar_md_dec_matrix_close(
- ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */
- const int16_t num_channels /* i : number of internal channels */
-);
-
-ivas_error ivas_spar_md_dec_open(
- ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */
- const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t sba_order, /* i : SBA order */
- const int16_t sid_format, /* i : SID format */
- const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */
-);
-
-void ivas_spar_md_dec_close(
- ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */
-);
-
-void ivas_spar_get_parameters(
- SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
- const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t ts, /* i : time slot index */
- const int16_t num_ch_out, /* i : number of channels out */
- const int16_t num_ch_in, /* i : number of channels in */
- const int16_t num_spar_bands, /* i : number of SPAR bands */
- float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /* o : mixing matrix */
-);
-
-ivas_error ivas_spar_md_dec_init(
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t sba_order /* i : SBA order */
-);
-
-void ivas_spar_md_dec_process(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t sba_order /* i : SBA order */
-);
-
-void ivas_spar_to_dirac(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t dtx_vad, /* i : DTX frame flag */
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t bw, /* i : band joining factor */
- const int16_t dyn_active_w_flag /* i : dynamic active W flag */
-);
-
-void ivas_spar_update_md_hist(
- ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */
-);
-
-int16_t ivas_spar_chk_zero_coefs(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
-);
-
-void ivas_spar_smooth_md_dtx(
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t num_md_sub_frames /* i : number of metadata subframes */
-);
-
-void ivas_spar_setup_md_smoothing(
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t num_md_sub_frames /* i : number of metadata subframes */
-);
-
-void ivas_spar_dec_gen_umx_mat(
- ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t nchan_transport, /* i : number of transport channels */
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t bfi, /* i : bad frame indicator */
- const int16_t num_md_sub_frames
-);
-
-
-
-
-
-/* Transient detector module */
-ivas_error ivas_transient_det_open_fx(
- ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */
- const Word32 sampling_rate /* i : sampling rate */
-);
-
-void ivas_transient_det_close_fx(
- ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */
-);
-
-void ivas_transient_det_process(
- ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */
- float *pIn_pcm, /* i : input audio channels */
- const int16_t frame_len, /* i : frame length in samples */
- int16_t transient_det[2] /* o : transient det outputs */
-);
-
-void ivas_td_decorr_get_ducking_gains(
- ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */
- float *pIn_pcm,
- float *pIn_duck_gains,
- float *pOut_duck_gains,
- const int16_t frame_len,
- const int16_t tdet_flag
-);
-
-#define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \
- out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); MAC(1); MULT(1); \
- out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); MAC(1); MULT(1);
-
-#define IVAS_CALCULATE_ABS( re, im, out ) \
- out = sqrtf( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); SQRT(1);
-
-#define IVAS_CALCULATE_RABS( re, out ) \
- out = sqrtf( re * re ); MULT(1); SQRT(1);
-
-#define IVAS_CALCULATE_SQ_ABS( re, im, out ) \
- out = (float) ( ( re * re ) + ( im * im ) ); MAC(1); MULT(1);
-
-#define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \
- out1_re = ( in1_re * in2_re ); DMULT(1); \
-
-#define IVAS_CALCULATE_SQ_ABS_N( re, out ) \
- out = (float) ( re * re ); MULT(1);
-
-#define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \
- out1_re = ( in1_re * in2_re ); MULT(1);
-
-
-/* PCA */
-void ivas_pca_enc_init(
- PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */
-);
-
-void ivas_pca_read_bits(
- Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/
- PCA_DEC_STATE *hPCA /* i/o: PCA encoder structure */
-);
-
-void ivas_pca_dec_init(
- PCA_DEC_STATE *hPCA /* i/o: PCA decoder structure */
-);
-
-void ivas_pca_dec(
- PCA_DEC_STATE *hPCA, /* i/o: PCA decoder structure */
- const int16_t n_samples, /* i : output frame length */
- const int16_t n_channels, /* i : number of channels */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */
- const int16_t bfi, /* i : bad frame indicator */
- float *pcm_out[] /* o : output audio channels */
-);
-
-void pca_dec_s3(
- const int32_t index,
- float *q
-);
-
-
-void ivas_huffman_encode_fx(
- ivas_huffman_cfg_t *huff_cfg,
- Word16 in,
- Word16 *hcode,
- Word16 *hlen
-);
-
-
-
-ivas_error ivas_huffman_decode(
- ivas_huffman_cfg_t *huff_cfg,
- Decoder_State *st0,
- int16_t *dec_out
-);
-
-void ivas_arith_decode_cmplx_cell_array(
- ivas_arith_t *pArith_re,
- ivas_arith_t *pArith_re_diff,
- Decoder_State *st0,
- ivas_cell_dim_t *pCell_dims,
- int16_t *pDo_diff, const int16_t nB,
- int16_t *pSymbol_re,
- int16_t *pSymbol_re_old
-);
-
-
-
-
-void ivas_ari_done_encoding_14bits(
- BSTR_ENC_HANDLE hBstr, Tastat *s
-);
-
-
-void ivas_wrap_arround(
- int16_t *pArr,
- const int16_t min_val,
- const int16_t max_val,
- const int16_t length
-);
-
-void ivas_get_cum_freq_model(
- const int16_t *pFreq_model,
- const int16_t length,
- int16_t *pCum_freq_model
-);
-
-int16_t ivas_map_num_pred_r_to_idx(
- const int16_t num_quant_points_pred_r,
- const int16_t active_w_flag
-);
-
-int16_t ivas_map_num_drct_r_to_idx(
- const int16_t num_quant_points_drct_r
-);
-
-int16_t ivas_map_num_decd_r_to_idx(
- const int16_t num_quant_points_decd_r
-);
-
-/* Quantization utilities */
-void ivas_quantise_real_values(
- const float *values,
- const int16_t q_levels,
- const float min_value,
- const float max_value,
- int16_t *index,
- float *quant,
- const int16_t dim
-);
-
-
-void ivas_spar_quant_dtx_init(
- ivas_spar_md_t *spar_md,
- float *min_max
-);
-
-void ivas_map_prior_coeffs_quant(
- ivas_spar_md_prev_t *pSpar_md_prior,
- ivas_spar_md_com_cfg *pSpar_md_cfg,
- const int16_t qsi,
- const int16_t nB
-);
-
-
-void ivas_clear_band_coeffs(
- ivas_band_coeffs_t *pband_coeffs,
- const uint16_t num_bands
-);
-
-void ivas_clear_band_coeff_idx(
- ivas_band_coeffs_ind_t *pband_coeff_idx,
- const uint16_t num_bands
-);
-
-
-/*----------------------------------------------------------------------------------*
- * MASA prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_masa_decode(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t *nb_bits_read /* o : number of bits read */
-);
-
-void generate_gridEq(
- SPHERICAL_GRID_DATA *data /* o : data structure for grid */
-);
-
-ivas_error ivas_masa_enc_open_fx(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
-);
-
-void ivas_masa_enc_close_fx(
- MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */
-);
-
-void ivas_masa_enc_reconfigure(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-ivas_error ivas_masa_dec_reconfigure(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */
- int16_t *data /* o : output synthesis signal */
-);
-
-ivas_error ivas_masa_encode(
- MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
- int16_t *nb_bits_metadata, /* o : number of metadata bits written */
- const int16_t nchan_transport, /* i : number of MASA input/transport channels */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t Opt_DTX_ON, /* i : DTX on flag */
- const int16_t element_mode, /* i : element mode */
- const ISM_MODE ism_mode, /* i : ISM format mode */
- const int16_t nchan_ism, /* i : number of ISM channels */
- ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata handle */
- const int16_t idx_separated_object, /* i : index of the separated object */
- OMASA_ENC_HANDLE hOMasa, /* i : OMASA encoder handle */
- const int16_t ism_imp, /* i : importance of separated object */
- const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */
-);
-
-void ivas_masa_estimate_energy(
- MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */
- float *data_f[], /* i : Input audio channels */
- const int16_t input_frame, /* i : frame length */
- const int16_t nchan_transport /* i : number of MASA input/transport channels */
-);
-
-
-void ivas_masa_set_elements(
- const int32_t ivas_total_brate, /* i : codec total bitrate */
- const int16_t mc_mode, /* i : MC format mode */
- const int16_t nchan_transport, /* i : number of MASA input/transport channels */
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- int16_t *element_mode, /* o : element mode */
- int16_t *nSCE, /* o : number of SCEs */
- int16_t *nCPE, /* o : number of CPEs */
- const int16_t ivas_format, /* i : IVAS format */
- const ISM_MODE ism_mode, /* i : ISM mode */
- const int32_t ism_total_brate /* i : initial ISM total bitrate */
-);
-
-/*! r: valid or not 1/0 */
-int16_t valid_ratio_index(
- int16_t index, /* i : index to be checked */
- const int16_t K, /* i : L1 norm to check against */
- const int16_t len /* i : vector length */
-);
-
-void reconstruct_ism_ratios(
- int16_t *ratio_ism_idx,
- const int16_t nchan_ism,
- const float step,
- float *q_energy_ratio_ism
-);
-
-void distribute_evenly_ism(
- int16_t *idx,
- const int16_t K,
- const int16_t nchan_ism
-);
-
-
-int16_t ivas_qmetadata_encode_extended_gr_length_fx(
- const uint16_t value,
- const uint16_t alphabet_size,
- const int16_t gr_param);
-
-void ivas_qmetadata_encode_extended_gr_fx(
- BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */
- const uint16_t value, /* i : value to be encoded */
- const uint16_t alphabet_size, /* i : alphabet size */
- const int16_t gr_param); /* i : GR order */
-
-/*! r: CPE bitrate value */
-int32_t calculate_cpe_brate_MASA_ISM(
- const ISM_MODE ism_mode, /* i : ism mode */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t nchan_ism /* i : number of objects */
-);
-
-void ivas_merge_masa_metadata(
- MASA_ENCODER_HANDLE hMasa, /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */
- OMASA_SPATIAL_META_HANDLE hOMasaMeta /* i : ISM-object metadata to be merged with the MASA metadata */
-);
-
-
-/*!r : number of bits for ISM ratio index */
-int16_t bits_index_ism_ratio(
- const int16_t nchan_ism /* i : number of objects */
-);
-
-void calculate_nbits_meta(
- const int16_t nchan_ism,
- float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS],
- float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],
- const int16_t numSf,
- const int16_t numCodingBands,
- int16_t* bits_ism,
- const int16_t idx_sep_obj,
- const int16_t ism_imp
-);
-
-/*! r: limitation flag */
-int16_t calculate_brate_limit_flag(
- const int16_t ism_imp[], /* i : ISM importance flags */
- const int16_t nchan_ism /* i : number of objects */
-);
-
-void ivas_masa_set_coding_config(
- MASA_CODEC_CONFIG* config, /* i/o: MASA coding config structure */
- int16_t* band_mapping, /* o : Band mapping used */
- const int32_t ivas_total_brate, /* i : codec total bitrate */
- const int16_t nchan_transport, /* i : number of transport channel (mono/stereo) */
- const uint8_t isMcMasa /* i : toggle for selecting McMASA specific config */
-);
-
-/*! r: Surround coherence significant flag */
-uint8_t ivas_masa_surrcoh_signicant(
- float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Surround coherence */
- float diffuse_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Diffuse to total ratio */
- const int16_t nSubFrames, /* i : Number of sub frames */
- const int16_t nBands /* i : Number of frequency bands */
-);
-
-void masa_compensate_two_dir_energy_ratio_index(
- const int16_t ratio_index_1, /* i : Input ratio for direction 1 */
- const int16_t ratio_index_2, /* i : Input ratio for direction 2 */
- int16_t *ratio_index_mod1, /* o : Output modified ratio for direction 1 */
- int16_t *ratio_index_mod2, /* o : Output modified ratio for direction 2 */
- const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */
-);
-
-void ivas_set_qmetadata_maxbit_req_fx(
- IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */
- const IVAS_FORMAT ivas_format /* i : IVAS format */
-);
-
-void masa_sample_rate_band_correction(
- MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */
- int16_t *band_mapping, /* i/o: Band mapping used and modified */
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */
- const uint8_t maxBand, /* i : max band */
- uint8_t is_encoder, /* i : signals if called at encoder */
- MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */
-);
-
-void invdct4_transform(
- float *v, /* i : input vector */
- uint8_t *invdct_v /* o : transformed vector */
-);
-
-
-void ivas_spar_param_to_masa_param_mapping(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
- float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */
- float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */
- const int16_t subframe /* i : Subframe to map */
-);
-
-/*---------------------------------------------------------------------------------*
- * Binaural FastConv Renderer Prototypes
-*-----------------------------------------------------------------------------------*/
-
-
-void ivas_binaural_hrtf_close(
- HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */
-);
-
-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 */
- 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 */
- float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */
-);
-
-void ivas_binaural_add_LFE(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- int16_t output_frame, /* i : length of input frame */
- float *input_f[], /* i : transport channels */
- float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */
-);
-
-/*----------------------------------------------------------------------------------*
- * renderer prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_ism_renderer_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_ism_renderer_close(
- ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */
-);
-
-void ivas_ism_render_sf(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output_f[], /* i/o: core-coder transport channels/object output */
- const int16_t n_samples_to_render /* i : output frame length per channel */
-);
-
-
-void ivas_mc2sba(
- IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */
- float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */
- float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t sba_order, /* i : SBA order */
- const float gain_lfe /* i : gain for LFE, 0=ignore LFE */
-);
-
-void ivas_param_mc_mc2sba_cldfb(
- IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */
- float *hoa_encoder, /* i : HOA3 encoder for the transported MC format */
- const int16_t slot_idx, /* i : current slot in the subframe */
- float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */
- float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */
- const int16_t nBands, /* i : number of synth CLDFB bands */
- const float gain_lfe /* i : gain applied to LFE */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Amplitude Panning VBAP prototypes
- *----------------------------------------------------------------------------------*/
-
-void panning_wrap_angles(
- const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
- const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
- float *azi_wrapped, /* o : wrapped azimuth component */
- float *ele_wrapped /* o : wrapped elevation component */
-);
-
-/*----------------------------------------------------------------------------------*
- * LS Renderer prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_ls_setup_conversion_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_ls_setup_conversion_close(
- LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */
-);
-
-
-void ivas_ls_setup_conversion(
- Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
- const int16_t input_chans, /* i : number of input channels to the renderer */
- const int16_t output_frame, /* i : frame length */
- float *input[], /* i : LS input/output synthesis signal */
- float *output[] /* i/o: LS input/output synthesis signal */
-);
-
-void ivas_ls_setup_conversion_process_mdct(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output[] /* i/o: output synthesis signal */
-);
-
-void ivas_ls_setup_conversion_process_mdct_param_mc(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *x[][NB_DIV] /* i/o: output synthesis signal */
-);
-
-void ivas_lssetupconversion_process_param_mc(
- Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */
- const int16_t num_timeslots, /* i : number of time slots to process */
- float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */
- float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */
- int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Custom loudspeaker setup prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_ls_custom_open(
- LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */
-);
-
-
-
-/*----------------------------------------------------------------------------------*
- * McMASA prototypes
- *----------------------------------------------------------------------------------*/
-
-
-ivas_error ivas_mcmasa_dec_reconfig(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
-);
-
-void ivas_mcmasa_setNumTransportChannels(
- int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */
- int16_t* element_mode, /* o : Pointer to element mode to be set */
- const int32_t ivas_total_brate /* i : Total bitrate of IVAS */
-);
-
-void ivas_mcmasa_set_separate_channel_mode(
- uint8_t *separateChannelEnabled, /* o : Pointer to separate channel toggle */
- int16_t *separateChannelIndex, /* o : Pointer to separate channel index */
- const int32_t ivas_total_brate /* i : Total bitrate of IVAS */
-);
-
-void ivas_mcmasa_split_brate(
- const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */
- const int32_t ivas_total_brate, /* i : Total bitrate available to be split */
- const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */
- const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */
- int32_t *brate_sce, /* o : Pointer to SCE element bitrate */
- int32_t *brate_cpe /* o : Pointer to CPE element bitrate */
-);
-
-
-void ivas_mcmasa_dmx_modify_fx(
- const Word16 n_samples, /* i : input frame length in samples */
- Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/
- Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/
- const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */
- const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/
-);
-
-ivas_error ivas_mono_dmx_renderer_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-
-void ivas_mono_dmx_renderer_close(
- MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */
-);
-
-void ivas_mono_downmix_render_passive(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */
- const int16_t output_frame /* i : output frame length */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * LFE encoder low pass filter prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_create_lfe_lpf_enc(
- ivas_filters_process_state_t **hLfeLpf, /* o : LFE LPF handle */
- const int32_t input_Fs /* i : input sampling rate */
-);
-
-void ivas_lfe_lpf_enc_close_fx(
- ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */
-);
-
-void ivas_lfe_lpf_enc_apply(
- ivas_filters_process_state_t *hLfeLpf, /* i/o: LFE LPF handle */
- float data_lfe_ch[], /* i/o: LFE signal */
- const int16_t input_frame /* i : input frame length per channel */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * LFE Coding prototypes
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_create_lfe_enc_fx(
- LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */
- const int32_t input_Fs /* i : input sampling rate */
-);
-
-void ivas_lfe_enc_close_fx(
- LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */
-);
-
-void ivas_lfe_enc(
- LFE_ENC_HANDLE hLFE, /* i/o: LFE encoder handle */
- float data_lfe_ch[], /* i : input LFE signal */
- const int16_t input_frame, /* i : input frame length per channel */
- BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
-);
-
-void ivas_lfe_tdplc(
- LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */
- float *prevsynth, /* i : previous frame synthesis */
- float *ytda, /* o : output time-domain buffer */
- const int16_t output_frame /* i : output frame length */
-);
-void ivas_lfe_window_init(
- LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */
- const int32_t sampling_rate, /* i : sampling rate */
- const int16_t frame_len /* i : frame length in samples */
-);
-
-void ivas_lfe_lpf_select_filt_coeff(
- const int32_t sampling_rate, /* i : sampling rate */
- const int16_t order, /* i : filter order */
- const float **ppFilt_coeff /* o : filter coefficients */
-);
-
-void ivas_filters_init(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- const float *filt_coeff, /* i : filter coefficients */
- const int16_t order /* i : filter order */
-);
-
-void ivas_filters_init_fx(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */
- const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */
- const Word16 order ) ;
-
-void ivas_filter_process(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- float *pIn_Out, /* i : signal subject to filtering */
- const int16_t length /* i : filter order */
-);
-
-void ivas_filter_process_fx(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */
- const Word16 length, /* i : filter order */
- Word16 q_factor );
-
-/*----------------------------------------------------------------------------------*
- * OSBA prototypes
- *----------------------------------------------------------------------------------*/
-ivas_error ivas_osba_enc_reconfig(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-ivas_error ivas_osba_data_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
-);
-
-ivas_error ivas_osba_dirac_td_binaural_jbm(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
- uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
- uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- float *output_f[] /* o : rendered time signal */
-);
-
-
-void ivas_osba_data_close(
- SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */
-);
-
-
-/*----------------------------------------------------------------------------------*
-* OMASA prototypes
-*---------------------------------------------------------------------------------*/
-
-ivas_error ivas_omasa_enc_open(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
-);
-
-void ivas_omasa_enc_close(
- OMASA_ENC_HANDLE *hOMasa /* i/o: encoder OMASA handle */
-);
-
-
-ivas_error ivas_omasa_dec_config(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */
- int16_t *data /* o : output synthesis signal */
-);
-
-
-
-
-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(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- int32_t *ism_total_brate /* i : ISM total bitrate */
-);
-
-
-void ivas_set_ism_importance_interformat(
- const int32_t ism_total_brate, /* i/o: ISms total bitrate */
- const int16_t nchan_transport, /* i : number of transported channels */
- ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */
- const float lp_noise_CPE, /* i : LP filtered total noise estimation */
- int16_t ism_imp[] /* o : ISM importance flags */
-);
-
-
-/*! r: adjusted bitrate */
-int32_t ivas_interformat_brate(
- const ISM_MODE ism_mode, /* i : ISM mode */
- const int16_t nchan_ism, /* i : number of ISM channels */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t ism_imp, /* i : ISM importance flag */
- const int16_t limit_flag /* i : flag to limit the bitrate increase */
-);
-
-void ivas_combined_format_brate_sanity(
- const int32_t element_brate, /* i : element bitrate */
- const int16_t core, /* i : core */
- const int32_t total_brate, /* i : total bitrate */
- int32_t *core_brate, /* i/o: core bitrate */
- int16_t *inactive_coder_type_flag, /* o : inactive coder_type flag */
- int16_t *diff_nBits /* o : number of differential bits */
-);
-
-ISM_MODE ivas_omasa_ism_mode_select(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t nchan_ism /* i : number of input ISM's */
-);
-
-void ivas_set_omasa_TC(
- const ISM_MODE ism_mode, /* i : ISM mode */
- const int16_t nchan_ism, /* i : number of input ISMs */
- int16_t *nSCE, /* o : number of SCEs */
- int16_t *nCPE /* o : number of CPEs */
-);
-
-void ivas_merge_masa_transports(
- float data_in_f1[][L_FRAME48k], /* i : Transport audio signals 1 */
- float *data_in_f2[], /* i : Transport audio signals 2 */
- float *data_out_f[], /* o : Merged transport audio signals */
- const int16_t input_frame, /* i : Input frame size */
- const int16_t num_transport_channels /* i : Number of transport audio signals */
-);
-
-
-ivas_error ivas_omasa_ism_metadata_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const int32_t ism_total_brate, /* i : ISM total bitrate */
- int16_t *nchan_ism, /* o : number of ISM separated channels */
- int16_t *nchan_transport_ism, /* o : number of ISM TCs */
- const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */
- int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */
-);
-
-void ivas_omasa_preProcessStereoTransportsForMovedObjects(
- Decoder_Struct *st_ivas,
- float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
- float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
- const int16_t nBins,
- const int16_t subframe
-);
-
-ivas_error ivas_omasa_separate_object_renderer_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_omasa_separate_object_renderer_close(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_omasa_separate_object_render_jbm(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const uint16_t nSamplesRendered, /* i : number of samples rendered */
- float input_f[][L_FRAME48k], /* i : separated object signal */
- float *output_f[], /* o : rendered time signal */
- const int16_t subframes_rendered, /* i : number of subframes rendered */
- const int16_t slots_rendered /* i : number of CLDFB slots rendered */
-);
-
-void ivas_omasa_encode_masa_to_total(
- float masa_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],
- BSTR_ENC_HANDLE hMetaData,
- const int16_t low_bitrate_mode,
- const int16_t nbands,
- const int16_t nblocks
-);
-
-void ivas_omasa_decode_masa_to_total(
- uint16_t *bit_stream,
- int16_t *index,
- float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],
- const int16_t nbands,
- const int16_t nblocks
-);
-
-void ivas_omasa_modify_masa_energy_ratios(
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS]
-);
-
-
-/*----------------------------------------------------------------------------------*
- * TD Binaural Object renderer
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_td_binaural_renderer(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output[], /* i/o: SCE channels / Binaural synthesis */
- const int16_t output_frame /* i : output frame length */
-);
-
-ivas_error ivas_td_binaural_renderer_sf(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float *output[], /* i/o: SCE channels / Binaural synthesis */
- const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */
-);
-
-/*----------------------------------------------------------------------------------*
- * Filter-bank (FB) Mixer
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_fb_set_cfg(
- IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */
- const int16_t ivas_format, /* i : IVAS format */
- const int16_t num_in_chans, /* i : number of FB input channels */
- const int16_t num_out_chans, /* i : number of FB output channels */
- const int16_t active_w_mixing, /* i : active_w_mixing flag */
- const int32_t sampling_Fs, /* i : sampling rate */
- const int16_t nachan_dirac_ana /* i : number of DirAR analysis channels */
-);
-
-void ivas_fb_mixer_pcm_ingest(
- IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */
- float *pcm_in[], /* i : input audio channels */
- float **ppOut_pcm, /* o : output audio channels */
- const int16_t frame_length, /* i : frame length */
- const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]
-);
-
-void ivas_fb_mixer_update_prior_input(
- IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */
- float *pcm_in[], /* i : input audio channels */
- const int16_t length, /* i : length of time slot */
- const int16_t nchan_fb_in /* i : number of analysis channels */
-);
-
-void ivas_fb_mixer_get_windowed_fr(
- IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */
- float *pcm_in[], /* i : input audio channels */
- float *frame_f_real[], /* o : real freq domain values */
- float *frame_f_imag[], /* o : imag freq domain values */
- const int16_t length, /* i : number of new samples in time slot */
- const int16_t mdft_len, /* i : MDFT frame length */
- const int16_t nchan_fb_in /* i : number of analysis channels */
-);
-
-/*! r: number of spectral bands */
-
-/* clang-format on */
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index 80bdda3c2e6fd4ce43204716ae9aa789eded3be5..1bc3c6c5b5dd25c44103c58d1cfd8160a4b1626c 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -669,11 +669,6 @@ Word16 read_flag_EC_DFT(
Word16 *flag /* o : flag value */
);
-/*file : ivas_mc_param_dec_fx.c*/
-Word16 param_mc_get_num_cldfb_syntheses_ivas_fx(
- Decoder_Struct *st_ivas /* i : Parametric MC handle */
-);
-
void ivas_init_dec_get_num_cldfb_instances(
Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
Word16 *numCldfbAnalyses, /* o : number of CLDFB analysis instances */
@@ -1314,6 +1309,18 @@ Word16 matrix_diag_product_fx(
Word32 *Z, /* o : resulting matrix after the matrix multiplication */
Word16 *Z_e );
+Word16 matrix_diag_product_fx_2(
+ const Word32 *X, /* i : left hand matrix Q31 - X_e*/
+ const Word16 X_e,
+ const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/
+ const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/
+ const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/
+ const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/
+ const Word16 *Y_e,
+ const Word16 entriesY, /* i : number of entries in the diagonal Q0*/
+ Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/
+ Word16 *Z_e );
+
Word16 matrix_diag_product_fx_1(
const Word32 *X, /* i : left hand matrix */
const Word16 *X_e,
@@ -1960,6 +1967,7 @@ void ivas_DetectTonalComponents_fx(
const Word16 scaleFactors_exp[],
const Word16 scaleFactors_max_e,
const Word32 secondLastPowerSpectrum[],
+ const Word16 secondLastPowerSpectrum_e,
const Word16 nSamples,
const Word16 nSamplesCore,
Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */
@@ -2275,20 +2283,6 @@ ivas_error ivas_mct_dec_fx(
const Word16 output_frame, /* i : output frame length per channel */
const Word16 nb_bits_metadata /* i : number of metadata bits */
);
-void swb_tbe_reset_synth_ivas_fx(
- Word32 genSHBsynth_Hilbert_Mem[],
- Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[],
- Word32 genSHBsynth_state_lsyn_filt_shb_local_fx_32[] );
-
-void InitSWBdecBuffer_ivas_fx(
- Decoder_State *st_fx /* i/o: SHB decoder structure */
-);
-
-void td_bwe_dec_init_ivas_fx(
- Decoder_State *st_fx, /* i/o: SHB decoder structure */
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- const Word32 output_Fs /* i : output sampling rate */
-);
void ivas_dirac_dec_render_sf_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
@@ -2908,7 +2902,7 @@ void stereo_dft_enc_write_BS_fx(
void stereo_dft_enc_res_fx(
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */
- const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q16 */
+ const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q15 */
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
Word16 *nb_bits, /* o : number of bits written */
const Word16 max_bits );
@@ -2975,7 +2969,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas */
Word16 *pitch_fr, /* i : fraction pitch values */
Word16 *voicing_fr, /* i : fractional voicing values */
- Word16 currFlatness, /* i : flatness */
+ Word32 currFlatness, /* i : flatness */
Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
Word16 stab_fac, /* i : LP filter stability */
Word32 *res_cod_SNR_M,
@@ -3092,7 +3086,7 @@ Word16 transient_analysis_ivas_fx(
void set_transient_stereo_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE structure */
- Word16 currFlatness[] /* i/o: current flatness Q7*/
+ Word32 currFlatness[] /* i/o: current flatness Q21*/
);
void ivas_smc_mode_selection_fx(
@@ -3242,11 +3236,8 @@ void computeDirectionVectors_fixed(
Word32 *direction_vector_y, /*Q30*/
Word32 *direction_vector_z, /*Q30*/
Word16 i_e /*Exponent of all the intensity buffers*/
-#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
,
- Word16 *i_e_band
-#endif
-);
+ Word16 *i_e_band );
UWord8 ivas_masa_surrcoh_signicant_fx(
@@ -3790,8 +3781,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */
UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */
UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- Word32 *output_fx[], /* o : rendered time signal */
- Word16 out_len /*Store the length of values in each channel*/
+ Word32 *output_fx[] /* o : rendered time signal */
);
ivas_error ivas_osba_ism_metadata_dec_fx(
@@ -4706,13 +4696,12 @@ Word32 dot_product_cholesky_fx(
const Word32 *A, /* i : Cholesky matrix A */
const Word16 N /* i : vector & matrix size */
);
-Word32 dot_product_cholesky_fixed(
+
+Word64 dot_product_cholesky_fixed(
const Word32 *x, /* i : vector x */
const Word32 *A, /* i : Cholesky matrix A */
- const Word16 N, /* i : vector & matrix size */
- const Word16 exp_x,
- const Word16 exp_A,
- Word16 *exp_sum );
+ const Word16 N /* i : vector & matrix size */
+);
void v_mult_mat_fx(
Word32 *y_fx, /* o : the product x*A */
@@ -4995,6 +4984,15 @@ void ivas_dirac_dec_get_response_fx(
const Word16 ambisonics_order,
Word16 Q_out );
+#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx
+/*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/
+void ivas_dirac_dec_get_response_fx_29(
+ const Word16 azimuth,
+ const Word16 elevation,
+ Word32 *response_fx, /*Q_out=29*/
+ const Word16 ambisonics_order );
+#endif
+
void calculate_hodirac_sector_parameters_fx(
DIRAC_ENC_HANDLE hDirAC, /* i : DirAC handle */
Word32 RealBuffer_fx[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector (L+1)^2 x N_bins, real part */
@@ -5338,15 +5336,14 @@ ivas_error ivas_sba_dec_render_fx(
const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */
UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */
UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */
- Word32 *output_fx[], /* o : rendered time signal Q11*/
- Word16 out_len /*Store the length of values in each channel*/
+ Word32 *output_fx[] /* o : rendered time signal Q11*/
);
void ivas_spar_dec_upmixer_sf_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- Word32 *output_fx[], /* o : output audio channels */
- const Word16 nchan_internal, /* i : number of internal channels */
- Word16 out_len );
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
+ Word32 *output_fx[], /* o : output audio channels */
+ const Word16 nchan_internal /* i : number of internal channels */
+);
ivas_error ivas_spar_md_enc_open_fx(
ivas_spar_md_enc_state_t **hMdEnc_in, /* i/o: SPAR MD encoder handle */
@@ -5857,8 +5854,7 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
Word16 Q_old_inp_16k,
Word16 Q_r[2],
- Word16 *Q_new,
- Word16 downscale_buf_speech_enc_pe );
+ Word16 *Q_new );
ivas_error ivas_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
@@ -5874,4 +5870,819 @@ void reset_metadata_spatial_fx(
const Word32 core_brate, /* i : core bitrate */
const Word16 nb_bits_metadata /* i : number of meatdata bits */
);
+
+/*=============================================================================================*/
+/* clang-format off */
+
+/*----------------------------------------------------------------------------------*
+ * General IVAS prototypes
+ *----------------------------------------------------------------------------------*/
+
+/*! r: number of channels to be analysed */
+
+void copy_encoder_config_ivas_fx(
+ Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
+ Encoder_State *st, /* o : encoder state structure */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
+);
+
+ivas_error create_mct_enc_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+void destroy_cpe_enc(
+ CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
+);
+
+void ivas_mct_enc_close_fx(
+ MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
+);
+
+ivas_error pre_proc_front_ivas_fx(
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q,
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 *q_old_wsp,
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word32 currFlatness_fx, /* i : flatness parameter Q21*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
+ Word16 lf_E_LR_fx_q,
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
+ Word16 band_energies_LR_fx_q,
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
+ Word16 *Q_new
+#ifdef DEBUG_MODE_INFO
+ ,
+ const Word16 ch_idx
+#endif
+);
+ivas_error pre_proc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word32 last_element_brate, /* i : last element bitrate Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
+ Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
+ Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
+ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
+ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
+ Word16 e_old_wsp,
+ const Word16 loc_harm, /* i : harmonicity flag Q0*/
+ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
+ Word16 e_enerBuffer,
+ Word16 fft_buff_fx[2 * L_FFT], /* Qx */
+ Word16 cor_map_sum_fx, /* Q8 */
+ Word16 *Q_new
+);
+/*! r: number of clipped samples */
+void ivas_initialize_handles_enc_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+ivas_error ivas_init_encoder(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+void ivas_destroy_enc_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+ivas_error ivas_initialize_MD_bstr_enc_fx(
+ BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+void ivas_destroy_MD_bstr_enc_fx(
+ BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */
+);
+
+ivas_error ivas_init_decoder_front(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+
+void ivas_mct_dec_close(
+ MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */
+);
+
+/*! r: number of channels to be synthesised */
+
+void copy_decoder_config(
+ Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
+ Decoder_State *st /* o : decoder state structure */
+);
+
+void ivas_initialize_handles_dec(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_core_enc_fx(
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/
+ Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/
+ Word16 Q_new[],
+ Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 epsP_fx_q[], /* i : LP prediction errors */
+ Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/
+ Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/
+ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/
+ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/
+ Word16 *q_re_im_buf,
+ Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/
+ Word16 e_old_wsp[],
+ const Word16 loc_harm[], /* i : harmonicity flag Q0*/
+ const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/
+ const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 enerBuffer_fx_exp[], /* o : energy buffer */
+ Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/
+ const Word16 ivas_format, /* i : IVAS format Q0*/
+ const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+);
+
+void ivas_renderer_select(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_mc_enc_config_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+/*! r: flag indicating a valid bitrate */
+Word16 is_IVAS_bitrate_fx(
+ const Word32 ivas_total_brate /* i : IVAS total bitrate */
+);
+
+int16_t is_DTXrate(
+ const int32_t ivas_total_brate /* i : IVAS total bitrate */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * JBM prototypes
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_jbm_dec_set_discard_samples(
+ Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
+);
+
+TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode(
+ Decoder_Struct *st_ivas /* i : IVAS decoder handle */
+);
+
+void ivas_jbm_dec_tc_buffer_close(
+ DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
+);
+
+void ivas_jbm_dec_td_renderers_adapt_subframes(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_jbm_dec_metadata_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+void ivas_jbm_masa_sf_to_sf_map(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * ISM prototypes
+ *----------------------------------------------------------------------------------*/
+
+void bitbudget_to_brate(
+ const Word16 x[], /* i : bitbudgets Q0 */
+ Word32 y[], /* o : bitrates Q0 */
+ const Word16 N /* i : number of entries to be converted */
+);
+
+void ivas_ism_reset_metadata(
+ ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */
+);
+
+void ivas_ism_reset_metadata_enc(
+ ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */
+);
+void ivas_ism_reset_metadata_API(
+ ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */
+);
+
+/*! r: index of the winning codeword */
+Word16 ism_quant_meta_fx(
+ const Word32 val, /* i : scalar value to quantize Q22 */
+ Word32 *valQ, /* o : quantized value Q22 */
+ const Word32 borders_fx[], /* i : level borders Q22 */
+ const Word32 q_step_fx, /* i : quantization step Q22 */
+ const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */
+ const Word16 cbsize /* i : codebook size */
+);
+
+ivas_error ivas_ism_metadata_enc_create_fx(
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 n_ISms, /* i : number of objects */
+ Word32 element_brate_tmp[] /* o : element bitrate per object */
+);
+
+/*----------------------------------------------------------------------------------*
+ * Parametric ISM prototypes
+ *----------------------------------------------------------------------------------*/
+
+/*! r: ISM format mode */
+
+ivas_error ivas_param_ism_enc_open_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+void ivas_param_ism_enc_close_fx(
+ PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
+ const Word32 input_Fs /* i : input sampling_rate */
+);
+
+void ivas_ism_metadata_close(
+ ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */
+ const Word16 first_idx /* i : index of first handle to deallocate */
+);
+
+
+ivas_error ivas_ism_enc_config(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+/*----------------------------------------------------------------------------------*
+ * ISM DTX prototypes
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_ism_dtx_open(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+void ivas_ism_metadata_sid_enc_fx(
+ ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
+ const Word16 flag_noisy_speech, /* i : noisy speech flag */
+ const Word16 nchan_ism, /* i : number of objects */
+ const Word16 nchan_transport, /* i : number of transport channels */
+ const ISM_MODE ism_mode, /* i : ISM mode */
+ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
+ const Word16 sid_flag, /* i : indication of SID frame */
+ const Word16 md_diff_flag[], /* i : metadata differental flag */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ Word16 nb_bits_metadata[] /* o : number of metadata bits */
+);
+
+
+
+void ivas_param_ism_compute_noisy_speech_flag_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+/*----------------------------------------------------------------------------------*
+ * DFT Stereo prototypes
+ *----------------------------------------------------------------------------------*/
+
+void stereo_dft_dec_destroy(
+ STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */
+);
+
+/*----------------------------------------------------------------------------------*
+ * Range Coder prototypes
+ *----------------------------------------------------------------------------------*/
+
+/*! r: Read bit */
+UWord16 rc_uni_dec_read_bit(
+ RangeUniDecState *rc_st_dec /* i/o: RC state handle */
+);
+
+/*! r: Read bit */
+UWord16 rc_uni_dec_read_bit_prob_fast(
+ RangeUniDecState *rc_st_dec, /* i/o: RC state handle */
+ const Word16 freq0, /* i : Frequency for symbol 0 */
+ const UWord16 tot_shift /* i : Total frequency as a power of 2 */
+);
+
+/*! r: Read bits */
+UWord16 rc_uni_dec_read_bits(
+ RangeUniDecState *rc_st_dec, /* i/o: RC state handle */
+ const Word16 bits /* i : Number of bits */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * TD Stereo prototypes
+ *----------------------------------------------------------------------------------*/
+
+void tdm_bit_alloc(
+ const Word16 ivas_format, /* i : IVAS format */
+ const Word16 ism_mode, /* i : ISM mode in combined format */
+ const Word32 element_brate_wo_meta, /* i : element bitrate without metadata */
+ const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag */
+ Word32 *total_brate_pri, /* o : Allocated primary channel bitrate */
+ Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate */
+ Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */
+ const Word16 coder_type, /* i : secondary channel coder type */
+ const Word16 ener_ratio_idx, /* i : correlation ratio indexe */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 bwidth_pri, /* i : bandwidth of the primary channel */
+ const Word16 bwidth_sec, /* i : bandwidth of the secondary channel */
+ const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */
+ const Word16 tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */
+);
+
+
+/*! r: value of the indice */
+uint16_t get_indice_st(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word32 element_brate, /* i : element bitrate */
+ const Word16 pos, /* i : absolute position in the bitstream */
+ const Word16 nb_bits /* i : number of bits to quantize the indice */
+);
+
+/*----------------------------------------------------------------------------------*
+ * MDCT Stereo prototypes
+ *----------------------------------------------------------------------------------*/
+
+void stereo_mdct_core_enc_fx(
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
+ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
+);
+
+Word16 write_stereo_to_bitstream_fx
+(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
+ Encoder_State **sts, /* i/o: Encoder state structure */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
+ BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
+);
+
+/*----------------------------------------------------------------------------------*
+ * Stereo CNG prototypes
+ *----------------------------------------------------------------------------------*/
+void stereo_cng_dec_update(
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Framework general prototypes
+ *----------------------------------------------------------------------------------*/
+
+void mvc2c(
+ const uint8_t x[], /* i : input vector */
+ uint8_t y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+);
+
+void stereo_switching_dec(
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/
+);
+
+
+/*! r: number of bits written */
+
+
+
+/*----------------------------------------------------------------------------------*
+ * MCT prototypes
+ *----------------------------------------------------------------------------------*/
+void ivas_mdct_core_whitening_enc_fx(
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */
+ Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
+ Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */
+ Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */
+ Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */
+ Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */
+ Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */
+ Word16 p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */
+ const Word16 nChannels, /* i : total number of coded channels */
+Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV],
+Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV]
+);
+
+void splitAvailableBitsMCT_fx(
+ void **sts, /* i/o: encoder/decoder state structure */
+ const Word16 total_bits, /* i : total number of available bits */
+ const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */
+ const Word16 enc_dec, /* i : encoder or decoder flag */
+ const Word16 nchan /* i : number of channels */
+);
+
+void enc_prm_igf_mdct(
+ Encoder_State *st, /* i : Encoder state handle */
+ BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */
+);
+
+/*----------------------------------------------------------------------------------*
+ * Q Metadata prototypes for DirAC and MASA
+ *----------------------------------------------------------------------------------*/
+/*! r: number of bits written */
+
+/*! r: number of bits read */
+Word16 ivas_qmetadata_dec_decode(
+ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
+ UWord16 *bitstream, /* i : bitstream */
+ Word16 *index, /* i/o: bitstream position */
+ const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */
+);
+
+/*! r: number of bits read */
+Word16 ivas_qmetadata_dec_decode_hr_384_512(
+ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */
+ UWord16 *bitstream, /* i : bitstream */
+ Word16 *index, /* i/o: bitstream position */
+ const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */
+ const Word16 bits_sph_idx,
+ const Word16 bits_sp_coh,
+ const UWord8 ncoding_bands_config
+);
+
+/*! r: number of bits read */
+Word16 ivas_qmetadata_dec_sid_decode(
+ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
+ UWord16 *bitstream, /* i : bitstream */
+ Word16 *index, /* i/o: bitstream position */
+ const Word16 nchan_transport, /* i : number of transport channels */
+ Word16 *element_mode, /* o : element mode */
+ const Word16 ivas_format /* i : IVAS format */
+);
+
+
+UWord16 ivas_qmetadata_reorder_generic_fx(
+ const Word16 signed_value
+);
+
+void ivas_sba_set_cna_cng_flag(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+/*! r: number of ambisonics metadata channels */
+
+void ivas_sba_dirac_stereo_config(
+ STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */
+);
+
+
+Word16 ivas_get_sba_dirac_stereo_flag(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * DirAC prototypes
+ *----------------------------------------------------------------------------------*/
+
+
+ivas_error ivas_dirac_enc_reconfigure(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+);
+
+ivas_error ivas_mc_paramupmix_enc_open_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+);
+
+void ivas_mc_paramupmix_enc_close_fx(
+ MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
+ const int32_t input_Fs /* i : input sampling rate */
+);
+
+ivas_error ivas_mc_paramupmix_dec_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+void ivas_mc_paramupmix_dec_close(
+ MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */
+);
+
+void ivas_mc_paramupmix_dec_read_BS(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Decoder_State *st, /* i/o: decoder state structure */
+ MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */
+ Word16 *nb_bits /* o : number of bits written */
+);
+
+void ivas_mc_paramupmix_dec_digest_tc(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
+ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */
+ const Word16 nSamplesForRendering /* i : number of samples provided */
+);
+
+void ivas_param_mc_set_coded_bands_fx(
+ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */
+);
+
+UWord16 ivas_param_mc_get_configuration_index_fx(
+ const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate */
+);
+
+/*----------------------------------------------------------------------------------*
+ * SPAR prototypes
+ *----------------------------------------------------------------------------------*/
+
+/* MD module */
+
+/*! r: number of MD subframes */
+ivas_error ivas_spar_md_dec_open(
+ ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */
+ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
+ const Word16 num_channels, /* i : number of internal channels */
+ const Word16 sba_order, /* i : SBA order */
+ const Word16 sid_format, /* i : SID format */
+ const Word32 last_active_ivas_total_brate /* i : IVAS last active bitrate */
+);
+
+void ivas_spar_md_dec_close(
+ ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */
+);
+
+ivas_error ivas_spar_md_dec_init(
+ ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
+ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
+ const Word16 num_channels, /* i : number of internal channels */
+ const Word16 sba_order /* i : SBA order */
+);
+
+/* Transient detector module */
+ivas_error ivas_transient_det_open_fx(
+ ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */
+ const Word32 sampling_rate /* i : sampling rate */
+);
+
+void ivas_transient_det_close_fx(
+ ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */
+);
+
+void ivas_huffman_encode_fx(
+ ivas_huffman_cfg_t *huff_cfg,
+ Word16 in,
+ Word16 *hcode,
+ Word16 *hlen
+);
+
+ivas_error ivas_huffman_decode(
+ ivas_huffman_cfg_t *huff_cfg,
+ Decoder_State *st0,
+ Word16 *dec_out
+);
+
+void ivas_arith_decode_cmplx_cell_array(
+ ivas_arith_t *pArith_re,
+ ivas_arith_t *pArith_re_diff,
+ Decoder_State *st0,
+ ivas_cell_dim_t *pCell_dims,
+ Word16 *pDo_diff, const Word16 nB,
+ Word16 *pSymbol_re,
+ Word16 *pSymbol_re_old
+);
+
+void ivas_map_prior_coeffs_quant(
+ ivas_spar_md_prev_t *pSpar_md_prior,
+ ivas_spar_md_com_cfg *pSpar_md_cfg,
+ const Word16 qsi,
+ const Word16 nB
+);
+
+void ivas_clear_band_coeff_idx(
+ ivas_band_coeffs_ind_t *pband_coeff_idx,
+ const UWord16 num_bands
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * MASA prototypes
+ *----------------------------------------------------------------------------------*/
+ivas_error ivas_masa_enc_open_fx(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+);
+
+void ivas_masa_enc_close_fx(
+ MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */
+);
+
+int16_t ivas_qmetadata_encode_extended_gr_length_fx(
+ const UWord16 value,
+ const UWord16 alphabet_size,
+ const Word16 gr_param);
+
+void ivas_qmetadata_encode_extended_gr_fx(
+ BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */
+ const UWord16 value, /* i : value to be encoded */
+ const UWord16 alphabet_size, /* i : alphabet size */
+ const Word16 gr_param); /* i : GR order */
+
+
+void ivas_set_qmetadata_maxbit_req_fx(
+ IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */
+ const IVAS_FORMAT ivas_format /* i : IVAS format */
+);
+
+
+/*---------------------------------------------------------------------------------*
+ * Binaural FastConv Renderer Prototypes
+*-----------------------------------------------------------------------------------*/
+
+
+void ivas_binaural_hrtf_close(
+ HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */
+);
+
+/*----------------------------------------------------------------------------------*
+ * renderer prototypes
+ *----------------------------------------------------------------------------------*/
+
+void ivas_ism_renderer_close(
+ ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Amplitude Panning VBAP prototypes
+ *----------------------------------------------------------------------------------*/
+
+void panning_wrap_angles(
+ const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
+ const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
+ float *azi_wrapped, /* o : wrapped azimuth component */
+ float *ele_wrapped /* o : wrapped elevation component */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * McMASA prototypes
+ *----------------------------------------------------------------------------------*/
+
+
+ivas_error ivas_mcmasa_dec_reconfig(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
+);
+
+void ivas_mcmasa_dmx_modify_fx(
+ const Word16 n_samples, /* i : input frame length in samples */
+ Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/
+ Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/
+ const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */
+ const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/
+);
+
+ivas_error ivas_mono_dmx_renderer_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+
+void ivas_mono_dmx_renderer_close(
+ MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * LFE encoder low pass filter prototypes
+ *----------------------------------------------------------------------------------*/
+
+void ivas_lfe_lpf_enc_close_fx(
+ ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * LFE Coding prototypes
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_create_lfe_enc_fx(
+ LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */
+ const Word32 input_Fs /* i : input sampling rate */
+);
+
+void ivas_lfe_enc_close_fx(
+ LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */
+);
+
+void ivas_filters_init_fx(
+ ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
+ const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */
+ const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */
+ const Word16 order ) ;
+
+void ivas_filter_process_fx(
+ ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
+ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */
+ const Word16 length, /* i : filter order */
+ Word16 q_factor );
+
+/*----------------------------------------------------------------------------------*
+ * OSBA prototypes
+ *----------------------------------------------------------------------------------*/
+ivas_error ivas_osba_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+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(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ int32_t *ism_total_brate /* i : ISM total bitrate */
+);
+
+ivas_error ivas_omasa_separate_object_renderer_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+void ivas_omasa_separate_object_renderer_close(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+/*----------------------------------------------------------------------------------*
+ * Filter-bank (FB) Mixer
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_fb_set_cfg(
+ IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */
+ const Word16 ivas_format, /* i : IVAS format */
+ const Word16 num_in_chans, /* i : number of FB input channels */
+ const Word16 num_out_chans, /* i : number of FB output channels */
+ const Word16 active_w_mixing, /* i : active_w_mixing flag */
+ const Word32 sampling_Fs, /* i : sampling rate */
+ const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */
+);
+
+
+/*=============================================================================================*/
+
#endif
diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com_fx.c
similarity index 91%
rename from lib_com/ivas_qmetadata_com.c
rename to lib_com/ivas_qmetadata_com_fx.c
index cbc67de00687671820538f9c8f4741fb28928c9d..a5fbf9e83c6d8c0c3b21f77d0a96f8d889f4543a 100644
--- a/lib_com/ivas_qmetadata_com.c
+++ b/lib_com/ivas_qmetadata_com_fx.c
@@ -36,11 +36,9 @@
#include "options.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
-#include "ivas_prot.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
@@ -154,10 +152,8 @@ ivas_error ivas_qmetadata_allocate_memory_fx(
{
set32_fx( hQMetaData->q_direction[dir].band_data[j].elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
set32_fx( hQMetaData->q_direction[dir].band_data[j].azimuth_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
-#ifdef MSAN_FIX
set32_fx( hQMetaData->q_direction[dir].band_data[j].q_elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
set32_fx( hQMetaData->q_direction[dir].band_data[j].q_azimuth_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
-#endif
set32_fx( hQMetaData->q_direction[dir].band_data[j].energy_ratio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
}
}
@@ -317,14 +313,8 @@ ivas_error only_reduce_bits_direction_fx(
Word16 *bits_dir0;
Word16 bits_sph_idx_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES];
-#ifdef FIX_QMETADATA_PENALTY
Word32 penalty[MASA_MAXIMUM_CODING_SUBBANDS];
Word16 tmp;
-#else
- Word16 penalty[MASA_MAXIMUM_CODING_SUBBANDS];
- Word16 shift, tmp, tmp_e, flag;
- Word32 tmp_32;
-#endif
FOR( j = 0; j < coding_subbands; j++ )
{
FOR( k = 0; k < no_subframes; k++ )
@@ -409,7 +399,6 @@ ivas_error only_reduce_bits_direction_fx(
}
ELSE
{
-#ifdef FIX_QMETADATA_PENALTY
Word16 m, sorted, index1, index2;
@@ -457,67 +446,6 @@ ivas_error only_reduce_bits_direction_fx(
}
}
}
-
-
-#else
- FOR( j = 0; j < coding_subbands; j++ )
- {
- penalty[j] = 0;
- move16();
- tmp_32 = 0;
- move32();
- shift = find_guarded_bits_fx( no_subframes );
-
- flag = 1;
- move16();
- // This change was done due to loss of precision from BASOP_Util_Divide3232_Scale which was leading to penalty getting calculated wrongly
- // and hence ind_order being sorted incorrectly which might cause infinite loop.
- FOR( k = 0; k < no_subframes - 1; k++ )
- {
- IF( NE_16( bits_sph_idx_orig[j][k], bits_sph_idx_orig[j][k + 1] ) )
- {
- flag = 0;
- move16();
- }
- }
-
- IF( flag )
- {
- tmp = 0;
- move16();
- FOR( k = 0; k < no_subframes; k++ )
- {
- IF( bits_sph_idx_orig[j][k] > 0 )
- {
- tmp = add( tmp, sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) );
- }
- }
-
- tmp = BASOP_Util_Divide1616_Scale( tmp, bits_sph_idx_orig[j][0], &tmp_e );
-
- tmp_32 = L_shl( tmp, tmp_e ); /* Q15 */
-
- penalty[j] = extract_l( L_shr( tmp_32, shift ) ); /* Q15 - shift */
- move16();
- // Division by no_subframes for penalty[j] not required
- }
- ELSE
- {
- FOR( k = 0; k < no_subframes; k++ )
- {
- IF( bits_sph_idx_orig[j][k] > 0 )
- {
- tmp = BASOP_Util_Divide3232_Scale( extract_l( L_sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) ), bits_sph_idx_orig[j][k], &tmp_e );
- tmp_32 = L_add( tmp_32, L_shl( tmp, tmp_e ) );
- }
- }
- penalty[j] = extract_l( L_shr( tmp_32, shift ) ); /* Q15 - shift */
- move16();
- // Division by no_subframes for penalty[j] not required
- }
- }
- sort_desc_ind_16_fx( penalty, coding_subbands, ind_order );
-#endif
}
*reduce_bits_out = negate( reduce_bits );
diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com_fx.c
similarity index 99%
rename from lib_com/ivas_qspherical_com.c
rename to lib_com/ivas_qspherical_com_fx.c
index 8ef48be2e355803124f13020b97b562ca6d85615..6661026a8cde298b8d2f618156313e3cdef73a1f 100644
--- a/lib_com/ivas_qspherical_com.c
+++ b/lib_com/ivas_qspherical_com_fx.c
@@ -36,13 +36,10 @@
#include
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
-#include "ivas_prot.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-#include "prot_fx.h"
#include "ivas_rom_com_fx.h"
diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c
index 8ea2b91e411b204a3b8a6e239481c20f0e6cd7ee..a7a8bdcbfd6176743ab5f8571aa3cb82905bd5fc 100644
--- a/lib_com/ivas_rom_com_fx.c
+++ b/lib_com/ivas_rom_com_fx.c
@@ -1617,23 +1617,23 @@ const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBAND
};
/* Multi-channel input and output setups */
-const int16_t ls_azimuth_CICP2_idx[2] = { 1, 2 };
-const int16_t ls_elevation_CICP2_idx[2] = { 0, 0 };
+const Word16 ls_azimuth_CICP2_idx[2] = { 1, 2 };
+const Word16 ls_elevation_CICP2_idx[2] = { 0, 0 };
-const int16_t ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 };
-const int16_t ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 };
+const Word16 ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 };
+const Word16 ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 };
-const int16_t ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 };
-const int16_t ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 };
+const Word16 ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 };
+const Word16 ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 };
-const int16_t ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 };
-const int16_t ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 };
+const Word16 ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 };
+const Word16 ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 };
-const int16_t ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 };
-const int16_t ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 };
+const Word16 ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 };
+const Word16 ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 };
-const int16_t ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 };
-const int16_t ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 };
+const Word16 ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 };
+const Word16 ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 };
const Word32 shoebox_sin_cos_tbl_fx[11][2] = { { 0, 1073741824 }, // 0
{ 536870912, 929887680 },
diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config_fx.c
similarity index 99%
rename from lib_com/ivas_sba_config.c
rename to lib_com/ivas_sba_config_fx.c
index 94ceb8e3cb1b4a9ae6b0c252636f3641b96ad360..b3a0806d4af63519605efa1c7ff5da40ba095d2e 100644
--- a/lib_com/ivas_sba_config.c
+++ b/lib_com/ivas_sba_config_fx.c
@@ -37,8 +37,7 @@
#include "cnst.h"
#include "ivas_cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c
index 788fb3c56568b76a9da297901c393c1ded640571..fa64b0092d6de30d78c2199930ea32e99629cb3a 100644
--- a/lib_com/ivas_sns_com_fx.c
+++ b/lib_com/ivas_sns_com_fx.c
@@ -33,9 +33,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot.h"
#include "prot_fx.h"
-#include "ivas_prot.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include
@@ -62,12 +60,11 @@ void sns_compute_scf_fx(
Word64 sum;
Word32 L_tmp;
const Word32 *pow_tilt;
+ Word16 q_shift, q_out, f_tmp;
+ Word16 bw, inv_bw, exp;
const UWord8 nBands = pPsychParams->nBands;
move16();
const UWord8 *bandLengths = pPsychParams->bandLengths;
- Word8 bw = 0;
- move16();
- Word16 q_shift;
const Word16 w_0 = 2730; // (1.0f / 12.0f) in Q15
move16();
@@ -89,91 +86,83 @@ void sns_compute_scf_fx(
IF( bandLengths == NULL )
{
- bw = (Word8) shr( L_frame, 6 );
+ bw = shr( L_frame, 6 );
move16();
+
+ exp = norm_s( bw );
+ inv_bw = div_s( ONE_IN_Q14, shl( bw, exp ) ); // Q:15+14-exp = 29-exp
+ inv_bw = shl( inv_bw, sub( exp, 14 ) ); // Q15
+
/* Energy per band */
k = 0;
move16();
FOR( i = 0; i < nBands; ++i )
{
- x_64[i] = 0;
+ sum = 0;
move64();
FOR( n = 0; n < bw; ( ++n, ++k ) )
{
- x_64[i] = W_add( x_64[i], W_deposit32_l( spectrum[k] ) ); // Q_in
- move64();
+ /* x[i] += spectrum[k];
+ inv_bw is for x[i] /= bw; */
+ sum = W_mac_32_16( sum, spectrum[k], inv_bw ); // Q_in+15+1
}
+ x_64[i] = sum; // Q_in+16
+ move64();
}
}
ELSE
{
/* Energy per band */
k = 0;
- move32();
+ move16();
FOR( i = 0; i < nBands; ++i )
{
- x_64[i] = 0;
+ exp = norm_s( bandLengths[i] );
+ inv_bw = div_s( ONE_IN_Q14, shl( bandLengths[i], exp ) ); // Q:15+14-exp
+ inv_bw = shl( inv_bw, sub( exp, 14 ) ); // Q15
+
+ sum = 0;
move64();
FOR( n = 0; n < bandLengths[i]; ( ++n, ++k ) )
{
- x_64[i] = W_add( x_64[i], W_deposit32_l( spectrum[k] ) ); // Q_in
- move64();
+ /* x[i] += spectrum[k];
+ inv_bw is for x[i] /= bandLengths[i]; */
+ sum = W_mac_32_16( sum, spectrum[k], inv_bw ); // Q_in+15+1
}
+ x_64[i] = sum; // Q_in+16
+ move64();
}
}
/* Move accumulated values to 32-bit */
- q_shift = 0;
- move16();
- IF( x_64[0] != 0 )
+ q_shift = W_norm_arr( x_64, nBands ); // W_norm_arr return 63 when all the values of the input buffer are zeroes
+ IF( EQ_16( q_shift, 63 ) )
{
- q_shift = W_norm( x_64[0] );
- }
- FOR( i = 1; i < nBands; ++i )
- {
- IF( x_64[i] != 0 )
- {
- q_shift = s_min( q_shift, W_norm( x_64[i] ) );
- }
- }
- FOR( i = 0; i < nBands; ++i )
- {
- x[i] = W_extract_l( W_shl( x_64[i], sub( q_shift, 32 ) ) ); // Q_in + (q_shift - 32)
- }
+ /* If all the values of x_64 are zeros, the scale factor (scf) values will be calculated as zeroes as per the below operations.
+ To avoid extra computations in such a case, set scf values as zeroes and return. */
- IF( bandLengths == NULL )
- {
- Word16 inv_bw;
- bw = (Word8) shr( L_frame, 6 );
- move16();
- inv_bw = div_l( ONE_IN_Q16 /*1 Q16*/, bw ); // Q15
- FOR( i = 0; i < nBands; ++i )
- {
- x[i] = Mpy_32_16_1( x[i], inv_bw ); // Q_in + (q_shift - 32)
- move32();
- }
+ set_zero_fx( scf, SNS_NPTS );
+
+ return;
}
- ELSE
+
+ FOR( i = 0; i < nBands; ++i )
{
- FOR( i = 0; i < nBands; ++i )
- {
- Word16 inv_bw = div_l( ONE_IN_Q16 /*1 Q16*/, bandLengths[i] ); // Q15
- x[i] = Mpy_32_16_1( x[i], inv_bw ); // Q_in + (q_shift - 32)
- move32();
- }
+ x[i] = W_extract_h( W_shl( x_64[i], q_shift ) ); // Q: Q_in+16+q_shift-32 = Q_in+q_shift-16
+ move32();
}
/* Smoothing */
- xs[0] = L_add( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[1], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32)
+ xs[0] = Madd_32_16( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), x[1], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16
move32();
FOR( i = 1; i < FDNS_NPTS - 1; i++ )
{
- xs[i] = L_add( L_add( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), Mpy_32_16_1( x[i - 1], 8192 /* 0.25 in Q15 */ ) ), Mpy_32_16_1( x[i + 1], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32)
+ xs[i] = Madd_32_16( Madd_32_16( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), x[i - 1], 8192 /* 0.25 in Q15 */ ), x[i + 1], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16
move32();
}
- xs[FDNS_NPTS - 1] = L_add( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32)
+ xs[FDNS_NPTS - 1] = Madd_32_16( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16
move32();
/* Pre-emphasis */
@@ -195,86 +184,83 @@ void sns_compute_scf_fx(
FOR( i = 0; i < FDNS_NPTS; i++ )
{
- xs[i] = Mpy_32_32( xs[i], pow_tilt[i] ); // Q_in + (q_shift - 32)
+ xs[i] = Mpy_32_32( xs[i], pow_tilt[i] ); // Q_in+q_shift-16+23-31 = Q_in+q_shift-24
move32();
}
/* Noise floor at -40dB */
sum = 0;
move64();
- FOR( Word16 ind = 0; ind < FDNS_NPTS; ind++ )
+ FOR( i = 0; i < FDNS_NPTS; i++ )
{
- sum = W_add( sum, W_deposit32_l( xs[ind] ) ); // Q_in + (q_shift - 32)
+ sum = W_mac_32_16( sum, xs[i], 1 ); // Q_in+q_shift-24+1
}
- mean = W_extract_l( W_shr( sum, 6 ) ); // Q_in + (q_shift - 32)
- nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // Q_in + (q_shift - 32)
- nf = L_max( nf, 0 /* powf( 2.0f, -32.0f ) in Q31 */ ); // Q_in + (q_shift - 32)
+ q_out = sub( add( Q_in, q_shift ), 24 );
+
+ /* mean = sum / FDNS_NPTS;
+ -Q6 is for division with FDNS_NPTS and -Q1 is to reduce Q by one */
+ mean = W_shl_sat_l( sum, -Q7 ); // q_out
+ nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // q_out
+ nf = L_max( nf, L_shl( 256, sub( q_out, 40 ) ) /* powf( 2.0f, -32.0f ) in Q40 */ ); // q_out
FOR( i = 0; i < FDNS_NPTS; i++ )
{
- if ( LT_32( xs[i], nf ) )
- {
- xs[i] = nf; // Q_in + (q_shift - 32)
- move32();
- }
+ xs[i] = L_max( xs[i], nf ); // q_out
+ move32();
}
/* Log-domain */
FOR( i = 0; i < FDNS_NPTS; i++ )
{
- Word16 e_tmp = norm_l( xs[i] );
- Word16 f_tmp = Log2_norm_lc( L_shl( xs[i], e_tmp ) ); /*Q16*/
- e_tmp = sub( sub( 34, e_tmp ), Q_in );
- /* Note: Mpy_32_16 is used temporarily for this computation, It needs to be replaced with appropriate BASOP. */
- xl[i] = Mpy_32_16( e_tmp, f_tmp, 16384 ); /* Q16 */
+ /* xl[i] = logf( xs[i] ) * scale_log;
+ scale_log = INV_LOG_2 * 0.5f; */
+
+ exp = norm_l( xs[i] );
+ f_tmp = Log2_norm_lc( L_shl( xs[i], exp ) ); // Q15
+ exp = sub( sub( 30, exp ), q_out );
+ L_tmp = L_mac( L_deposit_h( exp ), f_tmp, 1 ); // Q16
+ xl[i] = L_shr( L_tmp, 1 ); // Q16
move32();
}
/* Downsampling */
- L_tmp = L_deposit_l( 0 );
- L_tmp = Madd_32_16( L_tmp, xl[0], w_0 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[0], w_1 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[1], w_2 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[2], w_3 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[3], w_4 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[4], w_5 ); // Q16
- xl4[0] = L_tmp; // Q16
- move32();
+ L_tmp = Madd_32_16( Mpy_32_16_1( xl[0], w_0 ), xl[0], w_1 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[1], w_2 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[2], w_3 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[3], w_4 ); // Q16
+ xl4[0] = Madd_32_16( L_tmp, xl[4], w_5 ); // Q16
+
FOR( n = 1; n < SNS_NPTS - 1; n++ )
{
- Word16 n4 = shl( n, 2 );
-
- L_tmp = L_deposit_l( 0 );
- L_tmp = Madd_32_16( L_tmp, xl[n4 - 1], w_0 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[n4], w_1 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[n4 + 1], w_2 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[n4 + 2], w_3 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[n4 + 3], w_4 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[n4 + 4], w_5 ); // Q16
- xl4[n] = L_tmp; // Q16
+ L_tmp = Mpy_32_16_1( xl[4 * n - 1], w_0 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[4 * n], w_1 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[4 * n + 1], w_2 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[4 * n + 2], w_3 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[4 * n + 3], w_4 ); // Q16
+ xl4[n] = Madd_32_16( L_tmp, xl[4 * n + 4], w_5 ); // Q16
move32();
}
- L_tmp = L_deposit_l( 0 );
- L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 5], w_0 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 4], w_1 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 3], w_2 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 2], w_3 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_4 ); // Q16
- L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_5 ); // Q16
- xl4[SNS_NPTS - 1] = L_tmp; // Q16
+ L_tmp = Mpy_32_16_1( xl[FDNS_NPTS - 5], w_0 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 4], w_1 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 3], w_2 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 2], w_3 ); // Q16
+ L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_4 ); // Q16
+ xl4[SNS_NPTS - 1] = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_5 ); // Q16
move32();
/* Remove mean and scaling */
sum = 0;
move64();
- FOR( Word16 ind = 0; ind < SNS_NPTS; ind++ )
+ FOR( i = 0; i < SNS_NPTS; i++ )
{
- sum = W_add( sum, W_deposit32_l( xl4[ind] ) ); // Q16
+ sum = W_mac_32_16( sum, xl4[i], 1 ); // Q16+1
}
- mean = W_extract_l( W_shr( sum, 4 ) ); // Q16
+ /* mean = sum / SNS_NPTS;
+ -Q4 is for division with SNS_NPTS and -Q1 is to reduce Q by one */
+ mean = W_shl_sat_l( sum, -Q5 ); // Q16
FOR( i = 0; i < SNS_NPTS; i++ )
{
diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com_fx.c
similarity index 97%
rename from lib_com/ivas_spar_com.c
rename to lib_com/ivas_spar_com_fx.c
index 0ebae0de678aacc93972eab223eefd9cb9908cf3..5a0d342e91e737a95e08e15fd7f22b63a9f61784 100644
--- a/lib_com/ivas_spar_com.c
+++ b/lib_com/ivas_spar_com_fx.c
@@ -35,9 +35,7 @@
#include "options.h"
#include "basop_util.h"
#include "ivas_stat_com.h"
-#include "prot.h"
#include "prot_fx.h"
-#include "ivas_prot.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "cnst.h"
@@ -2633,11 +2631,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
test();
IF( W_norm( re ) == 0 || W_norm( recon_uu_re[i][j] ) == 0 )
{
-#ifdef FIX_ISSUE_1122
recon_uu_re[i][j] = L_shr( recon_uu_re[i][j], 1 ); // q_recon_uu_re[i][j] - 1
-#else
- re1[m] = L_shr( re1[m], 1 ); // q_recon_uu_re[i][j]-1
-#endif
move32();
q_recon_uu_re[i][j] = sub( q_recon_uu_re[i][j], 1 );
move16();
@@ -3808,7 +3802,7 @@ void ivas_compute_spar_params_fx(
{
Word32 pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS];
- Word16 b, i, ndm;
+ Word16 b, i, ndm, j;
Word16 q_pred_coeffs;
ivas_get_pred_coeffs_fx( cov_real, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, active_w_vlbr, dtx_vad, from_dirac, dyn_active_w_flag, hSparMd->res_ind, &q_pred_coeffs, q_dm_fv_re );
@@ -3836,11 +3830,7 @@ void ivas_compute_spar_params_fx(
}
ELSE
{
-#ifdef FIX_11_1_IVAS_SPAR_DEC_UPMIXER_SF_RND_COEFFS
hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].pred_re_fx[i] = L_shr_r( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].pred_re_fx[i], sub( tmp, 22 ) ); // q22
-#else
- hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].pred_re_fx[i] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].pred_re_fx[i], sub( tmp, 22 ) ); // q22
-#endif
move32();
}
}
@@ -3867,24 +3857,14 @@ void ivas_compute_spar_params_fx(
Word16 q_tmp = hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].q_C_re_fx;
IF( NE_16( ndm, 1 ) )
{
-#ifdef MSAN_FIX
FOR( i = 0; i < ( num_ch - ndm ); i++ )
{
- FOR( Word16 j = 0; j < sub( ndm, 1 ); j++ )
+ FOR( j = 0; j < sub( ndm, 1 ); j++ )
{
hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].C_re_fx[i][j], sub( q_tmp, 22 ) ); // q22
move32();
}
}
-#else
- for ( i = 0; i < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; i++ )
- {
- for ( int j = 0; j < IVAS_SPAR_MAX_DMX_CHS - 1; j++ )
- {
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j], sub( q_tmp, 22 ) );
- }
- }
-#endif
hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].q_C_re_fx = Q22;
move16();
}
@@ -3892,7 +3872,7 @@ void ivas_compute_spar_params_fx(
q_tmp = hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].q_P_re_fx;
move16();
- FOR( Word16 j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ )
+ FOR( j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ )
{
hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].P_re_fx[j] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].P_re_fx[j], sub( q_tmp, 22 ) ); // q22
move32();
@@ -4005,7 +3985,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
move16();
P_norm_fx[0] = 0;
move32();
- FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ )
+ Word16 len = s_max( 0, sub( foa_ch, ndm ) );
+ FOR( i = 0; i < len; i++ )
{
P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
@@ -4015,7 +3996,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
P_norm_fx[1] = 0;
move32();
- FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
+ len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
+ FOR( ; i < len; i++ ) // max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
{
P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
@@ -4032,8 +4014,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
}
P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
move32();
-
- FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ )
+ len = s_max( 0, sub( foa_ch, ndm ) );
+ FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) )
{
idx = sub( remix_order[i + ndm], ndm );
P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4046,7 +4028,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
move32();
}
}
- FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
+ len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
+ FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
{
idx = sub( remix_order[i + ndm], ndm );
P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4058,6 +4041,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
move32();
}
}
+
FOR( ; i < ( num_ch - ndm ); i++ )
{
idx = sub( remix_order[i + ndm], ndm );
@@ -4223,7 +4207,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
/*normalize 2nd order*/
norm_fx = 0;
move32();
- FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
+ Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order );
+ FOR( ch = foa_ch; ch < min_ch_order; ch++ )
{
norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29
}
@@ -4244,7 +4229,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
move16();
}
norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
- FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
+ min_ch_order = s_min( hoa2_ch_order, num_ch_order );
+ FOR( ch = foa_ch; ch < min_ch_order; ch++ )
{
IF( LT_32( norm_fx, EPSILON_FX_THR ) )
{
@@ -4558,7 +4544,8 @@ void ivas_get_spar_md_from_dirac_fx(
move16();
P_norm_fx[0] = 0;
move32();
- FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ )
+ Word16 len = s_max( 0, sub( foa_ch, ndm ) );
+ FOR( i = 0; i < len; i++ ) // i < max( 0, sub( foa_ch, ndm ) )
{
P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
@@ -4568,7 +4555,8 @@ void ivas_get_spar_md_from_dirac_fx(
P_norm_fx[1] = 0;
move32();
- FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
+ len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
+ FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
{
P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
@@ -4585,8 +4573,8 @@ void ivas_get_spar_md_from_dirac_fx(
}
P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
move32();
-
- FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ )
+ len = s_max( 0, sub( foa_ch, ndm ) );
+ FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) )
{
idx = sub( remix_order[i + ndm], ndm );
P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4599,7 +4587,8 @@ void ivas_get_spar_md_from_dirac_fx(
move32();
}
}
- FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
+ len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
+ FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
{
idx = sub( remix_order[i + ndm], ndm );
P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4776,7 +4765,8 @@ void ivas_get_spar_md_from_dirac_fx(
/*normalize 2nd order*/
norm_fx = 0;
move32();
- FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
+ Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order );
+ FOR( ch = foa_ch; ch < min_ch_order; ch++ )
{
norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29
}
@@ -4797,7 +4787,8 @@ void ivas_get_spar_md_from_dirac_fx(
move16();
}
norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
- FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
+ min_ch_order = s_min( hoa2_ch_order, num_ch_order );
+ FOR( ch = foa_ch; ch < min_ch_order; ch++ )
{
IF( LT_32( norm_fx, EPSILON_FX_THR ) )
{
@@ -7173,6 +7164,133 @@ void ivas_dirac_dec_get_response_fx(
return;
}
+#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx
+/*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/
+void ivas_dirac_dec_get_response_fx_29(
+ const Word16 azimuth,
+ const Word16 elevation,
+ Word32 *response_fx, /*Q_out*/
+ const Word16 ambisonics_order )
+{
+ Word16 index_azimuth, index_elevation;
+ Word16 el, az;
+ Word32 cos_1_fx, cos_2_fx, sin_1_fx, cos_az_fx[3];
+ Word32 sin_az_fx[3];
+ Word32 f_fx;
+ Word32 c_fx_better;
+ Word16 l, m;
+ Word16 b, b1, b_2, b1_2;
+ // Word16 Q_out = 29;
+
+ index_azimuth = add( azimuth, 180 ) % 360;
+ move16();
+ index_elevation = add( elevation, 90 );
+
+ Word32 e_fac = L_add( 0x7FFFFFFF, 0 );
+
+ if ( GT_16( index_elevation, 90 ) )
+ {
+ e_fac = L_add( 0x80000000, 0 );
+ }
+
+
+ el = index_elevation;
+ move16();
+
+ if ( GT_16( index_elevation, 90 ) )
+ {
+ el = sub( 180, index_elevation );
+ }
+
+ az = index_azimuth;
+ move16();
+
+ if ( GT_16( index_azimuth, 180 ) )
+ {
+ az = sub( 360, index_azimuth );
+ }
+
+ f_fx = 1;
+ move16();
+
+ if ( GT_16( index_azimuth, 180 ) )
+ {
+ f_fx = -1;
+ }
+
+ cos_1_fx = L_shr( dirac_gains_trg_term_fx[az][0], 1 ); // q30
+ cos_2_fx = L_shl( Mpy_32_32( cos_1_fx, cos_1_fx ), 1 ); // q30
+ sin_1_fx = L_shr( dirac_gains_trg_term_fx[az][1], 1 ); // q30
+
+ if ( EQ_32( f_fx, -1 ) )
+ {
+ sin_1_fx = L_negate( sin_1_fx ); // q30
+ }
+ cos_az_fx[0] = cos_1_fx; // q30
+ move32();
+ cos_az_fx[1] = L_shl( L_sub( cos_2_fx, ONE_IN_Q29 /*0.5 q30*/ ), 1 ); /*q30*/
+ move32();
+ cos_az_fx[2] = L_sub( L_shl( Mpy_32_32( cos_1_fx, cos_az_fx[1] ), 2 ), cos_az_fx[0] /* cos_az_fx[0] q30*/ ); /*q30*/
+ move32();
+ sin_az_fx[0] = sin_1_fx; /*q30*/
+ move32();
+ sin_az_fx[1] = L_shl( Mpy_32_32( sin_1_fx, cos_1_fx ), 2 ); /*q30*/
+ move32();
+ sin_az_fx[2] = L_shl( Mpy_32_32( sin_1_fx, L_sub( cos_2_fx, ONE_IN_Q28 /*1/4 q30*/ ) ), 3 ); /*q30*/
+ move32();
+
+ response_fx[0] = 0x20000000;
+ move32();
+
+ FOR( l = 1; l <= ambisonics_order; l++ )
+ {
+ Word16 a;
+ b_2 = imult1616( l, l );
+ b1_2 = add( b_2, shl( l, 1 ) );
+ FOR( m = 0; m < l; m += 2 )
+ {
+ b = b_2 + m;
+ a = dirac_gains_P_idx[b];
+
+ c_fx_better = local_result_table[el][a]; // q30
+ move32();
+ response_fx[b] = Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ); // Q_out
+ move32();
+
+ b1 = b1_2 - m;
+ response_fx[b1] = Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ); // Q_out
+ move32();
+ }
+
+ FOR( m = 1; m < l; m += 2 )
+ {
+ b = b_2 + m;
+ a = dirac_gains_P_idx[b];
+ c_fx_better = local_result_table[el][a]; // q30
+ move32();
+ c_fx_better = Mpy_32_32( c_fx_better, e_fac ); // q30
+ response_fx[b] = Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ); // Q_out
+ move32();
+
+ b1 = b1_2 - m;
+ response_fx[b1] = Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ); // Q_out
+ move32();
+ }
+
+ b = add( b_2, l );
+ a = dirac_gains_P_idx[b];
+ c_fx_better = local_result_table_2[el][a]; // q30
+ move32();
+ if ( s_and( l, 0x01 ) )
+ {
+ c_fx_better = Mpy_32_32( c_fx_better, e_fac ); // q30
+ }
+ response_fx[b] = L_shl( c_fx_better, -1 ); // Q_out
+ move32();
+ }
+ return;
+}
+#endif /*FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx*/
/*-----------------------------------------------------------------------------------------*
* Function ivas_get_bits_to_encode
*
diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util_fx.c
similarity index 99%
rename from lib_com/ivas_spar_com_quant_util.c
rename to lib_com/ivas_spar_com_quant_util_fx.c
index 0f0e003dd3be3d4b58764a2c74e899361f74f26c..cfd03a3b3e68d51d66045229266e9f412a564231 100644
--- a/lib_com/ivas_spar_com_quant_util.c
+++ b/lib_com/ivas_spar_com_quant_util_fx.c
@@ -33,9 +33,7 @@
#include
#include "options.h"
#include "math.h"
-#include "prot.h"
#include "prot_fx.h"
-#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include
#include "wmc_auto.h"
diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h
index 249d1e96384ef5bcf140180c09ce1eedf067eb05..fb11d3934486f3c09af3e8e5482ec78c90f6bc7a 100644
--- a/lib_com/ivas_stat_com.h
+++ b/lib_com/ivas_stat_com.h
@@ -46,18 +46,18 @@
typedef struct
{
- int16_t last_angle1_idx; /* last frame index of coded azimuth/yaw */
- int16_t angle1_diff_cnt; /* FEC counter of consecutive differentially azimuth/yaw coded frames */
- int16_t last_angle2_idx; /* last frame index of coded elevation/pitch */
- int16_t angle2_diff_cnt; /* FEC counter of consecutive differentially elevation/pitch coded frames */
+ Word16 last_angle1_idx; /* last frame index of coded azimuth/yaw */
+ Word16 angle1_diff_cnt; /* FEC counter of consecutive differentially azimuth/yaw coded frames */
+ Word16 last_angle2_idx; /* last frame index of coded elevation/pitch */
+ Word16 angle2_diff_cnt; /* FEC counter of consecutive differentially elevation/pitch coded frames */
} ISM_METADATA_ANGLE, *ISM_METADATA_ANGLE_HANDLE;
/* ISM metadata handle (storage for one frame of read ISM metadata) */
typedef struct
{
- int16_t ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */
- int16_t last_ism_metadata_flag; /* last frame ism_metadata_flag */
+ Word16 ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */
+ Word16 last_ism_metadata_flag; /* last frame ism_metadata_flag */
Word32 azimuth_fx; /* azimuth value read from the input metadata file */ /* Q22 */
Word32 elevation_fx; /* elevation value read from the input metadata file */ /* Q22 */
@@ -65,25 +65,25 @@ typedef struct
Word32 yaw_fx; /* yaw value read from the input metadata file */ /* Q22 */
Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */
- int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */
+ Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */
ISM_METADATA_ANGLE position_angle; /* Angle structs for azimuth and elevation */
ISM_METADATA_ANGLE orientation_angle; /* Angle structs for yaw and pitch */
- int16_t last_radius_idx; /* last frame index of coded radius */
- int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */
+ Word16 last_radius_idx; /* last frame index of coded radius */
+ Word16 radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */
Word32 last_azimuth_fx; /* MD smoothing in DTX- last Q azimuth value */ /* Q22 */
Word32 last_elevation_fx; /* MD smoothing in DTX - last Q elevation value */ /* Q22 */
Word32 last_true_azimuth_fx; /* MD smoothing in DTX- last true Q azimuth value */ /* Q22 */
Word32 last_true_elevation_fx; /* MD smoothing in DTX- last true Q elevation value */ /* Q22 */
- int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */
- int16_t ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */
- Word16 last_true_radius_fx; /* last true Q radius value */
+ Word16 ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */
+ Word16 ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */
+ Word16 last_true_radius_fx; /* last true Q radius value */
- int16_t ism_imp; /* ISM importance flag */
- int16_t ism_md_null_flag;
- int16_t ism_md_lowrate_flag;
+ Word16 ism_imp; /* ISM importance flag */
+ Word16 ism_md_null_flag;
+ Word16 ism_md_lowrate_flag;
Word32 q_azimuth_old_fx;
Word32 q_elevation_old_fx;
@@ -96,15 +96,15 @@ typedef struct
typedef struct stereo_dft_config_data_struct
{
- int16_t dmx_active;
- int16_t band_res;
- int16_t prm_res; /* Send prm every # DFT frames */
- 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;
- int16_t ada_wb_res_cod_mode; /* res_cod_mode for adaptive wide band residual coding */
+ Word16 dmx_active;
+ Word16 band_res;
+ Word16 prm_res; /* Send prm every # DFT frames */
+ Word16 res_pred_mode; /* mode : from 0 (off) to 1 (on) */
+ Word16 res_cod_mode; /* mode : from 0 (off) to 3 */
+ Word16 hybrid_itd_flag;
+ Word16 ada_wb_res_cod_mode; /* res_cod_mode for adaptive wide band residual coding */
- int16_t force_mono_transmission;
+ Word16 force_mono_transmission;
} STEREO_DFT_CONFIG_DATA, *STEREO_DFT_CONFIG_DATA_HANDLE;
@@ -115,20 +115,20 @@ typedef struct stereo_dft_config_data_struct
typedef struct
{
- uint8_t const bandLengthsTCX20[SMDCT_MAX_STEREO_BANDS_TCX20]; /* Length of a band in number of bins. Range is 4..160 */
- const int16_t bdnCnt_TCX20[4]; /* uppermost band for FB,SWB,WB,NB */
- uint8_t const bandLengthsTCX10[SMDCT_MAX_STEREO_BANDS_TCX10]; /* Length of a band in number of bins. Range is 2..80, always divisible by 2 */
- const int16_t bndCnt_TCX10[4]; /* uppermost band for FB,SWB,WB,NB */
+ UWord8 const bandLengthsTCX20[SMDCT_MAX_STEREO_BANDS_TCX20]; /* Length of a band in number of bins. Range is 4..160 */
+ const Word16 bdnCnt_TCX20[4]; /* uppermost band for FB,SWB,WB,NB */
+ UWord8 const bandLengthsTCX10[SMDCT_MAX_STEREO_BANDS_TCX10]; /* Length of a band in number of bins. Range is 2..80, always divisible by 2 */
+ const Word16 bndCnt_TCX10[4]; /* uppermost band for FB,SWB,WB,NB */
} MDCTStereoBands_config;
/* MDCT stereo frequency band structure */
typedef struct stereo_mdct_dec_band_parameters_struct
{
- int16_t sfbOffset[MAX_SFB + 1]; /* stereo frequency band start offsets */
- int16_t sfbCnt; /* number of stereo frequency bands */
- int16_t nBandsStereoCore; /* number of stereo frequency bands in the core */
- int16_t sfbIgfStart; /*index for first IGF band*/
+ Word16 sfbOffset[MAX_SFB + 1]; /* stereo frequency band start offsets */
+ Word16 sfbCnt; /* number of stereo frequency bands */
+ Word16 nBandsStereoCore; /* number of stereo frequency bands in the core */
+ Word16 sfbIgfStart; /*index for first IGF band*/
} STEREO_MDCT_BAND_PARAMETERS;
@@ -139,9 +139,9 @@ typedef struct stereo_mdct_dec_band_parameters_struct
typedef struct
{
- int16_t config_index;
- int16_t encoding_active; /* internal state specifying if actual encoding is active or only length evaluation is active */
- int32_t bit_count_estimate; /* uses 22Q10 fixed-point representation */
+ Word16 config_index;
+ Word16 encoding_active; /* internal state specifying if actual encoding is active or only length evaluation is active */
+ Word32 bit_count_estimate; /* uses 22Q10 fixed-point representation */
void *ac_handle;
} ECSQ_instance;
@@ -153,9 +153,9 @@ typedef struct
typedef struct ivas_dirac_config_data_struct
{
- int16_t enc_param_start_band;
- int16_t dec_param_estim;
- int16_t nbands;
+ Word16 enc_param_start_band;
+ Word16 dec_param_estim;
+ Word16 nbands;
} DIRAC_CONFIG_DATA, *DIRAC_CONFIG_DATA_HANDLE;
@@ -180,9 +180,9 @@ typedef struct ivas_band_coeffs_t
typedef struct ivas_band_coeffs_ind_t
{
- int16_t pred_index_re[IVAS_SPAR_MAX_CH - 1];
- int16_t drct_index_re[IVAS_SPAR_MAX_C_COEFF];
- int16_t decd_index_re[IVAS_SPAR_MAX_CH - 1];
+ Word16 pred_index_re[IVAS_SPAR_MAX_CH - 1];
+ Word16 drct_index_re[IVAS_SPAR_MAX_C_COEFF];
+ Word16 decd_index_re[IVAS_SPAR_MAX_CH - 1];
} ivas_band_coeffs_ind_t;
@@ -192,7 +192,7 @@ typedef struct ivas_spar_md_t
ivas_band_coeffs_ind_t band_coeffs_idx[IVAS_MAX_NUM_BANDS];
Word16 num_bands;
Word32 min_max_fx[2]; /*q28*/
- int16_t dtx_vad;
+ Word16 dtx_vad;
Word32 en_ratio_slow_fx[IVAS_MAX_NUM_BANDS];
Word32 ref_pow_slow_fx[IVAS_MAX_NUM_BANDS];
Word16 res_ind;
@@ -210,7 +210,7 @@ typedef struct ivas_quant_coeffs_t
{
Word32 min_fx; /* Q28 */
Word32 max_fx; /* Q28 */
- int16_t q_levels[2];
+ Word16 q_levels[2];
} ivas_quant_coeffs_t;
typedef struct ivas_quant_strat_t
@@ -224,23 +224,23 @@ typedef struct ivas_quant_strat_t
typedef struct ivas_spar_md_com_cfg
{
- int16_t max_freq_per_chan[IVAS_SPAR_MAX_CH];
- int16_t num_dmx_chans_per_band[IVAS_MAX_NUM_BANDS];
- int16_t num_decorr_per_band[IVAS_MAX_NUM_BANDS];
- int16_t active_w;
- int16_t remix_unmix_order;
+ Word16 max_freq_per_chan[IVAS_SPAR_MAX_CH];
+ Word16 num_dmx_chans_per_band[IVAS_MAX_NUM_BANDS];
+ Word16 num_decorr_per_band[IVAS_MAX_NUM_BANDS];
+ Word16 active_w;
+ Word16 remix_unmix_order;
ivas_quant_strat_t quant_strat[MAX_QUANT_STRATS];
- int16_t quant_strat_bits;
- int16_t nchan_transport;
- int16_t num_quant_strats;
- int16_t prior_strat;
- int16_t tgt_bits_per_blk;
- int16_t max_bits_per_blk;
- int16_t prev_quant_idx;
- int16_t agc_bits_ch_idx;
- int16_t planarCP;
- int16_t num_umx_chs;
- int16_t max_md_bits_spar;
+ Word16 quant_strat_bits;
+ Word16 nchan_transport;
+ Word16 num_quant_strats;
+ Word16 prior_strat;
+ Word16 tgt_bits_per_blk;
+ Word16 max_bits_per_blk;
+ Word16 prev_quant_idx;
+ Word16 agc_bits_ch_idx;
+ Word16 planarCP;
+ Word16 num_umx_chs;
+ Word16 max_md_bits_spar;
} ivas_spar_md_com_cfg;
@@ -248,26 +248,26 @@ typedef struct ivas_spar_md_com_cfg
/* arithmetic coder structures */
typedef struct ivas_cell_dim_t
{
- int16_t dim1;
- int16_t dim2;
+ Word16 dim1;
+ Word16 dim2;
} ivas_cell_dim_t;
typedef struct ivas_freq_models_t
{
- int16_t freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
- int16_t diff_freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
- int16_t vals[IVAS_MAX_QUANT_LEVELS];
- int16_t diff_vals[IVAS_MAX_QUANT_LEVELS];
- int16_t num_models;
- int16_t diff_num_models;
+ Word16 freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
+ Word16 diff_freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
+ Word16 vals[IVAS_MAX_QUANT_LEVELS];
+ Word16 diff_vals[IVAS_MAX_QUANT_LEVELS];
+ Word16 num_models;
+ Word16 diff_num_models;
} ivas_freq_models_t;
typedef struct ivas_huff_models_t
{
- int16_t code_book[IVAS_MAX_QUANT_LEVELS][3];
- int16_t diff_code_book[IVAS_MAX_QUANT_LEVELS][3];
+ Word16 code_book[IVAS_MAX_QUANT_LEVELS][3];
+ Word16 diff_code_book[IVAS_MAX_QUANT_LEVELS][3];
} ivas_huff_models_t;
@@ -275,22 +275,22 @@ typedef struct ivas_huff_models_t
/* Entropy coder structures */
typedef struct ivas_huffman_cfg_t
{
- const int16_t *codebook;
- int16_t min_len;
- int16_t max_len;
- int16_t sym_len;
+ const Word16 *codebook;
+ Word16 min_len;
+ Word16 max_len;
+ Word16 sym_len;
} ivas_huffman_cfg_t;
typedef struct ivas_arith_t
{
- int16_t dyn_model_bits;
- const int16_t *pFreq_model;
- const int16_t *pAlt_freq_models[IVAS_NUM_PROB_MODELS];
- const int16_t *vals;
- int16_t cum_freq[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
- int16_t range;
- int16_t num_models;
+ Word16 dyn_model_bits;
+ const Word16 *pFreq_model;
+ const Word16 *pAlt_freq_models[IVAS_NUM_PROB_MODELS];
+ const Word16 *vals;
+ Word16 cum_freq[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
+ Word16 range;
+ Word16 num_models;
Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; /* Q15 */
} ivas_arith_t;
@@ -338,18 +338,18 @@ typedef struct ivas_cov_smooth_state_t
Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word16 *q_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word16 *q_prior_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- int16_t prior_bank_idx;
+ Word16 prior_bank_idx;
Word32 *pSmoothing_factor_fx; /* Q31 */
- int16_t num_bins;
+ Word16 num_bins;
} ivas_cov_smooth_state_t;
typedef struct ivas_cov_smooth_cfg_t
{
Word32 max_update_rate_fx; /* Q31 */
- int16_t min_pool_size;
- int16_t max_bands;
- int16_t num_bins;
+ Word16 min_pool_size;
+ Word16 max_bands;
+ Word16 num_bins;
} ivas_cov_smooth_cfg_t;
@@ -357,20 +357,20 @@ typedef struct ivas_cov_smooth_cfg_t
/* SPAR bitrate constant table structure */
typedef struct ivas_spar_br_table_t
{
- int32_t ivas_total_brate;
- int16_t isPlanar;
- int16_t sba_order;
- int16_t bwidth;
- int16_t fpcs;
- int16_t nchan_transport;
+ Word32 ivas_total_brate;
+ Word16 isPlanar;
+ Word16 sba_order;
+ Word16 bwidth;
+ Word16 fpcs;
+ Word16 nchan_transport;
ivas_spar_pmx_strings_t dmx_str;
- int16_t active_w;
- int16_t tmode;
- int32_t core_brs[FOA_CHANNELS][3];
- int16_t q_lvls[MAX_QUANT_STRATS][NUM_MD_Q_COEFS_SET];
- int16_t td_ducking;
- int16_t agc_bits_ch_idx; /* 0-3, Indicates core-coder channel index from which AGC bits have been taken from*/
- int16_t usePlanarCoeff;
+ Word16 active_w;
+ Word16 tmode;
+ Word32 core_brs[FOA_CHANNELS][3];
+ Word16 q_lvls[MAX_QUANT_STRATS][NUM_MD_Q_COEFS_SET];
+ Word16 td_ducking;
+ Word16 agc_bits_ch_idx; /* 0-3, Indicates core-coder channel index from which AGC bits have been taken from*/
+ Word16 usePlanarCoeff;
} ivas_spar_br_table_t;
@@ -419,7 +419,7 @@ typedef struct ivas_masa_common_spatial_meta_struct
typedef struct ivas_omasa_meta_struct
{
- uint8_t num_dirs;
+ UWord8 num_dirs;
MASA_DIRECTIONAL_SPATIAL_META directional_meta[MASA_MAXIMUM_DIRECTIONS];
MASA_COMMON_SPATIAL_META common_meta;
@@ -435,16 +435,16 @@ typedef struct ivas_masa_metadata_frame_struct
typedef struct ivas_masa_config_struct
{
- uint16_t max_metadata_bits;
- int16_t block_grouping[5];
- int16_t band_grouping[MASA_FREQUENCY_BANDS + 1];
- uint8_t numCodingBands;
- uint8_t numTwoDirBands;
- uint8_t numberOfDirections;
- uint8_t joinedSubframes;
- uint8_t useCoherence;
- uint8_t coherencePresent;
- uint8_t mergeRatiosOverSubframes;
+ UWord16 max_metadata_bits;
+ Word16 block_grouping[5];
+ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1];
+ UWord8 numCodingBands;
+ UWord8 numTwoDirBands;
+ UWord8 numberOfDirections;
+ UWord8 joinedSubframes;
+ UWord8 useCoherence;
+ UWord8 coherencePresent;
+ UWord8 mergeRatiosOverSubframes;
IVAS_FORMAT input_ivas_format;
} MASA_CODEC_CONFIG;
@@ -456,11 +456,11 @@ typedef struct ivas_masa_config_struct
typedef struct
{
- int16_t nbands;
- int16_t nblocks;
- int16_t start_band;
- uint8_t inactiveBands;
- int16_t search_effort;
+ Word16 nbands;
+ Word16 nblocks;
+ Word16 start_band;
+ UWord8 inactiveBands;
+ Word16 search_effort;
MC_LS_SETUP mc_ls_setup;
} IVAS_METADATA_CONFIG;
@@ -615,10 +615,10 @@ typedef struct ivas_parametric_mc_metadata_struct
typedef struct ivas_lfe_window
{
- int16_t dct_len;
- int16_t fade_len;
- int16_t zero_pad_len;
- int16_t full_len;
+ Word16 dct_len;
+ Word16 fade_len;
+ Word16 zero_pad_len;
+ Word16 full_len;
const Word32 *pWindow_coeffs_fx;
@@ -626,14 +626,14 @@ typedef struct ivas_lfe_window
typedef struct ivas_lfe_freq_models
{
- uint16_t entropy_coder_model_fine_sg1[65];
- uint16_t entropy_coder_model_fine_sg2[33];
- uint16_t entropy_coder_model_fine_sg3[9];
- uint16_t entropy_coder_model_fine_sg4[3];
- uint16_t entropy_coder_model_coarse_sg1[33];
- uint16_t entropy_coder_model_coarse_sg2[17];
- uint16_t entropy_coder_model_coarse_sg3[5];
- uint16_t entropy_coder_model_coarse_sg4;
+ UWord16 entropy_coder_model_fine_sg1[65];
+ UWord16 entropy_coder_model_fine_sg2[33];
+ UWord16 entropy_coder_model_fine_sg3[9];
+ UWord16 entropy_coder_model_fine_sg4[3];
+ UWord16 entropy_coder_model_coarse_sg1[33];
+ UWord16 entropy_coder_model_coarse_sg2[17];
+ UWord16 entropy_coder_model_coarse_sg3[5];
+ UWord16 entropy_coder_model_coarse_sg4;
} ivas_lfe_freq_models;
diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com_fx.c
similarity index 99%
rename from lib_com/ivas_stereo_dft_com.c
rename to lib_com/ivas_stereo_dft_com_fx.c
index 1157fffcf9664bf918466201103087f011585b21..6d63bc6d1565160d0a3a3edb4f84b812077e882e 100644
--- a/lib_com/ivas_stereo_dft_com.c
+++ b/lib_com/ivas_stereo_dft_com_fx.c
@@ -35,8 +35,7 @@
#include "options.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
-#include "ivas_prot.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c
index b4fb6642953e1a7d7e2a713eaf572950992addf9..958781473910ff0f164ad50b9eb076fd3e0796e3 100644
--- a/lib_com/ivas_stereo_eclvq_com_fx.c
+++ b/lib_com/ivas_stereo_eclvq_com_fx.c
@@ -33,11 +33,10 @@
#include
#include "options.h"
#include
-#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_cnst.h"
#include
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
/*---------------------------------------------------------------
diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c
index 78a3c90caa265dec0fdbca7344d3d390b86763a2..8548797a4134d1805618080459a0f8ec38631269 100644
--- a/lib_com/ivas_stereo_ica_com_fx.c
+++ b/lib_com/ivas_stereo_ica_com_fx.c
@@ -36,9 +36,7 @@
#include "options.h"
#include "cnst.h"
#include "ivas_cnst.h"
-#include "prot.h"
#include "prot_fx.h"
-#include "ivas_prot.h"
#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_fx.c
similarity index 99%
rename from lib_com/ivas_stereo_mdct_bands_com.c
rename to lib_com/ivas_stereo_mdct_bands_com_fx.c
index b1750fd16a3148fa01e314412e5ae620b41c687f..43f2f16c7efc13d125717975cc63064027644d3d 100644
--- a/lib_com/ivas_stereo_mdct_bands_com.c
+++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c
@@ -35,11 +35,9 @@
#include "options.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
-#include "ivas_prot.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
/*-------------------------------------------------------------------*
diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c
similarity index 99%
rename from lib_com/ivas_stereo_mdct_stereo_com.c
rename to lib_com/ivas_stereo_mdct_stereo_com_fx.c
index dd94358af22c0e0694f43dd8c0c4dde5272edbf0..0a773169d07313155482bed27f0613b1cccb7a40 100644
--- a/lib_com/ivas_stereo_mdct_stereo_com.c
+++ b/lib_com/ivas_stereo_mdct_stereo_com_fx.c
@@ -33,7 +33,6 @@
#include
#include "options.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "wmc_auto.h"
#include
#include "prot_fx.h"
diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com_fx.c
similarity index 99%
rename from lib_com/ivas_stereo_psychlpc_com.c
rename to lib_com/ivas_stereo_psychlpc_com_fx.c
index 996b262db669270cf1f79828cfc99cd04d902c7c..df514089560c440dde31ff103bf87fd0b1ff740f 100644
--- a/lib_com/ivas_stereo_psychlpc_com.c
+++ b/lib_com/ivas_stereo_psychlpc_com_fx.c
@@ -33,9 +33,7 @@
#include
#include "options.h"
#include "ivas_rom_com.h"
-#include "ivas_prot.h"
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
#include
diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c
similarity index 99%
rename from lib_com/ivas_stereo_td_bit_alloc.c
rename to lib_com/ivas_stereo_td_bit_alloc_fx.c
index 14ab8131e196032a592316911b5a25ce4a34df8c..b54c1d3deb5ae86bf589fe0fd34d0e9359885734 100644
--- a/lib_com/ivas_stereo_td_bit_alloc.c
+++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c
@@ -35,12 +35,10 @@
#include "cnst.h"
#include "stat_enc.h"
#include "rom_com.h"
-#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "ivas_cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools_fx.c
similarity index 91%
rename from lib_com/ivas_tools.c
rename to lib_com/ivas_tools_fx.c
index ec3c30723a14064891ab567e01b2f2dcdb4fdf9a..ca8dec27615addfd578de77e9464538d8f21d519 100644
--- a/lib_com/ivas_tools.c
+++ b/lib_com/ivas_tools_fx.c
@@ -34,11 +34,9 @@
#include
#include "options.h"
#include
-#include "prot.h"
-#include "ivas_prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_rom_com.h"
-#include "prot_fx.h"
#include "ivas_prot_fx.h"
#define ANGLE_90_DEG_Q22 377487360
@@ -308,12 +306,6 @@ void v_add_inc_fx(
const Word16 N /* i : Vector length Q0*/
)
{
-#ifndef FIX_1107_VADDINC
- Word16 i;
- Word16 ix1 = 0;
- Word16 ix2 = 0;
- Word16 iy = 0;
-#else
Word16 i, ix1, ix2, iy;
/* The use of this function is currently always for the interleaved input format, */
@@ -336,7 +328,6 @@ void v_add_inc_fx(
ix1 = 0;
ix2 = 0;
iy = 0;
-#endif
move16();
move16();
move16();
@@ -607,41 +598,41 @@ void v_sub32_fx(
*---------------------------------------------------------------------*/
/*! r: the dot product x'*A*A'*x */
-Word32 dot_product_cholesky_fixed(
+Word64 dot_product_cholesky_fixed(
const Word32 *x, /* i : vector x Q31 - exp_x*/
const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/
- const Word16 N, /* i : vector & matrix size Q0*/
- const Word16 exp_x,
- const Word16 exp_A,
- Word16 *exp_sum )
+ const Word16 N /* i : vector & matrix size Q0*/
+)
{
Word16 i, j;
- Word32 suma, tmp_sum, mul;
+ Word64 suma, tmp_sum;
+ Word32 mul;
+ Word32 tmp;
const Word32 *pt_x, *pt_A;
- Word16 mul_exp, tmp_sum_exp;
- mul_exp = add( exp_x, exp_A );
pt_A = A;
suma = 0;
- move32();
+ move64();
+
FOR( i = 0; i < N; i++ )
{
tmp_sum = 0;
move32();
- tmp_sum_exp = 0;
- move16();
pt_x = x;
FOR( j = 0; j <= i; j++ )
{
- mul = Mpy_32_32( *pt_x++, *pt_A++ ); /*Q31 - (exp_x + exp_A)*/
- tmp_sum = BASOP_Util_Add_Mant32Exp( tmp_sum, tmp_sum_exp, mul, mul_exp, &tmp_sum_exp ); // exp_x+exp_A
+ mul = Mpy_32_32( *pt_x++, *pt_A++ );
+ tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) );
}
- suma = BASOP_Util_Add_Mant32Exp( suma, *exp_sum, Mpy_32_32( tmp_sum, tmp_sum ), shl( tmp_sum_exp, 1 ), exp_sum ); /*Q31 - exp_sum*/
+ tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow
+ tmp = W_extract_l( tmp_sum );
+ suma = W_mac_32_32( suma, tmp, tmp );
}
return suma;
}
+
void v_mult_mat_fixed(
Word32 *y, /* o : the product x*A Qx - guardbits*/
const Word32 *x, /* i : vector x Qx*/
@@ -941,7 +932,6 @@ Word16 matrix_product_mant_exp_fx(
Word16 out_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS];
Word16 *Zp_fx_e = out_e;
Word16 row, col;
- Word16 x_idx, y_idx;
Word64 temp;
Word16 temp_e;
Word16 prod_e = add( X_fx_e, Y_fx_e );
@@ -968,9 +958,7 @@ Word16 matrix_product_mant_exp_fx(
FOR( k = 0; k < rowsX; ++k )
{
- x_idx = k + i * rowsX;
- y_idx = k + j * rowsY;
- temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
+ temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e
}
/* Maximize accumulated value to 32-bit */
temp_e = W_norm( temp );
@@ -1008,9 +996,7 @@ Word16 matrix_product_mant_exp_fx(
move64();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = i + k * rowsX;
- y_idx = j + k * rowsY;
- temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
+ temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e
}
/* Maximize accumulated value to 32-bit */
temp_e = W_norm( temp );
@@ -1048,9 +1034,7 @@ Word16 matrix_product_mant_exp_fx(
move64();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = k + i * rowsX;
- y_idx = j + k * rowsY;
- temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
+ temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e
}
/* Maximize accumulated value to 32-bit */
temp_e = W_norm( temp );
@@ -1089,9 +1073,7 @@ Word16 matrix_product_mant_exp_fx(
move64();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = i + k * rowsX;
- y_idx = k + j * rowsY;
- temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
+ temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e
}
/* Maximize accumulated value to 32-bit */
temp_e = W_norm( temp );
@@ -1149,7 +1131,6 @@ Word16 matrix_product_fx(
)
{
Word16 i, j, k;
- Word16 x_idx, y_idx;
Word32 *Zp_fx = Z_fx;
/* Processing */
@@ -1170,9 +1151,7 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < rowsX; ++k )
{
- x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/
+ ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Qx + Qy - 31*/
move32();
}
Zp_fx++;
@@ -1193,9 +1172,7 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/
+ ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/
move32();
}
Zp_fx++;
@@ -1216,9 +1193,7 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/
+ ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/
move32();
}
@@ -1241,9 +1216,7 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/
+ ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); /*Qx + Qy - 31*/
// TODO: overflow of Z_fx to be checked
move32();
}
@@ -1268,7 +1241,6 @@ Word16 matrix_product_q30_fx(
)
{
Word16 i, j, k;
- Word16 x_idx, y_idx;
Word32 *Zp_fx = Z_fx;
Word64 W_tmp;
@@ -1291,10 +1263,7 @@ Word16 matrix_product_q30_fx(
move64();
FOR( k = 0; k < rowsX; ++k )
{
- //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );
- x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56
+ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 ); /*Q62*/
( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/
@@ -1318,10 +1287,7 @@ Word16 matrix_product_q30_fx(
move64();
FOR( k = 0; k < colsX; ++k )
{
- //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) );
- x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56
+ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 ); /*Q62*/
( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/
@@ -1345,9 +1311,6 @@ Word16 matrix_product_q30_fx(
move64();
FOR( k = 0; k < colsX; ++k )
{
- //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) );
- x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
}
@@ -1374,10 +1337,7 @@ Word16 matrix_product_q30_fx(
move64();
FOR( k = 0; k < colsX; ++k )
{
- //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) );
- x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56
+ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 ); /*Q62*/
( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/
@@ -1410,7 +1370,6 @@ Word16 matrix_product_mant_exp(
Word16 *Zp_e = Z_e;
Word32 L_tmp;
Word16 tmp_e;
- Word16 x_idx, y_idx;
/* Processing */
test();
@@ -1432,11 +1391,8 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < rowsX; ++k )
{
- x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- //( *Zp ) += X[k + i * rowsX] * Y[k + j * rowsY];
- L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/
- tmp_e = add( X_e[x_idx], Y_e[y_idx] );
+ L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/
+ tmp_e = add( X_e[k + i * rowsX], Y_e[k + j * rowsY] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
move32();
@@ -1464,11 +1420,8 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[j + k * rowsY];
- L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/
- tmp_e = add( X_e[x_idx], Y_e[y_idx] );
+ L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/
+ tmp_e = add( X_e[i + k * rowsX], Y_e[j + k * rowsY] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
( *Zp_e ) = tmp_e;
@@ -1495,11 +1448,8 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- //( *Zp ) += X_fx[k + i * rowsX] * Y_fx[j + k * rowsY];
- L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/
- tmp_e = add( X_e[x_idx], Y_e[y_idx] );
+ L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/
+ tmp_e = add( X_e[k + i * rowsX], Y_e[j + k * rowsY] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
move32();
@@ -1529,11 +1479,8 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[k + j * rowsY];
- L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/
- tmp_e = add( X_e[x_idx], Y_e[y_idx] );
+ L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/
+ tmp_e = add( X_e[i + k * rowsX], Y_e[k + j * rowsY] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
move32();
@@ -1564,7 +1511,6 @@ Word16 matrix_diag_product_fx(
{
Word16 i, j;
Word32 *Zp = Z;
- Word16 tmp;
/* Processing */
IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
@@ -1577,8 +1523,7 @@ Word16 matrix_diag_product_fx(
{
FOR( i = 0; i < colsX; ++i )
{
- tmp = add( j, imult1616( i, rowsX ) );
- *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/
+ *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/
move32();
Zp++;
}
@@ -1609,6 +1554,98 @@ Word16 matrix_diag_product_fx(
return EXIT_SUCCESS;
}
+Word16 matrix_diag_product_fx_2(
+ const Word32 *X, /* i : left hand matrix Q31 - X_e*/
+ const Word16 X_e,
+ const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/
+ const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/
+ const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/
+ const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/
+ const Word16 *Y_e,
+ const Word16 entriesY, /* i : number of entries in the diagonal Q0*/
+ Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/
+ Word16 *Z_e )
+{
+ Word16 i, j;
+ Word32 *Zp = Z;
+ Word16 *Z_ep = Z_e;
+ Word16 tmp;
+ Word16 max_exp = -31;
+ move16();
+
+ /* Processing */
+ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
+ {
+ IF( NE_16( rowsX, entriesY ) )
+ {
+ return EXIT_FAILURE;
+ }
+ FOR( j = 0; j < entriesY; ++j )
+ {
+ FOR( i = 0; i < colsX; ++i )
+ {
+ tmp = j + i * rowsX; /*Q0*/
+ *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/
+ move32();
+ Zp++;
+ *( Z_ep ) = add( X_e, Y_e[j] );
+ move16();
+ max_exp = s_max( max_exp, *Z_ep ); // Find the max exp
+ Z_ep++;
+ }
+ }
+
+ Zp = Z;
+ Z_ep = Z_e;
+ FOR( j = 0; j < entriesY; ++j )
+ {
+ FOR( i = 0; i < colsX; ++i )
+ {
+ *Zp = L_shr( *Zp, sub( max_exp, *Z_ep ) );
+ *Z_ep = max_exp;
+ Zp++;
+ Z_ep++;
+ }
+ }
+ }
+ ELSE /* Regular case */
+ {
+ IF( NE_16( colsX, entriesY ) )
+ {
+ return EXIT_FAILURE;
+ }
+
+ FOR( j = 0; j < entriesY; ++j )
+ {
+ FOR( i = 0; i < rowsX; ++i )
+ {
+ *( Zp ) = Mpy_32_32( *( X ), Y[j] ); /*Q31 - (X_e + Y_e)*/
+ move32();
+ Zp++;
+ *( Z_ep ) = add( X_e, Y_e[j] );
+ move16();
+ max_exp = s_max( max_exp, *Z_ep ); // Find the max exp
+ Z_ep++;
+ X++;
+ }
+ }
+ Zp = Z;
+ Z_ep = Z_e;
+ FOR( j = 0; j < entriesY; ++j )
+ {
+ FOR( i = 0; i < rowsX; ++i )
+ {
+ *Zp = L_shr( *Zp, sub( max_exp, *Z_ep ) );
+ *Z_ep = max_exp;
+ Zp++;
+ Z_ep++;
+ }
+ }
+ }
+
+ return EXIT_SUCCESS;
+}
+
Word16 matrix_diag_product_fx_1(
const Word32 *X, /* i : left hand matrix Q31 - X_e*/
const Word16 *X_e,
@@ -1624,7 +1661,6 @@ Word16 matrix_diag_product_fx_1(
Word16 i, j;
Word32 *Zp = Z;
Word16 *Z_ep = Z_e;
- Word16 tmp;
/* Processing */
IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
@@ -1637,11 +1673,10 @@ Word16 matrix_diag_product_fx_1(
{
FOR( i = 0; i < colsX; ++i )
{
- tmp = add( j, imult1616( i, rowsX ) ); /*Q0*/
- *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/
+ *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/
move32();
Zp++;
- *( Z_ep ) = add( X_e[tmp], Y_e[j] );
+ *( Z_ep ) = add( X_e[j + i * rowsX], Y_e[j] );
move16();
Z_ep++;
}
@@ -1687,7 +1722,6 @@ Word16 diag_matrix_product_fx(
{
Word16 i, j;
Word32 *Zp = Z;
- Word16 tmp;
/* Processing */
IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
@@ -1700,8 +1734,7 @@ Word16 diag_matrix_product_fx(
{
FOR( j = 0; j < entriesY; ++j )
{
- tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/
- *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/
+ *( Zp ) = Mpy_32_32( X[i + j * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/
move32();
Zp++;
}
@@ -1747,7 +1780,6 @@ Word16 matrix_product_diag_fx(
{
Word16 j, k;
Word32 *Zp = Z;
- Word16 y_idx, x_idx;
/* Processing */
test();
@@ -1766,9 +1798,7 @@ Word16 matrix_product_diag_fx(
move32();
FOR( k = 0; k < rowsX; ++k )
{
- x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/
+ ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/
move32();
}
Zp++;
@@ -1786,9 +1816,7 @@ Word16 matrix_product_diag_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/
+ ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/
move32();
}
Zp++;
@@ -1808,9 +1836,7 @@ Word16 matrix_product_diag_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/
- y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/
+ ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/
move32();
}
@@ -1830,9 +1856,7 @@ Word16 matrix_product_diag_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/
- y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/
+ ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/
move32();
}
Zp++;
@@ -2724,7 +2748,7 @@ Word64 var_32_fx(
Word16 q /* q : q-factor for the array */
)
{
-
+ Word16 i;
Word64 mean, var;
mean = 0;
@@ -2732,14 +2756,14 @@ Word64 var_32_fx(
var = 0;
move64();
- FOR( int i = 0; i < len; i++ )
+ FOR( i = 0; i < len; i++ )
{
mean = W_add( mean, x[i] ); /*q*/
}
mean = mean / len; /* NOTE: No BASOP for 64 bit division q*/
- FOR( int i = 0; i < len; i++ )
+ FOR( i = 0; i < len; i++ )
{
var = W_add( var, Mpy_32_32( L_sub( x[i], W_extract_l( mean ) ), L_sub( x[i], W_extract_l( mean ) ) ) ); /*q + q - 31*/
}
diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det_fx.c
similarity index 99%
rename from lib_com/ivas_transient_det.c
rename to lib_com/ivas_transient_det_fx.c
index b5ea507eb4065efc85019a44e0eb8bc226428e45..3b9a8cfd7ebf1e22ec6513d4a5f5229e53c9d53d 100644
--- a/lib_com/ivas_transient_det.c
+++ b/lib_com/ivas_transient_det_fx.c
@@ -34,11 +34,9 @@
#include "options.h"
#include "math.h"
#include "wmc_auto.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "ivas_prot_fx.h"
-#include "prot_fx.h"
#include "ivas_stat_com.h"
/*------------------------------------------------------------------------------------------*
diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c
index e0871fa70124f1d3479f0d1801c8e71c503ce419..9fb2872711d553565e75f883d9ddeafaef19cd40 100644
--- a/lib_com/lag_wind.c
+++ b/lib_com/lag_wind.c
@@ -37,7 +37,6 @@
#include
#include
#include "options.h"
-#include "prot.h"
#include "prot_fx.h"
#include "cnst.h"
#include "rom_com.h"
diff --git a/lib_com/lerp.c b/lib_com/lerp.c
index bb33d9922c50b3f745edce408841d7671f56b12e..6f148057faa5dba000aa064e5e4ba169de6781ec 100644
--- a/lib_com/lerp.c
+++ b/lib_com/lerp.c
@@ -36,154 +36,25 @@
#include
#include "options.h"
-#include "prot.h"
#include "prot_fx.h"
#include "wmc_auto.h"
-
/*-------------------------------------------------------------*
* Local function prototypes
*-------------------------------------------------------------*/
-static void lerp_proc_flt( const float *f, float *f_out, const int16_t bufferNewSize, const int16_t bufferOldSize );
-
-
/*-------------------------------------------------------------*
* procedure lerp_flt() *
* *
* *
*-------------------------------------------------------------*/
-void lerp_flt(
- const float *f,
- float *f_out,
- const int16_t bufferNewSize,
- const int16_t bufferOldSize_inp )
-{
- float maxFac;
- int16_t bufferOldSize, tmpNewSize;
-
- maxFac = 507.0 / 128.0;
- bufferOldSize = bufferOldSize_inp;
-
- if ( (float) bufferNewSize / bufferOldSize > maxFac )
- {
- tmpNewSize = bufferOldSize * 2;
- while ( bufferNewSize > bufferOldSize )
- {
- if ( (float) bufferNewSize / bufferOldSize <= maxFac )
- {
- tmpNewSize = bufferNewSize;
- }
-
- lerp_proc_flt( f, f_out, tmpNewSize, bufferOldSize );
-
- f = f_out;
- bufferOldSize = tmpNewSize;
- tmpNewSize *= 2;
- }
- }
- else if ( (float) bufferOldSize / bufferNewSize > maxFac )
- {
- tmpNewSize = bufferOldSize / 2;
- while ( bufferNewSize < bufferOldSize )
- {
- if ( (float) bufferOldSize / bufferNewSize <= maxFac )
- {
- tmpNewSize = bufferNewSize;
- }
-
- lerp_proc_flt( f, f_out, tmpNewSize, bufferOldSize );
-
- f = f_out;
- bufferOldSize = tmpNewSize;
- tmpNewSize /= 2;
- }
- }
- else
- {
- lerp_proc_flt( f, f_out, bufferNewSize, bufferOldSize );
- }
-
- return;
-}
-
/*-------------------------------------------------------------*
* procedure lerp_proc_flt() *
* *
* *
*-------------------------------------------------------------*/
-static void lerp_proc_flt(
- const float *f,
- float *f_out,
- const int16_t bufferNewSize,
- const int16_t bufferOldSize )
-{
- int16_t i, idx;
- float pos, shift, diff;
- float buf[2 * L_FRAME_MAX];
- Word16 tmp;
-
- if ( bufferNewSize == bufferOldSize )
- {
- mvr2r( f, buf, bufferNewSize );
- mvr2r( buf, f_out, bufferNewSize );
- return;
- }
-
- /* Using the basop code to avoid reading beyond end of input for bufferOldSize=320, bufferNewSize=640 */
- tmp = div_s( bufferOldSize, shl( bufferNewSize, 4 ) );
- shift = (float) ( L_shl( L_deposit_l( tmp ), 4 - 15 + 16 ) ) / 65536.0f;
- pos = 0.5f * shift - 0.5f;
-
- if ( shift < 0.3f )
- {
- pos = pos - 0.13f;
- }
-
- /* first point of interpolation */
- if ( pos < 0 )
- {
- buf[0] = f[0] + pos * ( f[1] - f[0] );
- }
- else
- {
- idx = (int16_t) pos;
- diff = pos - idx;
- buf[0] = f[idx] + diff * ( f[idx + 1] - f[idx] );
- }
-
- pos += shift;
-
- for ( i = 1; i < bufferNewSize - 1; i++ )
- {
- idx = (int16_t) pos;
- diff = pos - idx;
-
- buf[i] = f[idx] + diff * ( f[idx + 1] - f[idx] );
- pos += shift;
- }
-
-
- /* last point */
- idx = (int16_t) pos;
-
- if ( pos > bufferOldSize - 1 )
- {
- idx = bufferOldSize - 2;
- }
-
- diff = pos - idx;
-
- buf[bufferNewSize - 1] = f[idx] + diff * ( f[idx + 1] - f[idx] );
-
- mvr2r( buf, f_out, bufferNewSize );
-
- return;
-}
-
-
/*-------------------------------------------------------------*
* Local constants
*-------------------------------------------------------------*/
@@ -430,7 +301,7 @@ static void lerp_proc32( Word32 *f /*Qx*/, Word32 *f_out /*Qx*/, Word16 bufferNe
{
diff = sub( 16384 /*0.5f Q15*/, diff ); /*Q15*/
}
- *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) ); /*Qx*/
+ *ptr++ = L_add_sat( f[idx], L_sub( Mpy_32_16_1( f[idx + 1], diff ), Mpy_32_16_1( f[idx], diff ) ) ); /*Qx*/
move32();
pos = L_add( pos, shift ); /*Q16*/
idx = extract_h( pos );
@@ -485,10 +356,6 @@ void L_lerp_fx( Word32 *f /*q*/, Word32 *f_out /*q*/, Word16 bufferNewSize /*Q0*
f[ind] = L_shr( f[ind], guard_bits ); /*Q(guard_bits)*/
move32();
}
-#ifndef MSAN_FIX
- FOR( Word16 ind = 0; ind < bufferNewSize; ind++ )
- f_out[ind] = L_shr( f_out[ind], guard_bits );
-#endif
}
IF( GT_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) )
diff --git a/lib_com/limit_t0.c b/lib_com/limit_t0.c
deleted file mode 100644
index d49cad28376c7dd239a9bcd7634582d235a1f225..0000000000000000000000000000000000000000
--- a/lib_com/limit_t0.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------*
- * Local constants
- *-------------------------------------------------*/
-
-#define LIMIT_PIT_REL_LOWER 2 /* delta interval to extend pitch coding in relative Q */
-#define LIMIT_PIT_REL_UPPER 0
-
-/*-------------------------------------------------*
- * limit_T0()
- *
- * Close-loop pitch lag search limitation
- *-------------------------------------------------*/
-
-void limit_T0(
- const int16_t L_frame, /* i : length of the frame */
- const int16_t delta, /* i : Half the close-loop searched interval */
- const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */
- const int16_t limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */
- const int16_t T0, /* i : rough pitch estimate around which the search is done */
- const int16_t T0_frac, /* i : pitch estimate fractional part */
- int16_t *T0_min, /* o : lower pitch limit */
- int16_t *T0_max /* o : higher pitch limit */
-)
-{
- int16_t delta2, T1;
- int16_t pit_min, pit_max;
-
- if ( limit_flag == 0 ) /* restrained Q limits */
- {
- /* set limits */
- if ( L_frame == L_FRAME )
- {
- pit_max = PIT_MAX;
- pit_min = PIT_MIN;
- }
- else /* L_frame == L_FRAME16k */
- {
- pit_max = PIT16k_MAX;
- pit_min = PIT16k_MIN;
- }
-
- delta2 = 2 * delta - 1;
-
- T1 = T0;
- if ( T0_frac >= 2 )
- {
- T1++;
- }
- *T0_min = T1 - delta;
-
- if ( *T0_min < pit_min )
- {
- *T0_min = pit_min;
- }
- *T0_max = *T0_min + delta2;
-
- if ( *T0_max > pit_max )
- {
- *T0_max = pit_max;
- *T0_min = *T0_max - delta2;
- }
- }
- else /* extended Q limits */
- {
-
- /* set limits */
- if ( L_frame == L_FRAME )
- {
- pit_max = PIT_MAX;
- pit_min = PIT_MIN_EXTEND;
-
- if ( limit_flag == 2 )
- {
- pit_min = PIT_MIN_DOUBLEEXTEND;
- }
- }
- else /* L_frame == L_FRAME16k */
- {
- pit_max = PIT16k_MAX;
- pit_min = PIT16k_MIN_EXTEND;
- }
-
- delta2 = 2 * delta - 1;
-
- T1 = T0;
- if ( T0_frac >= 2 )
- {
- T1++;
- }
- *T0_min = T1 - delta;
-
- if ( pit_flag == 0 )
- {
- /* subframes with absolute search: keep Q range */
- if ( *T0_min < pit_min )
- {
- *T0_min = pit_min;
- }
- *T0_max = *T0_min + delta2;
-
- if ( *T0_max > pit_max )
- {
- *T0_max = pit_max;
- *T0_min = *T0_max - delta2;
- }
- }
- else
- {
- /* subframes with relative search: extend Q range */
- if ( *T0_min < pit_min - LIMIT_PIT_REL_LOWER )
- {
- *T0_min = pit_min - LIMIT_PIT_REL_LOWER;
- }
-
- if ( *T0_min < L_INTERPOL )
- {
- *T0_min = L_INTERPOL;
- }
- *T0_max = *T0_min + delta2;
-
- if ( *T0_max > pit_max + LIMIT_PIT_REL_UPPER )
- {
- *T0_max = pit_max + LIMIT_PIT_REL_UPPER;
- *T0_min = *T0_max - delta2;
- }
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------*
- * Routine limit_T0_voiced_ivas()
- *
- * Close-loop pitch lag search limitation
- *-------------------------------------------------*/
-
-void limit_T0_voiced_ivas(
- const int16_t nbits,
- const int16_t res,
- const int16_t T0, /* i : rough pitch estimate around which the search is done */
- const int16_t T0_frac, /* i : pitch estimate fractional part */
- const int16_t T0_res, /* i : pitch resolution */
- int16_t *T0_min, /* o : lower pitch limit */
- int16_t *T0_min_frac, /* o : lower pitch limit */
- int16_t *T0_max, /* o : higher pitch limit */
- int16_t *T0_max_frac, /* o : higher pitch limit */
- const int16_t pit_min, /* i : Minimum pitch lag */
- const int16_t pit_max /* i : Maximum pitch lag */
-)
-{
- int16_t T1, temp1, temp2;
-
- /* Mid-point */
- T1 = T0;
- if ( ( T0_res > 1 ) && ( T0_frac >= ( T0_res >> 1 ) ) )
- {
- T1++;
- }
-
- /* Lower-bound */
- temp1 = ( T1 * res ) - ( 1 << ( nbits - 1 ) );
- temp2 = temp1 / res;
- *T0_min = temp2;
- *T0_min_frac = temp1 - temp2 * res;
- if ( *T0_min < pit_min )
- {
- *T0_min = pit_min;
- *T0_min_frac = 0;
- }
-
- /* Higher-bound */
- temp1 = ( *T0_min * res ) + *T0_min_frac + ( 1 << nbits ) - 1;
- temp2 = temp1 / res;
- *T0_max = temp2;
- *T0_max_frac = temp1 - temp2 * res;
- if ( *T0_max > pit_max )
- {
- *T0_max = pit_max;
- *T0_max_frac = res - 1;
- temp1 = ( *T0_max * res ) + *T0_max_frac - ( 1 << nbits ) + 1;
- temp2 = temp1 / res;
- *T0_min = temp2;
- *T0_min_frac = temp1 - temp2 * res;
- }
-
- return;
-}
diff --git a/lib_com/longarith.c b/lib_com/longarith.c
index 66c5dd15ef0e35eac14d866e775ae82f56560561..72a763de3dc933db4fae6d7de78b0893b436a2c9 100644
--- a/lib_com/longarith.c
+++ b/lib_com/longarith.c
@@ -37,10 +37,9 @@
#include
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx.h"
/*-------------------------------------------------------------------*
@@ -53,27 +52,27 @@
*--------------------------------------------------------------------*/
void longadd(
- uint16_t a[], /* i/o: vector of the length lena */
- const uint16_t b[], /* i/o: vector of the length lenb */
- const int16_t lena, /* i/o: length of vector a[] */
- const int16_t lenb /* i/o: length of vector b[] */
+ UWord16 a[], /* i/o: vector of the length lena */
+ const UWord16 b[], /* i/o: vector of the length lenb */
+ const Word16 lena, /* i/o: length of vector a[] */
+ const Word16 lenb /* i/o: length of vector b[] */
)
{
- int16_t h;
- int32_t carry = 0;
+ Word16 h;
+ Word32 carry = 0;
assert( lena >= lenb );
for ( h = 0; h < lenb; h++ )
{
carry += ( (uint32_t) a[h] ) + ( (uint32_t) b[h] );
- a[h] = (uint16_t) carry;
+ a[h] = (UWord16) carry;
carry = carry >> 16;
}
for ( ; h < lena; h++ )
{
carry = ( (uint32_t) a[h] ) + carry;
- a[h] = (uint16_t) carry;
+ a[h] = (UWord16) carry;
carry = carry >> 16;
}
@@ -92,14 +91,14 @@ void longadd(
*--------------------------------------------------------------------*/
void longshiftright(
- uint16_t a[], /* i : vector of the length lena */
- const int16_t b, /* i : number of bit positions to shift right */
- uint16_t d[], /* o : vector of the length lend */
- int16_t lena, /* i : length of vector a[] */
- const int16_t lend /* i : length of vector d[] */
+ UWord16 a[], /* i : vector of the length lena */
+ const Word16 b, /* i : number of bit positions to shift right */
+ UWord16 d[], /* o : vector of the length lend */
+ Word16 lena, /* i : length of vector a[] */
+ const Word16 lend /* i : length of vector d[] */
)
{
- int16_t intb, fracb, fracb_u, k;
+ Word16 intb, fracb, fracb_u, k;
intb = b >> 4;
@@ -165,16 +164,16 @@ void longshr(
*--------------------------------------------------------------------*/
void longshiftleft(
- const uint16_t a[], /* i : vector of the length len */
- const int16_t b, /* i : number of bit positions to shift left */
- uint16_t d[], /* o : vector of the length len */
- const int16_t len /* i : length of vector a[] and d[] */
+ const UWord16 a[], /* i : vector of the length len */
+ const Word16 b, /* i : number of bit positions to shift left */
+ UWord16 d[], /* o : vector of the length len */
+ const Word16 len /* i : length of vector a[] and d[] */
)
{
- int16_t intb; /* integer part of b */
- int16_t fracb; /* shift left value for all upper words a[k] */
- int16_t fracb_l; /* shift right value for all lower words a[k-1] */
- int16_t k = len - 1;
+ Word16 intb; /* integer part of b */
+ Word16 fracb; /* shift left value for all upper words a[k] */
+ Word16 fracb_l; /* shift right value for all lower words a[k-1] */
+ Word16 k = len - 1;
intb = b >> 4;
fracb = b & 0xF;
diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c
index 9958b9d5fdef77ec8782e1aaf261baa60b7111b0..e51d2807b10162a20e29b17dca29ab55a8e7c13a 100644
--- a/lib_com/low_rate_band_att_fx.c
+++ b/lib_com/low_rate_band_att_fx.c
@@ -75,15 +75,11 @@ void ivas_fine_gain_pred_fx(
L_tmp = L_shl( xx, exp ); /*2*(15-shift)+exp */
exp = sub( 31, add( exp, sub( 30, shl( shift, 1 ) ) ) );
L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */
-#ifndef FIX_ISSUE_987
- Mpy_32_16_ss( L_tmp, ivas_fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
-#else
Word16 norm = norm_s( bw );
Word16 tmp1, tmp_exp = sub( 15, norm );
tmp1 = Sqrt16( shl( bw, norm ), &tmp_exp );
tmp1 = shr( tmp1, sub( sub( 15, tmp_exp ), Q11 ) );
Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
-#endif
gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */
test();
diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c
index ef6c0b0ffead8ab00b4b27b1a996bb5834167dbf..bde05b4f4ebc1d9ab7a4ac99776af5f25b97036d 100644
--- a/lib_com/lpc_tools_fx.c
+++ b/lib_com/lpc_tools_fx.c
@@ -1210,6 +1210,91 @@ Word16 E_LPC_lsp_unweight(
return 0;
}
+/*
+ * E_LPC_schur_ivas
+ *
+ * Parameters:
+ * R I: Rh[M+1] Vector of autocorrelations (msb)
+ * reflCoeff O: rc[M] Reflection coefficients. Q15
+ * epsP O: error vector
+ *
+ * Function:
+ * Schur algorithm to compute
+ * the LPC parameters from the autocorrelations of speech.
+ *
+ * Returns:
+ * void
+ */
+Word32 E_LPC_schur_ivas( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, const Word16 m )
+{
+ Word16 i, j, temp16, mMi, s;
+ Word32 g0[M], *g1, tmp32;
+ const Word32 min_epsP = 1; /* > 0.01f*2^27/2^30 */
+ Word32 tmp_epsP;
+
+ s = getScaleFactor32( r, add( m, 1 ) );
+ IF( s != 0 )
+ {
+ scale_sig32( r, add( m, 1 ), s ); /* scale in-place */
+ }
+
+ g1 = r;
+ Copy32( r + 1, g0, m );
+
+ /* compute g0[0]/g1[0], where g0[0] < g1[0] */
+ temp16 = negate( divide3232( g0[0], g1[0] ) );
+ reflCoeff[0] = temp16;
+ move16();
+ // epsP[0] = r[0];
+ move32();
+
+
+ FOR( i = 0; i < m; i++ )
+ {
+ /* g1[0] = g0[0]*temp16 + g1[0]; */
+ tmp32 = Mpy_32_16_1( g0[0], temp16 );
+ g1[0] = L_add( g1[0], tmp32 );
+ move32();
+
+ mMi = sub( m, i );
+ FOR( j = 1; j < mMi; j++ )
+ {
+ /* g0[j-1] = g0[j] + g1[j]*temp16;
+ g1[j] = g0[j]*temp16 + g1[j]; */
+ g0[j - 1] = L_add( g0[j], Mpy_32_16_1( g1[j], temp16 ) );
+ move32();
+ g1[j] = L_add( g1[j], Mpy_32_16_1( g0[j], temp16 ) );
+ move32();
+ }
+ temp16 = negate( divide3232( g0[0], g1[0] ) );
+ reflCoeff[i + 1] = temp16;
+ move16();
+
+ /* Prediction errors */
+ tmp_epsP = L_shr( g1[0], s );
+ if ( tmp_epsP <= 0 )
+ {
+ tmp_epsP = min_epsP;
+ move32();
+ }
+ // epsP[i + 1] = tmp_epsP;
+ move32();
+ }
+
+ /* epsP[i+1] = g0[0]*temp16 + g1[0]; */
+ tmp_epsP = L_add( g1[0], Mpy_32_16_1( g0[0], temp16 ) );
+ tmp_epsP = L_shr( tmp_epsP, s );
+ if ( tmp_epsP <= 0 )
+ {
+ tmp_epsP = min_epsP;
+ move32();
+ }
+
+ /* prediction gain = divide3232(L_shr(epsP[0], PRED_GAIN_E), g1[0]); */
+
+
+ return g1[0];
+}
/*
* E_LPC_schur
diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c
index 6292630af70ea7d15bd23afe34d9148ccc50db9d..33de5d9ac09d01ac656426a142cbec602cb610c9 100644
--- a/lib_com/lsf_dec_bfi_fx.c
+++ b/lib_com/lsf_dec_bfi_fx.c
@@ -36,7 +36,7 @@ void lsf_dec_bfi(
const Word16 Last_GSC_pit_band_idx,
const Word16 Opt_AMR_WB, /* i : IO flag */
const Word8 tcxonly,
- const short bwidth /* i: coded bandwidth */
+ const Word16 bwidth /* i: coded bandwidth */
)
{
Word16 i;
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index 08e74b9b70f054c4fe9a9dd5edc642707c1a92b5..5f0b3b57b404d1ade2874fcc232fe4e9e245f9bd 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -604,7 +604,6 @@ Word16 lpc2lsp_fx(
return ( 1 );
}
-#ifdef FIX_ISSUE_1165
/*===================================================================*/
/* FUNCTION : lpc2lsp_ivas_fx () */
/*-------------------------------------------------------------------*/
@@ -749,7 +748,6 @@ Word16 lpc2lsp_ivas_fx(
return ( 1 );
}
-#endif
/*===================================================================*/
/* FUNCTION : lsp2lpc_fx () */
@@ -3046,11 +3044,11 @@ void lsf_syn_mem_backup_ivas_fx(
/* back-up memories */
FOR( i = 0; i < M; i++ )
{
- mem_syn_bck[i] = hLPDmem->mem_syn[i]; // Q: ( 15 - st_fx->hLPDmem->e_mem_syn )
+ mem_syn_bck[i] = hLPDmem->mem_syn[i]; // Q( st_fx->hLPDmem->q_mem_syn )
move16();
}
- *mem_w0_bck = hLPDmem->mem_w0; // ( 15 - st_fx->hLPDmem->e_mem_syn )
+ *mem_w0_bck = hLPDmem->mem_w0; // Q( st_fx->hLPDmem->q_mem_syn )
move16();
@@ -3265,12 +3263,12 @@ void lsf_syn_mem_restore_ivas_fx(
}
/* restoring memories */
- hLPDmem->mem_w0 = mem_w0_bck; // Q(15 - st_fx->hLPDmem->e_mem_syn )
+ hLPDmem->mem_w0 = mem_w0_bck; // Q( st_fx->hLPDmem->q_mem_syn )
move16();
FOR( i = 0; i < M; i++ )
{
- hLPDmem->mem_syn[i] = mem_syn_bck[i]; // Q(15 - st_fx->hLPDmem->e_mem_syn )
+ hLPDmem->mem_syn[i] = mem_syn_bck[i]; // Q( st_fx->hLPDmem->q_mem_syn )
move16();
}
diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c
index 61ead2bf2a75118ce2399146e065fd243fae0077..4f493cacde1c222cba29c4859e08beb17776da29 100644
--- a/lib_com/lsp_conv_poly_fx.c
+++ b/lib_com/lsp_conv_poly_fx.c
@@ -6,10 +6,9 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/*-------------------------------------------------------------------*
* Local constants
diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c
index 4af93522dd07e3c4ce6d92e13e36644fc040c642..10e64a57deb9efbc548a2416db10d1ec550d66cf 100644
--- a/lib_com/modif_fs.c
+++ b/lib_com/modif_fs.c
@@ -38,13 +38,13 @@
#include "options.h"
#include
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
-void Interpolate_allpass_steep_32(
+/* IVAS 32-bit variant */
+void Interpolate_allpass_steep_fx32(
const Word32 *in_fx, /* i : input array of size N Qx */
Word32 *mem_fx, /* i/o: memory Qx */
const Word16 N, /* i : number of input samples */
@@ -102,6 +102,8 @@ void Interpolate_allpass_steep_32(
return;
}
+
+/* IVAS 32-bit variant */
void Decimate_allpass_steep_fx32(
const Word32 *in, /* i : input array of size N Qx */
Word32 *mem, /* i/o: memory Qx */
@@ -115,6 +117,22 @@ void Decimate_allpass_steep_fx32(
/* upper allpass filter chain */
FOR( k = 0; k < N / 2; k++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx
+ move32();
+ mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx
+ move32();
+
+ temp[1] = Madd_32_16( mem[1], temp[0], AP1_STEEP_FX[1] ); // Qx
+ move32();
+ mem[1] = Msub_32_16( temp[0], temp[1], AP1_STEEP_FX[1] ); // Qx
+ move32();
+
+ out[k] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx
move32();
mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx
@@ -129,17 +147,31 @@ void Decimate_allpass_steep_fx32(
move32();
mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
}
/* lower allpass filter chain */
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx
move32();
mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
/* for better performance, unroll this loop */
FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx
move32();
/*if ( fabs( temp[n] ) < 1e-12 )
@@ -148,26 +180,48 @@ void Decimate_allpass_steep_fx32(
}*/
mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
}
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+
+ mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
move32();
mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx
move32();
FOR( k = 1; k < N / 2; k++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx
move32();
mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
/* for better performance, unroll this loop */
FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx
move32();
/*if ( fabs( temp[n] ) < 1e-12 )
@@ -176,12 +230,20 @@ void Decimate_allpass_steep_fx32(
}*/
mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
}
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
move32();
mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx
move32();
}
@@ -192,7 +254,9 @@ void Decimate_allpass_steep_fx32(
return;
}
-void interpolate_3_over_2_allpass_32(
+
+/* IVAS 32-bit variant */
+void interpolate_3_over_2_allpass_fx32(
const Word32 *input, /* i : input signal Qx*/
const Word16 len, /* i : number of input samples */
Word32 *out, /* o : output signal Qx*/
@@ -211,12 +275,21 @@ void interpolate_3_over_2_allpass_32(
FOR( i = 0; i < len; i++ )
{
/* Upper branch */
+#ifdef OPT_STEREO_32KBPS_V1
+ Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx
move32();
Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx
move32();
mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
mem[1] = Vu[0]; // Qx
move32();
@@ -226,12 +299,21 @@ void interpolate_3_over_2_allpass_32(
move32();
/* Middle branch */
+#ifdef OPT_STEREO_32KBPS_V1
+ Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx
move32();
Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx
move32();
mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
mem[4] = Vm[0]; // Qx
move32();
@@ -241,12 +323,21 @@ void interpolate_3_over_2_allpass_32(
move32();
/* Lower branch */
+#ifdef OPT_STEREO_32KBPS_V1
+ Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx
move32();
Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx
move32();
mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx
move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
mem[0] = input[i]; // Qx
move32();
@@ -265,10 +356,17 @@ void interpolate_3_over_2_allpass_32(
{
mem_temp = out1_buff[2 * i];
move32();
+#ifdef OPT_STEREO_32KBPS_V1
+ out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx
+ // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965
+ out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 );
+ // 0.614152f in Q15 -> 20125
+#else /* OPT_STEREO_32KBPS_V1 */
out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx
// 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965
out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) );
// 0.614152f in Q15 -> 20125
+#endif /* OPT_STEREO_32KBPS_V1 */
mem[10] = mem[11]; // Qx
move32();
mem[11] = mem[12]; // Qx
@@ -284,8 +382,8 @@ void interpolate_3_over_2_allpass_32(
return;
}
-
-void interpolate_3_over_1_allpass_32(
+/* IVAS 32-bit variant */
+void interpolate_3_over_1_allpass_fx32(
const Word32 *input, /* i : input signal Qx */
const Word16 len, /* i : number of input samples */
Word32 *out, /* o : output signal */
diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c
index 6079e5db5a5ef4c1a8b073b8a5c1ac8e450170ce..bcbff13d57bebe95c3159b1b75e34fdc517fad79 100644
--- a/lib_com/modif_fs_fx.c
+++ b/lib_com/modif_fs_fx.c
@@ -330,9 +330,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
Word16 sigOut_fx[], /* o : decimated signal Q0 */
const Word32 fout, /* i : frequency of output Q0 */
Word16 mem_fx[], /* i/o: filter memory Q0 */
- const Word16 nblp, /* i : flag indicating if NB low-pass is applied */
- Word16 *Q_new_inp, // TO be removed
- Word16 *mem_decim_size // TO be removed
+ const Word16 nblp /* i : flag indicating if NB low-pass is applied */
)
{
Word16 i;
@@ -364,17 +362,13 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
/*-------------------------------------------------------------------*
* Find the resampling configuration
*-------------------------------------------------------------------*/
- *Q_new_inp = 0;
- move16();
+
/* check if fin and fout are the same */
IF( EQ_32( fin, fout ) )
{
/* just copy the signal_fx and quit */
Copy( sigIn_fx, sigOut_fx, lg );
- *mem_decim_size = 0;
- *Q_new_inp = 0;
- move16();
- move16();
+
return lg;
}
ELSE
@@ -439,8 +433,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
}
mem_len = shl( filt_len, 1 );
- *mem_decim_size = mem_len;
- move16();
signal_fx = signal_tab_fx + 2 * L_FILT_MAX + sub( L_FRAME48k, add( mem_len, lg ) );
signal_ana_fx = signal_fx;
mem_len_ana = mem_len;
@@ -508,7 +500,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
}
/* interpolation */
- datastep = shr( div_s( shl( fac_den, 7 ), shl( fac_num, 10 ) ), 12 );
+ datastep = shr( div_s( shl( fac_den, 8 ), shl( fac_num, 11 ) ), 12 );
/* equivalent to 'datastep = fac_den % fac_num' */
temp_n = i_mult2( datastep, fac_num ); /*Q0*/
fracstep = sub( fac_den, temp_n );
@@ -550,9 +542,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = round_fx( L_shl( L_mult( sigOut_fx[i], num_den ), 1 ) ); /*Q0*/
- *Q_new_inp = -1;
- move16();
- move16();
}
}
ELSE
@@ -562,16 +551,17 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
test();
if ( GT_32( fin, 16000 ) && ( EQ_16( lg_out, L_FRAME ) || EQ_16( lg_out, L_FRAME16k ) || EQ_16( lg_out, 512 ) ) )
{
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
num_den = shl_o( num_den, 1, &Overflow );
- //*Q_new_inp = 2;
+#else
+ num_den = shl( num_den, 1 );
+#endif
}
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = mult_r( sigOut_fx[i], num_den ); /*Q0*/
move16();
}
- *Q_new_inp = -1;
- move16();
}
}
ELSE
@@ -579,13 +569,10 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
IF( EQ_16( fac_num, 8 ) )
{
num_den = 26214;
- move16();
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = mult_r( sigOut_fx[i], num_den ); /*Q-1*/
move16();
- *Q_new_inp = -2;
- move16();
}
}
ELSE
@@ -594,9 +581,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = round_fx( L_mac( L_deposit_h( sigOut_fx[i] ), sigOut_fx[i], num_den ) ); /*Q0*/
- *Q_new_inp = -1;
- move16();
- move16();
}
}
}
@@ -607,8 +591,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
{
sigOut_fx[i] = mult_r( sigOut_fx[i], 16384 );
move16(); /*Q-1*/
- *Q_new_inp = -2;
- move16();
}
}
/* update the filter memory */
diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c
index 34e2083b96bd5146f205f9dd6d3f91e3be14af53..12234a4c055664712312c284ce500a2a019c119a 100644
--- a/lib_com/mslvq_com.c
+++ b/lib_com/mslvq_com.c
@@ -38,10 +38,8 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h"
#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
/*-----------------------------------------------------------------*
@@ -76,10 +74,10 @@ static void make_offset_scale(
void create_offset(
UWord32 *offset_scale1,
UWord32 *offset_scale2,
- const int16_t mode,
- const int16_t prediction_flag )
+ const Word16 mode,
+ const Word16 prediction_flag )
{
- int16_t tmp, tmp1;
+ Word16 tmp, tmp1;
if ( prediction_flag == 0 )
{
diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c
index 14c9b6d975f6281f36c620fe66b88bfece809c52..cf2ad8a8a0df8a9294e4f0a13f57664441b19676 100644
--- a/lib_com/mslvq_com_fx.c
+++ b/lib_com/mslvq_com_fx.c
@@ -31,7 +31,6 @@
*******************************************************************************************************/
#include "options.h"
-#include "prot.h"
#include "prot_fx.h"
#include "ivas_cnst.h"
#include "stl.h"
@@ -122,9 +121,33 @@ void init_lvq_fx(
)
{
Word16 i, j;
+#ifdef OPT_STEREO_32KBPS_V1
+ Word16 k;
+#endif /* OPT_STEREO_32KBPS_V1 */
/* safety-net mode */
FOR( i = 0; i < MAX_NO_MODES; i++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) )
+ {
+ if ( ( no_lead_fx[i][j] <= 0 ) )
+ {
+ j = MAX_NO_SCALES;
+ }
+ }
+ no_scales[i][0] = k;
+ move16();
+
+ FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) )
+ {
+ if ( no_lead_fx[i][j] <= 0 )
+ {
+ j = MAX_NO_SCALES << 1;
+ }
+ }
+ no_scales[i][1] = k;
+ move16();
+#else /* OPT_STEREO_32KBPS_V1 */
j = 0;
move16();
test();
@@ -143,10 +166,35 @@ void init_lvq_fx(
}
no_scales[i][1] = sub( j, MAX_NO_SCALES );
move16();
+#endif /* OPT_STEREO_32KBPS_V1 */
}
/* predictive mode */
FOR( i = 0; i < MAX_NO_MODES_p; i++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) )
+ {
+
+ if ( ( no_lead_p_fx[i][j] <= 0 ) )
+ {
+ j = MAX_NO_SCALES;
+ }
+ }
+ no_scales_p[i][0] = k;
+ move16();
+
+ FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) )
+ {
+
+ if ( ( no_lead_p_fx[i][j] <= 0 ) )
+ {
+ j = MAX_NO_SCALES << 1;
+ }
+ }
+
+ no_scales_p[i][1] = k;
+ move16();
+#else /* OPT_STEREO_32KBPS_V1 */
j = 0;
move16();
WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_p_fx[i][j] > 0 ) )
@@ -165,6 +213,7 @@ void init_lvq_fx(
}
no_scales_p[i][1] = sub( j, MAX_NO_SCALES );
move16();
+#endif /* OPT_STEREO_32KBPS_V1 */
}
/* index offsets for each truncation */
init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p );
@@ -412,12 +461,10 @@ static Word16 decode_indexes_ivas_fx(
IF( index[i] < 0 )
{
set16_fx( x_lvq, 0, 2 * LATTICE_DIM );
-#ifdef MSAN_FIX
scales_mslvq[0] = 0;
move16();
scales_mslvq[1] = 0;
move16();
-#endif
index[i] = 0;
return 1;
}
@@ -442,10 +489,8 @@ static Word16 decode_indexes_ivas_fx(
FOR( i = 0; i < LATTICE_DIM; i++ )
{
x_lvq[i] = 0;
-#ifdef MSAN_FIX
scales_mslvq[0] = 0;
move16();
-#endif
}
}
ELSE
@@ -454,12 +499,10 @@ static Word16 decode_indexes_ivas_fx(
{
/* safety check in case of bit errors */
set16_fx( x_lvq, 0, 2 * LATTICE_DIM );
-#ifdef MSAN_FIX
scales_mslvq[0] = 0;
move16();
scales_mslvq[1] = 0;
move16();
-#endif
return 1;
}
@@ -500,10 +543,8 @@ static Word16 decode_indexes_ivas_fx(
x_lvq[i] = 0;
move16();
}
-#ifdef MSAN_FIX
scales_mslvq[1] = 0;
move16();
-#endif
}
ELSE
{
diff --git a/lib_com/options.h b/lib_com/options.h
index f8769130889ed18fbb4d35a5319563808664d6dc..2133b86ac48a78abced5458bde234e1bf1123cea 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -67,110 +67,12 @@
#define BASOP_NOGLOB_DECLARE_LOCAL
#endif
-#define IVAS_FLOAT_FIXED
-#define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */
-#define MSAN_FIX
-#define ISM_DISABLE
-#define FIX_TMP_714
-#define BASOP_NOGLOB_TMP_715
-#define EVS_FUNC_MODIFIED
-//#define EVS_FLOAT_ENC
-#define IVAS_CNST
-#define REMOVE_IVAS_UNUSED_PARAMETERS_WARNING /*temporary operation on unused EVS parameters to remove warnings, these parameters will be used in IVAS */
-#define MOD_BIT_ALLOC_ROM_TABLE /* Just to highlight modification in bit allocation table and to ensure these modifications doesn't affect EVS modes*/
-#define SIMPLIFY_CODE_BE // Simplify synthesis loop
-#define CR_2109_to_2112_cd0_ce0 /* This is related to the CRs include in the 26.444 package of 21-12. Concerns lead_deindexing and */
-#define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */
-#define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */
-#define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/
-#define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */
-#define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX
-#define FIX_ISSUE_987
-#define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */
-#define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */
-#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */
-#define NONBE_IMPROVE_DIRAC_INTENSITY_PREC
-#define FIX_1103_OPT_L_NORM_ARR /* FhG: Optimize L_norm_arr(), avoid IF */
-#define FIX_1105_OPT_MINIMUM_SL /* FhG: Optimize minimum_s(), minimum_l(), avoid IF */
-#define FIX_1104_OPT_GETMINSCALEFAC /* FhG: Optimize get_min_scalefactor(), avoid IF */
-#define FIX_1106_SIMPLIFY_SET32FX /* FhG: simplify set32_fx() */
-#define FIX_1107_VADDINC /* FhG: Optimize v_add_inc_fx() for most frequent case */
-#define FIX_1009_OPT_PARAMMC_RENDER /* FhG: Optimize ivas_param_mc_dec_render_fx() */
-#define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */
-#define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */
-#define FIX_1127_IMPROVE_SBA_MLD /* Ittiam: Avoid saturation for DiRAC reference power */
-#define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/
-#define FIX_1133_IMPROVE_MC_MLD /* Ittiam: Correcting wrong updation of exponents in ivas_mc_paramupmix_param_est_enc_fx() */
-#define FIX_ISSUE_1122 /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */
-#define FIX_ISSUE_1125 /* Ittiam: Fix issue 1125: interfering talker flag not triggered on short test vector */
-#define FIX_1132_STACK_CORRUPTION /* Stack corruption issue due of extending index access*/
-#define FIX_ISSUE_1092 /* Ittiam: Fix for Issue 1092: BASOP asserts in stereo fx encoder for selection test inputs*/
-#define FIX_ISSUE_1135 /* Ittiam: Fix for Issue 1135: downmixing difference between float and fixed-point (DFT - stereo) */
-#define FIX_ISSUE_1148
-#define FIX_ISSUE_1147 /* Ittiam: Fix for issue 1147: Added saturation in DetectTnsFilt_fx.*/
-#define FIX_ISSUE_1150 /* Ittiam: Fix for Issue 1150: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from tcx_ltp_find_gain function*/
-#define FIX_ISSUE_1151 /* Ittiam: Fix for Issue 1151: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from sp_mus_classif_gmm_fx function*/
-#define FIX_ISSUE_1153 /* Ittiam: Fix for Issue 1153: Assertion error observed in stereo_dmx_evs_enc_fx from calc_poc_fx function*/
-#define FIX_ISSUE_1154 /* Ittiam: Fix for Issue 1154: Encoder crash for ParamMC 7.1 at 96kbps in ivas_param_mc_param_est_enc_fx() */
-#define FIX_ISSUE_1157 /* Ittiam: Fix for Issue 1157: Encoder crash for Stereo at 48/64kbps DTX on/off in kernel_switch_trafo_fx() */
-#define FIX_ISSUE_1152 /* Ittiam: Fix for issue 1152: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from find_tilt_fx function*/
-#define FIX_ISSUE_1156 /* Ittiam: Fix for Issue 1156: Encoder crash for Stereo at 32kbps in SWB_BWE_encoding_ivas_fx() */
-#define FIX_DISCLAIMER /* VA: Add disclaimer for external renderer + Add info about IVAS reference version (FLP issue 1225) */
-#define FIX_ISSUE_1167 /* Ittiam: Fix for Issue 1167: Encoder crash for OSBA ISM3SBA1 at 13.2 and 16.4 kbps in gauss_L2_ivas_fx() */
-#define FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC /* FhG: Reduce workload of binaural rendering: replace 1./tmp & sqrt by Isqrt32 */
-#define FIX_1113_OPT_DIRAC_BIN_REND /* FhG: Various optimizations to ivas_dirac_dec_binaual_functions.c */
-#define FIX_ISSUE_1187 /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/
-#define FIX_ISSUE_1186 /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */
-#define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */
-#define FIX_ISSUE_1185 /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/
-#define FIX_ISSUE_1209 /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/
-#define FIX_ISSUE_1218 /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
-#define FIX_ISSUE_1290 /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
-#define IVAS_ISSUE_1188_EVS_CRASH /* Ittiam: Fix for issue 1188: Issue due to ASAN */
-#define FIX_ISSUE_1155 /* Ittiam: Fix for issue 1155: Encoder crash for Stereo at 32kbps in PostShortTerm_ivas_enc_fx()*/
-#define FIX_1010_OPT_DIV /* FhG: SVD complexity optimizations (non-be) */
-#define FIX_1010_OPT_SINGLE_RESCALE /* FhG: SVD complexity optimizations (non-be) */
-#define FIX_1010_OPT_GIVENS /* FhG: SVD complexity optimizations (non-be) */
-#define FIX_1010_OPT_GIVENS_INV /* FhG: SVD complexity optimizations (non-be) */
-#define FIX_1010_OPT_NORM_NOSAT /* FhG: SVD complexity optimizations (non-be) */
-#define FIX_1010_OPT_SEC_SINGLE_RESCALE /* FhG: SVD complexity optimizations (non-be) */
-#define FIX_1072_SPEEDUP_matrixTransp2Mul_fx /* FhG: complexity optimization (non-be) */
-#define FIX_1072_REDUCE_DIVS /* FhG: complexity optimization (non-be) */
-#define FIX_ISSUE_1230 /* Ittiam: Fix for issue 1230: Basop Enc audible differences and distortion @16kbps */
-#define NONBE_1211_DTX_BR_SWITCHING /* VA: port float issue 1211: fix crash in MASA DTX bitrate switching */
-#define FIX_1189_GSC_IVAS_OMASA /* VA: Fix for issue 1189: Bitstream desynchornization due to reading/writing of the GSC_IVAS_mode parameter */
-#define NONBE_1273_ISM_METADATA_COUNTER /* VA: BASOP issue 1265, FLP issue 1273: fix counter overflow in ISM metadata encoder */
-#define NONBE_FIX_GSC_BSTR /* VA: issue 1264 FLP (1189 BASOP): Fix bitstream synchronization between encoder and decoder in ACELP GSC in OMASA */
-#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF /* FhG: fix for issue 1101: complexity of spar dec upmixer */
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
-#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS /* FhG: Defines 1.0f-weight variables, uses Madd operation instead of L_add_sat */
-#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS /* FhG: Splits single loop with IF-statements into two low-complex loops */
-#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_HQ_CONSTANTS /* FhG: IMPROVE PRECISION: Uses 1/6 and 1/20 in full-precise Q31 constants instead of Q15 */
-#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL /* FhG: Uses unique shift amount in each loop iteration */
-#define FIX_11_1_IVAS_SPAR_DEC_UPMIXER_SF_RND_COEFFS /* FhG ivas_spar_com.c: Zeroes very small negative coeffs via L_shr_r (was L_shr) */
-#define FIX_ISSUE_1237 /* VA: replacement of Copy_Scale_sig_16_32_DEPREC() that are doing 16 bits left shift by Copy_Scale_sig_16_32_no_sat() */
-#define FIX_ISSUE_1237_KEEP_EVS_BE /* VA: Fix to keep EVS bitexactness to 26.444 */
-#define FIX_ISSUE_1214 /* Ittiam: Fix for issue 1214: Energy leakage in IGF tiles for MDCT-stereo @64kbps SWB*/
-#define FIX_881_HILBERT_FILTER /* VA: improve the precision of the Hilbert filter to remove 2kHz unwanted tone */
-#define FIX_ISSUE_1245 /* Ittiam: Fix for issue 1245: Basop Encoder: Audible noise for silent Stereo input DTX on @24.4 kbps, @32 kbps*/
-#define FIX_ISSUE_1291 /* Ittiam: Wrong use of imult1616() in ACELP rescaling */
-#define FIX_920_IGF_INIT_ERROR /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */
-#define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */
-#define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */
-// #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
+//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */
+#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */
+#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/
+#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/
/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */
#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */
#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version */
-#define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
-#define FIX_ISSUE_1279 /* VA: correction of wrong scaling update */
-#define FIX_ISSUE_1247
-#define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
-#define FIX_1285_DECODER_CRASH
-#define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */
-#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS /* FhG: Minor WMOPS tuning, nonbe */
-#define FIX_1320_LOWRATE_ACELP
-#define FIX_1297_OVERFLOW /* VA: fixes issue with overflows in pre-processing */
-#define FIX_1298 /* VA: fix possible assert in gaus_enc */
-#define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */
-#define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */
#endif
diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c
index 180275d8fa5a74888eac160af018d1e3936fa3a1..0846c618be15583797a4c64ccbae74c7a21fa224 100644
--- a/lib_com/parameter_bitmaping_fx.c
+++ b/lib_com/parameter_bitmaping_fx.c
@@ -58,15 +58,15 @@ static Word16 FixedWidthEncoding( Word16 value, Word16 index )
void GetParameters(
ParamsBitMap const *paramsBitMap,
- const int16_t nArrayLength,
+ const Word16 nArrayLength,
void const *pParameter,
- int16_t **pStream,
- int16_t *pnSize,
- int16_t *pnBits )
+ Word16 **pStream,
+ Word16 *pnSize,
+ Word16 *pnBits )
{
- int16_t index;
- int16_t iParam, nParams;
- int16_t value;
+ Word16 index;
+ Word16 iParam, nParams;
+ Word16 value;
void const *pSubStruct;
assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pParameter != NULL ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( pnBits != NULL ) );
@@ -168,14 +168,14 @@ void GetParameters_fx(
void SetParameters(
ParamsBitMap const *paramsBitMap,
- const int16_t nArrayLength,
+ const Word16 nArrayLength,
void *pParameter,
- const int16_t **pStream,
- int16_t *pnSize )
+ const Word16 **pStream,
+ Word16 *pnSize )
{
- int16_t index;
- int16_t iParam, nParams;
- int16_t value;
+ Word16 index;
+ Word16 iParam, nParams;
+ Word16 value;
void *pSubStruct;
assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pParameter != NULL ) && ( pStream != NULL ) && ( pnSize != NULL ) );
diff --git a/lib_com/preemph.c b/lib_com/preemph.c
index 490a18aef187ffac1e65529de8eee2cbe3b3a3d1..9ebc0f72a81c39542312ff9e6bbd3d76b5a49197 100644
--- a/lib_com/preemph.c
+++ b/lib_com/preemph.c
@@ -36,7 +36,7 @@
#include
#include "options.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
/*-------------------------------------------------------------*
diff --git a/lib_com/prot.h b/lib_com/prot.h
deleted file mode 100644
index 16f4659a049c5ed94b4ab49b59571b7e5e3ff5a3..0000000000000000000000000000000000000000
--- a/lib_com/prot.h
+++ /dev/null
@@ -1,8339 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#ifndef PROT_H
-#define PROT_H
-
-#include
-#include
-#include
-#include "options.h"
-#include "typedef.h"
-#include "stat_enc.h"
-#include "stat_dec.h"
-#include "stat_com.h"
-#include "ivas_stat_com.h"
-#include "ivas_stat_enc.h"
-#include "ivas_stat_dec.h"
-#include "cnst.h"
-#include "stl.h"
-#include "ivas_error_utils.h"
-
-
-/*----------------------------------------------------------------------------------*
- * Prototypes of global macros
- *----------------------------------------------------------------------------------*/
-
-#ifndef min
-#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
-#endif
-
-#ifndef max
-#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
-#endif
-
-#ifndef TRUNC
-#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) )
-#endif
-
-#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f )
-#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) )
-
-#ifndef ABSVAL
-#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) )
-#endif
-
-#ifndef SQR
-#define SQR( a ) ( ( a ) * ( a ) )
-#endif
-
-#ifndef SWAP
-#define SWAP( a, b ) \
- { \
- tempr = ( a ); \
- ( a ) = ( b ); \
- ( b ) = tempr; \
- }
-#endif
-
-#ifndef swap
-#define swap( x, y, type ) \
- { \
- type u__p; \
- u__p = x; \
- x = y; \
- y = u__p; \
- }
-#endif
-
-#define set_max( a, b ) \
- { \
- if ( ( b ) > *a ) \
- { \
- *a = ( b ); \
- } \
- } /* If the first argument is already the highes or lowest, nothing is done. */
-#define set_min( a, b ) \
- { \
- if ( ( b ) < *a ) \
- { \
- *a = ( b ); \
- } \
- } /* Otherwise, the 2nd arg is stored at the address of the first arg. */
-
-
-/*----------------------------------------------------------------------------------*
- * MODE1 prototypes
- *----------------------------------------------------------------------------------*/
-
-/*! r: inverse square root of input value */
-float inv_sqrt(
- const float x /* i : input value */
-);
-
-/*! r: output random value */
-int16_t own_random(
- int16_t *seed /* i/o: random seed */
-);
-
-/*! r: sign of x (+1/-1) */
-float sign(
- const float x /* i : input value of x */
-);
-
-/*! r: logarithm2 of x */
-float log2_f(
- const float x /* i : input value of x */
-);
-
-int16_t norm_ul_float(
- uint32_t UL_var1 );
-
-/*! r: sum of all vector elements */
-int16_t sum_s(
- const int16_t *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-/*! r: sum of all vector elements */
-int32_t sum_l(
- const int32_t *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-/*! r: sum of all vector elements */
-float sum_f(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-/*! r: sum of all squared vector elements */
-float sum2_f(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-void set_c(
- int8_t y[], /* i/o: Vector to set */
- const int8_t a, /* i : Value to set the vector to */
- const int32_t N /* i : Length of the vector */
-);
-
-void set_s(
- int16_t y[], /* i/o: Vector to set */
- const int16_t a, /* i : Value to set the vector to */
- const int16_t N /* i : Lenght of the vector */
-);
-
-void set_l(
- int32_t y[], /* i/o: Vector to set */
- const int32_t a, /* i : Value to set the vector to */
- const int16_t N /* i : Length of the vector */
-);
-
-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 */
-);
-
-void set_zero_fx(
- Word32 *vec, /* o : input vector */
- const Word16 lvec /* i : length of the vector */
-);
-void set_zero2_fx(
- Word32 *vec, /* o : input vector */
- const Word32 lvec /* i : length of the vector */
-);
-void set16_zero_fx(
- Word16 *vec, /* o : input vector */
- const Word16 lvec /* i : length of the vector */
-);
-
-void set_zero(
- float *vec, /* o : input vector */
- const int16_t lvec /* i : length of the vector */
-);
-
-void mvr2r(
- const float x[], /* i : input vector */
- float y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-void mvs2s(
- const int16_t x[], /* i : input vector */
- int16_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-uint32_t mvr2s(
- const float x[], /* i : input vector */
- int16_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-void mvs2r(
- const int16_t x[], /* i : input vector */
- float y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-void mvl2l(
- const int32_t x[], /* i : input vector */
- int32_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-
-/*! r: index of the maximum value in the input vector */
-int16_t maximum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *max_val /* o : maximum value in the input vector */
-);
-/*! r: index of the maximum value in the input vector */
-int16_t maximumAbs(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *max_val /* o : maximum value in the input vector */
-);
-
-Word16 maximumAbs_l(
- const Word32 *vec, /* i : input vector */
- const Word16 lvec, /* i : length of input vector */
- Word32 *max_val /* o : maximum value in the input vector */
-);
-
-/*! r: index of the minimum value in the input vector */
-int16_t minimum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *min_val /* o : minimum value in the input vector */
-);
-
-/*! r: index of the minimum value in the input vector */
-int16_t minimum_s(
- const int16_t *vec, /* i : Input vector */
- const int16_t lvec, /* i : Vector length */
- int16_t *min_val /* o : minimum value in the input vector */
-);
-
-/*! r: return index with max energy value in vector */
-int16_t emaximum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *ener_max /* o : maximum energy value */
-);
-
-/*! r: vector mean */
-float mean(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-/*! r: dot product of x[] and y[] */
-float dotp(
- const float x[], /* i : vector x[] */
- const float y[], /* i : vector y[] */
- const int16_t n /* i : vector length */
-);
-
-void conv(
- const float x[], /* i : input vector */
- const float h[], /* i : impulse response (or second input vector) */
- float y[], /* o : output vetor (result of convolution) */
- const int16_t L /* i : vector size */
-);
-
-void fir(
- const float x[], /* i : input vector */
- const float h[], /* i : impulse response of the FIR filter */
- float y[], /* o : output vector (result of filtering) */
- float mem[], /* i/o: memory of the input signal (M samples) */
- const int16_t L, /* i : input vector size */
- const int16_t K, /* i : order of the FIR filter (M+1 coefs.) */
- const int16_t upd /* i : 1 = update the memory, 0 = not */
-);
-
-void v_add(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t N /* i : Vector length */
-);
-
-void v_sub(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 - vector 2 */
- const int16_t N /* i : Vector length */
-);
-
-void v_mult(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 .* vector 2*/
- const int16_t N /* i : Vector length */
-);
-
-void v_multc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains c*x */
- const int16_t N /* i : Vector length */
-);
-
-/*! r: index of the winning codeword */
-int16_t squant(
- const float x, /* i : scalar value to quantize */
- float *xq, /* o : quantized value */
- const float cb[], /* i : codebook */
- const int16_t cbsize /* i : codebook size */
-);
-
-int16_t squant_int(
- uint8_t x, /* i : scalar value to quantize */
- uint8_t *xq, /* o : quantized value */
- const uint8_t *cb, /* i : codebook */
- const int16_t cbsize /* i : codebook size */
-);
-
-/*! r: index of the winning codevector */
-int16_t vquant(
- float x[], /* i : vector to quantize */
- const float x_mean[], /* i : vector mean to subtract (0 if none) */
- float xq[], /* o : quantized vector */
- const float cb[], /* i : codebook */
- const int16_t dim, /* i : dimension of codebook vectors */
- const int16_t cbsize /* i : codebook size */
-);
-
-/*! r: index of the winning codevector */
-int16_t w_vquant(
- float x[], /* i : vector to quantize */
- const float x_mean[], /* i : vector mean to subtract (0 if none) */
- const int16_t weights[], /* i : error weights */
- float xq[], /* o : quantized vector */
- const float cb[], /* i : codebook */
- const int16_t dim, /* i : dimension of codebook vectors */
- const int16_t cbsize, /* i : codebook size */
- const int16_t reverse /* i : reverse codebook vectors */
-);
-
-/*! r: index of the winning codeword */
-int16_t usquant(
- const float x, /* i : scalar value to quantize */
- float *xq, /* o : quantized value */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta, /* i : quantization step */
- const int16_t cbsize /* i : codebook size */
-);
-
-/*! r: dequanzited gain */
-float usdequant(
- const int16_t idx, /* i : quantizer index */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta /* i : quantization step */
-);
-
-void v_sort_float(
- float *r, /* i/o: Vector to be sorted in place */
- const int16_t lo, /* i : Low limit of sorting range */
- const int16_t up /* i : High limit of sorting range */
-);
-
-void sort(
- uint16_t *x, /* i/o: Vector to be sorted */
- uint16_t len /* i/o: vector length */
-);
-
-void sort_l(
- Word32 *x, /* i/o: Vector to be sorted */
- Word16 len /* i/o: vector length */
-);
-
-/*! r: variance of vector */
-float var(
- const float *x, /* i : input vector */
- const int16_t len /* i : length of inputvector */
-);
-
-/*! r: standard deviation */
-float std_dev(
- const float *x, /* i : input vector */
- const int16_t len /* i : length of the input vector */
-);
-
-/*! r: the dot product x'*A*x */
-float dot_product_mat(
- const float *x, /* i : vector x */
- const float *A, /* i : matrix A */
- const int16_t m /* i : vector length */
-);
-
-float root_a(
- float a );
-
-float root_a_over_b(
- float a,
- float b );
-
-void polezero_filter(
- const float *in, /* i : input vector */
- float *out, /* o : output vector */
- const int16_t N, /* i : input vector size */
- const float *b, /* i : numerator coefficients */
- const float *a, /* i : denominator coefficients */
- const int16_t order, /* i : filter order */
- float *mem /* i/o: filter memory */
-);
-
-double rint_new(
- double x /* i/o: Round to the nearest integer with mid point exception */
-);
-
-double anint(
- double x /* i/o: Round to the nearest integer */
-);
-
-/*! r: Output either 1 if Numeric, 0 if NaN or Inf */
-int16_t is_numeric_float(
- float x /* i : Input value which is checked if numeric or not */
-);
-
-void delay_signal_float(
- float x[], /* i/o: signal to be delayed */
- const int16_t len, /* i : length of the input signal */
- float mem[], /* i/o: synchronization memory */
- const int16_t delay /* i : delay in samples */
-);
-
-ivas_error push_indice(
- 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 */
-);
-
-ivas_error push_next_indice(
- BSTR_ENC_HANDLE hBstr,
- UWord16 value, /* i : value of the quantized indice */
- Word16 nb_bits /* i : number of bits used to quantize the indice */
-);
-
-ivas_error push_next_bits(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */
- const Word16 nb_bits /* i : number of bits to pack */
-);
-
-/*! r: maximum number of indices */
-Word16 get_ivas_max_num_indices_fx(
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word32 ivas_total_brate /* i : IVAS total bitrate */
-);
-
-/*! r: maximum number of indices */
-int16_t get_BWE_max_num_indices(
- const int32_t extl_brate /* i : extensiona layer bitrate */
-);
-
-/*! r: maximum number of indices */
-Word16 get_ivas_max_num_indices_metadata_fx(
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word32 ivas_total_brate /* i : IVAS total bitrate */
-);
-ivas_error ind_list_realloc(
- INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
- const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */
- Encoder_Struct *st_ivas /* i : IVAS encoder structure */
-);
-
-ivas_error check_ind_list_limits(
- BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
-);
-
-void move_indices(
- INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
- INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
- const int16_t nb_indices /* i : number of moved indices */
-);
-
-/*! r: index of the indice in the list, -1 if not found */
-int16_t find_indice(
- BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */
- const int16_t id, /* i : ID of the indice */
- uint16_t *value, /* o : value of the quantized indice */
- int16_t *nb_bits /* o : number of bits used to quantize the indice */
-);
-
-/*! r: number of deleted indices */
-uint16_t delete_indice(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t id /* i : ID of the indice */
-);
-
-/*! r: value of the indice */
-uint16_t get_next_indice(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
-);
-
-/*! r: value of the indice */
-uint16_t get_next_indice_1(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void get_next_indice_tmp(
- Decoder_State *st, /* o : decoder state structure */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
-);
-
-/*! r: value of the indice */
-uint16_t get_indice(
- 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 */
-);
-
-/*! r: value of the indice */
-uint16_t get_indice_1(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t pos /* i : absolute position in the bitstream */
-);
-
-void reset_indices_enc(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t max_num_indices /* i : max number of indices */
-);
-
-void reset_indices_dec(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-ivas_error write_indices_ivas(
- Encoder_Struct *st_ivas, /* i/o: encoder state structure */
- uint16_t *bit_stream, /* i/o: output bitstream */
- uint16_t *num_bits /* i/o: number of bits written to output */
-);
-
-Word16 rate2EVSmode_float(
- const Word32 brate, /* i : bitrate */
- int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
-);
-
-
-/*! r: 1 = OK, 0 = something wrong */
-ivas_error read_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 *prev_ft_speech,
- int16_t *CNG,
- int16_t bfi /* i : bad frame indicator */
-);
-
-
-void ivas_set_bitstream_pointers(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-Decoder_State **reset_elements(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-
-void convertSerialToBytestream(
- const uint16_t *const serial, /* i : input serial bitstream with values 0 and 1 */
- const uint16_t num_bits, /* i : number of bits in the input bitstream */
- uint8_t *const bytestream /* o : output compact bitstream (bytestream) */
-);
-
-void convertBytestreamToSerial(
- const uint8_t *const bytestream, /* i : input compact bitstream (bytestream) */
- const uint16_t num_bits, /* i : number of bits in the input bitstream */
- uint16_t *const serial /* o : output serial bitstream with values 0 and 1 */
-);
-
-void mdct_switching_dec(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void evs_dec_previewFrame_float(
- uint8_t *bitstream, /* i : bitstream pointer */
- int16_t bitstreamSize, /* i : bitstream size */
- int16_t *partialCopyFrameType, /* o : frame type of the partial copy */
- int16_t *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */
-);
-
-
-void getPartialCopyInfo_float(
- Decoder_State *st, /* i : decoder state structure */
- int16_t *sharpFlag );
-
-void get_NextCoderType(
- uint8_t *bitstream, /* i : bitstream */
- int16_t *next_coder_type /* o : next coder type */
-);
-
-int16_t print_disclaimer(
- FILE *fPtr );
-
-
-/*! r: delay value in ns */
-int32_t get_delay(
- const int16_t enc_dec, /* i : encoder/decoder flag */
- const int32_t io_fs, /* i : input/output sampling frequency */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */
-);
-
-void decision_matrix_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- int16_t *hq_core_type /* o : HQ core type */
-);
-
-void signaling_enc(
- Encoder_State *st /* i : encoder state structure */
-);
-
-int16_t signaling_mode1_tcx20_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t push /* i : flag to push indice */
-);
-
-void decision_matrix_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t *sharpFlag, /* o : formant sharpening flag */
- int16_t *hq_core_type, /* o : HQ core type */
- int16_t *core_switching_flag /* o : ACELP->HQ switching frame flag */
-);
-
-
-void amr_wb_dec_init(
- AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */
-);
-
-void hf_synth_amr_wb_init(
- AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */
-);
-
-void hf_synth_amr_wb_reset(
- AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */
- ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */
-);
-
-void hf_synth_amr_wb(
- AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */
- ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t output_frame, /* i : output frame length */
- const float *Aq, /* i : quantized Az */
- const float *exc, /* i : excitation at 12.8 kHz */
- float *synth, /* i/o: synthesis signal at 12.8 kHz */
- int16_t *amr_io_class, /* i : signal class (determined by FEC algorithm) */
- float *synth_out, /* i/o: synthesis signal at output Fs */
- float fmerit, /* i : classify parameter from FEC */
- const int16_t *hf_gain, /* i : decoded HF gain */
- const float *voice_factors, /* i : voicing factors */
- const float pitch_buf[], /* i : pitch buffer */
- const float ng_ener_ST, /* i : Noise gate - short-term energy */
- const float *lsf_new /* i : ISF vector */
-);
-
-void hf_cod_init(
- float *mem_hp400_enc, /* o : memory of hp 400 Hz filter */
- float *mem_hf1_enc, /* o : HF band-pass filter memory */
- float *mem_syn_hf_enc, /* o : HF synthesis memory */
- float *mem_hf2_enc, /* o : HF band-pass filter memory */
- float *gain_alpha /* o : smoothing gain for transitions between active and inactive frames */
-);
-
-void hf_cod(
- const int32_t core_brate, /* i : core bitrate */
- const float *speech16k, /* i : original speech at 16 kHz */
- const float Aq[], /* i : quantized Aq */
- const float exc[], /* i : excitation at 12.8 kHz */
- float synth[], /* i : 12.8kHz synthesis signal */
- int16_t *seed2_enc, /* i/o: random seed for HF noise gen */
- float *mem_hp400_enc, /* i/o: memory of hp 400 Hz filter */
- float *mem_syn_hf_enc, /* i/o: HF synthesis memory */
- float *mem_hf1_enc, /* i/o: HF band-pass filter memory */
- float *mem_hf2_enc, /* i/o: HF band-pass filter memory */
- const int16_t *dtxHangoverCount,
- float *gain_alpha, /* i/o: smoothing gain for transitions between active and inactive frames */
- int16_t *hf_gain /* o : HF gain to be transmitted to decoder */
-);
-
-void hf_synth_init(
- ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */
-);
-
-void hf_synth_reset(
- ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */
-);
-
-void hf_synth(
- ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t output_frame, /* i : output frame length */
- const float *Aq, /* i : quantized Az */
- const float *exc, /* i : excitation at 12.8 kHz */
- float *synth, /* i/o: 12.8kHz synthesis signal */
- float *synth16k /* i/o: 16kHz synthesis signal */
-);
-
-void fft_rel(
- float x[], /* i/o: input/output vector */
- const int16_t n, /* i : vector length */
- const int16_t m /* i : log2 of vector length */
-);
-
-void ifft_rel(
- float io[], /* i/o: input/output vector */
- const int16_t n, /* i : vector length */
- const int16_t m /* i : log2 of vector length */
-);
-
-void preemph(
- float *signal, /* i/o: signal */
- const float mu, /* i : preemphasis factor */
- const int16_t L, /* i : vector size */
- float *mem /* i/o: memory (x[-1]) */
-);
-void preemph_ivas_fx(
- Word32 *signal, /* i/o: signal Qx*/
- const Word16 mu, /* i : preemphasis factor Q15*/
- const Word16 L, /* i : vector size Q0*/
- Word32 *mem /* i/o: memory (x[-1]) Qx*/
-);
-void cb_shape(
- const int16_t preemphFlag, /* i : flag for pre-emphasis */
- const int16_t pitchFlag, /* i : flag for pitch sharpening */
- const int16_t scramblingFlag, /* i : flag for phase scrambling */
- const int16_t formantFlag, /* i : flag for formant sharpening */
- const int16_t formantTiltFlag, /* i : flag for formant tilt */
- const float g1, /* i : formant sharpening numerator weighting */
- const float g2, /* i : formant sharpening denominator weighting */
- const float *p_Aq, /* i : LP filter coefficients */
- float *code, /* i/o: signal to shape */
- const float tilt_code, /* i : tilt of code */
- const float pt_pitch, /* i : pointer to current subframe fractional pitch*/
- const int16_t L_subfr /* i : subfframe length */
-);
-
-void CNG_exc(
- const int32_t core_brate, /* i : core bitrate */
- const int16_t L_frame, /* i : length of the frame */
- float *Enew, /* i/o: decoded SID energy */
- int16_t *seed, /* i/o: random generator seed */
- float exc[], /* o : current non-enhanced excitation */
- float exc2[], /* o : current enhanced excitation */
- float *lp_ener, /* i/o: LP filtered E */
- const int32_t last_core_brate, /* i : previous frame core bitrate */
- int16_t *first_CNG, /* i/o: first CNG frame flag for energy init. */
- int16_t *cng_ener_seed, /* i/o: random generator seed for CNG energy */
- float bwe_exc[], /* o : excitation for SWB TBE */
- const int16_t allow_cn_step, /* i : allow CN step */
- int16_t *last_allow_cn_step, /* i/o: last CN_step */
- const int16_t num_ho, /* i : number of selected hangover frames */
- float q_env[],
- float *lp_env,
- float *old_env,
- float *exc_mem,
- float *exc_mem1,
- int16_t *sid_bw,
- int16_t *cng_ener_seed1,
- float exc3[],
- const int16_t Opt_AMR_WB, /* i : AMR-WB interop flag */
- const int16_t element_mode /* i : IVAS Element mode */
-);
-
-
-void cng_params_postupd(
- const int16_t ho_circ_ptr, /* i : pointer for CNG averaging buffers */
- int16_t *cng_buf_cnt, /* i/o: counter for CNG store buffers */
- const float *cng_exc2_buf, /* i : Excitation buffer */
- const int32_t *cng_brate_buf, /* i : bitrate buffer */
- float ho_env_circ[], /* i/o: Envelope buffer */
- const int16_t element_mode, /* i : Element mode */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void calculate_hangover_attenuation_gain(
- Encoder_State *st, /* i : encoder state structure */
- float *att, /* o : attenuation factor */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-int16_t get_cng_mode_ivas(
- const int32_t last_active_brate /* i : last active bitrate */
-);
-
-void disf_ns_28b(
- int16_t *indice, /* i : quantized indices, use indice[0] = -1 in the decoder*/
- float *isf_q /* o : ISF in the frequency domain (0..6400) */
-);
-
-void limit_T0(
- const int16_t L_frame, /* i : length of the frame */
- const int16_t delta, /* i : Half the close-loop searched interval */
- const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */
- const int16_t limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
- const int16_t T0, /* i : rough pitch estimate around which the search is done */
- const int16_t T0_frac, /* i : pitch estimate fractional part */
- int16_t *T0_min, /* o : lower pitch limit */
- int16_t *T0_max /* o : higher pitch limit */
-);
-
-/*! r: interpolated value */
-float interpolation(
- const float *x, /* i : input vector */
- const float *win, /* i : interpolation window */
- const int16_t frac, /* i : fraction */
- const int16_t up_samp, /* i : upsampling factor */
- const int16_t nb_coef /* i : nb of filter coef */
-);
-
-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]) */
-);
-
-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 */
-);
-
-void weight_a_subfr(
- const int16_t nb_subfr, /* i : number of subframes */
- 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 */
-);
-
-void syn_12k8(
- const int16_t L_frame, /* i : length of the frame */
- const float *Aq, /* i : LP filter coefficients */
- const float *exc, /* i : input signal */
- float *synth, /* o : output signal */
- float *mem, /* i/o: initial filter states */
- const int16_t update_m /* i : update memory flag: 0 --> no memory update */
-); /* 1 --> update of memory */
-
-void syn_filt(
- const float a[], /* i : LP filter coefficients */
- const int16_t m, /* i : order of LP filter */
- const float x[], /* i : input signal */
- float y[], /* o : output signal */
- const int16_t l, /* i : size of filtering */
- float mem[], /* i/o: initial filter states */
- const int16_t update_m /* i : update memory flag: 0 --> no memory update */
-); /* 1 --> update of memory */
-
-void synth_mem_updt2_flt(
- const int16_t L_frame, /* i : frame length */
- const int16_t last_L_frame, /* i : frame length */
- float old_exc[], /* i/o: excitation buffer */
- float mem_syn_r[], /* i/o: synthesis filter memory */
- float mem_syn2[], /* o : synthesis filter memory for find_target */
- float mem_syn[], /* o : synthesis filter memory for find_target */
- const int16_t dec /* i : flag for decoder indication */
-);
-
-void int_lsp(
- const int16_t L_frame, /* i : length of the frame */
- const float lsp_old[], /* i : LSPs from past frame */
- const float lsp_new[], /* i : LSPs from present frame */
- float *Aq, /* o : LP coefficients in both subframes */
- const int16_t m, /* i : order of LP filter */
- const float *int_coeffs, /* i : interpolation coefficients */
- const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
-);
-
-void int_lsp4(
- const int16_t L_frame, /* i : length of the frame */
- const float lsp_old[], /* i : previous end-frame LSPs */
- const float lsp_mid[], /* i : current mid-frame LSPs */
- const float lsp_new[], /* i : current end-frame LSPs */
- float *Aq, /* o : LP coefficients in both subframes */
- const int16_t m, /* i : order of LP filter */
- int16_t relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
-);
-
-/*! r: length of output */
-int16_t modify_Fs(
- const float sigIn[], /* i : signal to decimate */
- const int16_t lg, /* i : length of input */
- const int32_t fin, /* i : frequency of input */
- float sigOut[], /* o : decimated signal */
- const int32_t fout, /* i : frequency of output */
- float mem[], /* i/o: filter memory */
- const int16_t nblp /* i : flag indicating if NB low-pass is applied */
-);
-
-void pred_lt4_flt(
- const float excI[], /* i : input excitation buffer */
- float excO[], /* o : output excitation buffer */
- const int16_t T0, /* i : integer pitch lag */
- int16_t frac, /* i : fraction of lag */
- const int16_t L_subfr, /* i : subframe size */
- const float *win, /* i : interpolation window */
- const int16_t nb_coef, /* i : nb of filter coef */
- const int16_t up_sample /* i : up_sample */
-);
-
-void pred_lt4_tc_flt(
- float exc[], /* i : excitation buffer */
- const int16_t T0, /* i : integer pitch lag */
- int16_t frac, /* i : fraction of lag */
- const float *win, /* i : interpolation window */
- const int16_t imp_pos, /* i : glottal impulse position */
- const int16_t i_subfr /* i : subframe index */
-);
-
-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 */
-);
-
-void calc_residu(
- const float *speech, /* i : weighted speech signal */
- float *res, /* o : residual signal */
- const float *p_Aq, /* i : quantized LP filter coefficients */
- const int16_t L_frame /* i : size of frame */
-);
-
-/*! r: impulse response energy */
-float enr_1_Az(
- const float Aq[], /* i : LP filter coefs */
- const int16_t len /* i : impulse response length */
-);
-
-void Es_pred_enc(
- float *Es_pred, /* o : predicited scaled innovation energy */
- int16_t *Es_pred_indice, /* o : indice corresponding to above parameter */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t L_subfr, /* i : length of the subframe */
- const float *res, /* i : residual signal */
- const float *voicing, /* i : normal. correlattion in three 1/2frames */
- const int16_t nb_bits, /* i : allocated number of bits */
- const int16_t no_ltp /* i : no_ltp flag */
-);
-
-void create_offset(
- UWord32 *offset_scale1,
- UWord32 *offset_scale2,
- const int16_t mode,
- const int16_t prediction_flag );
-
-float mslvq(
- float *pTmp, /* i : M-dimensional input vector */
- float *quant, /* o : quantized vector */
- float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */
- int16_t *idx_lead, /* o : leader index for each 8-dim subvector */
- int16_t *idx_scale, /* o : scale index for each subvector */
- const float *w, /* i : weights for LSF quantization */
- const int16_t mode, /* i : number indicating the coding mode */
- const int16_t mode_glb, /* i : LVQ coding mode */
- const int16_t pred_flag /* i : prediction flag (0: safety net, 1 - predictive )*/
-);
-
-void permute(
- float *pTmp1, /* i/o: vector whose components are to be permuted */
- const int16_t *perm /* i : permutation info (indexes that should be interchanged), max two perms */
-);
-
-void sort_desc_ind(
- float *s,
- const int16_t len,
- int16_t *ind );
-
-float mslvq_cng(
- int16_t idx_cv, /* i : index of cv from previous stage */
- float *pTmp, /* i : 16 dimensional input vector */
- float *quant, /* o : quantized vector */
- float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */
- int16_t *idx_lead, /* o : leader index for each 8-dim subvector */
- int16_t *idx_scale, /* o : scale index for each subvector */
- const float *w /* i : weights for LSF quantization */
-);
-
-int16_t deindex_lvq_cng(
- int16_t *index, /* i : index to be decoded, as an array of 3 short */
- float *x_lvq, /* o : decoded codevector */
- const int16_t idx_cv, /* i : relative mode_lvq, wrt START_CNG */
- const int16_t no_bits /* i : number of bits for lattice */
-);
-
-void multiply32_32_64(
- UWord32 x, /* i : operand 1 */
- UWord32 y, /* i : operand 2 */
- UWord32 *res /* o : result as array of two uint32 */
-);
-
-int16_t deindex_lvq(
- int16_t *index, /* i : index to be decoded, as an array of 3 short */
- float *x_lvq, /* o : decoded codevector */
- const int16_t mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */
- const int16_t sf_flag, /* i : safety net flag */
- const int16_t no_bits /* i : number of bits for lattice */
-);
-
-void index_lvq(
- float *quant, /* i : codevector to be indexed (2 8-dim subvectors) */
- int16_t *idx_lead, /* i : leader class index for each subvector */
- int16_t *idx_scale, /* i : scale index for each subvector */
- const int16_t mode, /* i : integer signaling the quantizer structure for the current bitrate */
- int16_t *index, /* o : encoded index (represented on 3 short each with 15 bits ) */
- const int16_t prediction_flag /* i : predictive mode or not */
-);
-
-int16_t qlsf_ARSN_tcvq_Dec_16k(
- float *y, /* o : Quantized LSF vector */
- int16_t *indice, /* i : Indices */
- const int16_t nBits /* i : number of bits */
-);
-
-
-int16_t lsf_bctcvq_decprm_ivas(
- Decoder_State *st,
- int16_t *param_lpc );
-
-
-void disf_2s_36b(
- int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
- float *isf_q, /* o : quantized ISFs in the cosine domain */
- float *mem_AR, /* i/o: quantizer memory for AR model */
- float *mem_MA /* i/o: quantizer memory for MA model */
-);
-
-void disf_2s_46b(
- int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
- float *isf_q, /* o : quantized ISFs in the cosine domain */
- float *mem_AR, /* o : quantizer memory for AR model */
- float *mem_MA /* i/o: quantizer memory for MA model */
-);
-
-void re8_k2y(
- const int16_t *k, /* i : Voronoi index k[0..7] */
- const int16_t m, /* i : Voronoi modulo (m = 2^r = 1<=2) */
- int16_t *y /* o : 8-dimensional point y[0..7] in RE8 */
-);
-
-void re8_PPV(
- const float x[], /* i : point in R^8 */
- int16_t y[] /* o : point in RE8 (8-dimensional integer vector) */
-);
-
-void enhancer(
- const int16_t codec_mode, /* i : flag indicating Codec Mode */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t cbk_index, /* i : */
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const int16_t coder_type, /* i : coding type */
- const int16_t L_frame, /* i : frame size */
- const float voice_fac, /* i : subframe voicing estimation */
- const float stab_fac, /* i : LP filter stablility measure */
- const float norm_gain_code, /* i : normalized innovative cb. gain */
- const float gain_inov, /* i : gain of the unscaled innovation */
- float *gc_threshold, /* i/o: code threshold */
- float *code, /* i/o: innovation */
- float *exc2, /* i/o: adapt. excitation/total exc. */
- const float gain_pit, /* i : Quantized pitch gain */
- float *dispMem /* i/o: Phase dispersion algorithm memory */
-);
-
-void phase_dispersion_flt(
- const float gain_code, /* i : gain of code */
- const float gain_pit, /* i : gain of pitch */
- float code[], /* i/o: code vector */
- const int16_t mode, /* i : level, 0=hi, 1=lo, 2=off */
- float disp_mem[] /* i/o: static memory (size = 8) */
-);
-
-void re8_vor(
- int16_t y[], /* i : point in RE8 (8-dimensional integer vector) */
- int16_t *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */
- int16_t k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 */
- int16_t c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */
- int16_t *ka /* o : identifier of absolute leader (needed to index c)*/
-);
-
-void DoRTFT480(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT320(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT160(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT128(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT120(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT80(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT20(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFT40(
- float *x, /* i/o: real part of input and output data */
- float *y /* i/o: imaginary part of input and output data */
-);
-
-void DoRTFTn(
- float *x, /* i/o: real part of input and output data */
- float *y, /* i/o: imaginary part of input and output data */
- const int16_t n /* i : size of the FFT n=(2^k) up to 1024 */
-);
-
-void BASOP_cfft_ivas(
- Word32 *re, /* i/o: real part */
- Word32 *im, /* i/o: imag part */
- Word16 s, /* i : stride real and imag part */
- Word16 *scale /* i : scalefactor */
-);
-
-void fft(
- float *re, /* i/o: real part */
- float *im, /* i/o: imag part */
- const int16_t length, /* i : length of fft */
- const int16_t s /* i : sign */
-);
-
-void rfft(
- float *x, /* i/o: values */
- const float *w, /* i : window */
- const int16_t length, /* i : length of fft */
- const int16_t isign /* i : sign */
-);
-
-void sinq(
- const float tmp, /* i : sinus factor cos(tmp*i+phi) */
- const float phi, /* i : sinus phase cos(tmp*i+phi) */
- const int16_t N, /* i : size of output */
- float x[] /* o : output vector */
-);
-
-void edct2(
- const int16_t n,
- const int16_t isgn,
- float *in,
- float *a,
- const int16_t *ip,
- const float *w );
-
-void stat_noise_uv_mod(
- const int16_t coder_type, /* i : coder type */
- float noisiness, /* i : noisiness parameter */
- const float *const lsp_old, /* i : old LSP vector at 4th sfr */
- const float *const lsp_new, /* i : LSP vector at 4th sfr */
- const float *const lsp_mid, /* i : LSP vector at 2nd sfr */
- float *Aq, /* o : A(z) quantized for the 4 subframes */
- float *exc2, /* o : excitation buffer */
- const int16_t bfi, /* i : bad frame indicator */
- float *ge_sm, /* i/o: smoothed excitation gain */
- int16_t *uv_count, /* i/o: unvoiced counter */
- int16_t *act_count, /* i/o: activation counter */
- float lspold_s[], /* i/o: old LSP */
- int16_t *noimix_seed, /* i/o: mixture seed */
- float *st_min_alpha, /* i/o: minimum alpha */
- float *exc_pe, /* i/o: memory of the preemphasis filter */
- const int32_t bitrate, /* i : core bitrate */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void limit_band_noise_level_calc(
- const int16_t *wnorm, /* i : reordered norm of sub-vectors */
- int16_t *limit, /* o : highest band of bit allocation */
- const int32_t core_brate, /* i : core bitrate */
- float *noise_level /* o : noise level */
-);
-
-/*! r: hqswb_clas */
-int16_t peak_avrg_ratio(
- const int32_t total_brate, /* i : total bitrate */
- const float *input_hi, /* i : input signal */
- const int16_t N, /* i : number of coefficients */
- int16_t *mode_count, /* i/o: HQ_HARMONIC mode count */
- int16_t *mode_count1 /* i/o: HQ_NORMAL mode count */
-);
-
-/*! r: Number of coefficients in nf codebook */
-int16_t build_nf_codebook(
- const int16_t flag_32K_env_ho, /* i : Envelope attenuation hangover flag */
- const float *coeff, /* i : Coded spectral coefficients */
- const int16_t *sfm_start, /* i : Subband start indices */
- const int16_t *sfmsize, /* i : Subband widths */
- const int16_t *sfm_end, /* i : Subband end indices */
- const int16_t nb_sfm, /* i : Last coded band */
- const int16_t *R, /* i : Per-band bit allocation */
- float *CodeBook, /* o : Noise-fill codebook */
- float *CodeBook_mod /* o : Densified noise-fill codebook */
-);
-
-void apply_noisefill_HQ(
- const int16_t *R, /* i : bit allocation */
- const int16_t length, /* i : input frame length */
- const int16_t flag_32K_env_ho, /* i : envelope stability hangover flag */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t last_sfm, /* i : last coded subband */
- const float *CodeBook, /* i : Noise-fill codebook */
- const float *CodeBook_mod, /* i : Densified noise-fill codebook */
- const int16_t cb_size, /* i : Codebook length */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t *sfmsize, /* i : Subband band width */
- float *coeff /* i/o: coded/noisefilled spectrum */
-);
-
-void harm_bwe_fine(
- const int16_t *R, /* i : bit allocation */
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t high_sfm, /* i : higher transition band to BWE */
- const int16_t num_sfm, /* i : total number of bands */
- const int16_t *norm, /* i : quantization indices for norms */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- int16_t *prev_L_swb_norm, /* i/o: last normalize length */
- float *coeff, /* i/o: coded/noisefilled normalized spectrum */
- float *coeff_out, /* o : coded/noisefilled spectrum */
- float *coeff_fine /* o : BWE fine structure */
-);
-
-void hvq_bwe_fine(
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t num_sfm, /* i : total number of bands */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t *peak_idx, /* i : Peak index */
- const int16_t Npeaks, /* i : Number of peaks */
- int16_t *peak_pos, /* i/o: Peak positions */
- int16_t *prev_L_swb_norm, /* i/o: last normalize length */
- float *coeff, /* i/o: coded/noisefilled normalized spectrum */
- int16_t *bwe_peaks, /* o : Positions of peaks in BWE */
- float *coeff_fine /* o : HVQ BWE fine structure */
-);
-
-void hq_fold_bwe(
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t num_sfm, /* i : Number of subbands */
- float *coeff /* i/o: coded/noisefilled normalized spectrum */
-);
-
-void apply_nf_gain(
- const int16_t nf_idx, /* i : noise fill gain index */
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t *R, /* i : bit allocation */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- float *coeff /* i/o: coded/noisefilled normalized spectrum */
-
-);
-
-void hq_generic_fine(
- float *coeff, /* i : coded/noisefilled normalized spectrum */
- const int16_t last_sfm, /* i : Last coded band */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
- float *coeff_out1 /* o : HQ GENERIC input */
-);
-
-void harm_bwe(
- const float *coeff_fine, /* i : fine structure for BWE */
- const float *coeff, /* i : coded/noisefilled normalized spectrum */
- const int16_t num_sfm, /* i : Number of subbands */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t high_sfm, /* i : higher transition band to BWE */
- const int16_t *R, /* i : bit allocation */
- const int16_t prev_hq_mode, /* i : previous hq mode */
- int16_t *norm, /* i/o: quantization indices for norms */
- float *noise_level, /* i/o: noise levels for harmonic modes */
- float *prev_noise_level, /* i/o: noise factor in previous frame */
- int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
- float *coeff_out, /* o : coded/noisefilled spectrum */
- const int16_t element_mode /* i : element mode */
-);
-
-void hvq_bwe(
- const float *coeff, /* i : coded/noisefilled spectrum */
- const float *coeff_fine, /* i : BWE fine structure */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t *sfm_len, /* i : Subband length */
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t prev_hq_mode, /* i : previous hq mode */
- const int16_t *bwe_peaks, /* i : HVQ bwe peaks */
- const int16_t bin_th, /* i : HVQ transition bin */
- const int16_t num_sfm, /* i : Number of bands */
- const int32_t core_brate, /* i : Core bitrate */
- const int16_t *R, /* i : Bit allocation */
- int16_t *norm, /* i/o: quantization indices for norms */
- float *noise_level, /* i/o: noise levels for harmonic modes */
- float *prev_noise_level, /* i/o: noise factor in previous frame */
- int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
- float *coeff_out /* o : coded/noisefilled spectrum */
-);
-
-void hvq_concat_bands(
- const int16_t pvq_bands, /* i : Number of bands in concatenated PVQ target */
- const int16_t *sel_bnds, /* i : Array of selected high bands */
- const int16_t n_sel_bnds, /* i : Number of selected high bands */
- int16_t *hvq_band_start, /* o : Band start indices */
- int16_t *hvq_band_width, /* o : Band widths */
- int16_t *hvq_band_end /* o : Band end indices */
-);
-
-void hq_generic_bwe(
- const int16_t HQ_mode, /* i : HQ mode */
- float *coeff_out1, /* i/o: BWE input & temporary buffer */
- const float *hq_generic_fenv, /* i : SWB frequency envelopes */
- float *coeff_out, /* o : SWB signal in MDCT domain */
- const int16_t hq_generic_offset, /* i : frequency offset for representing hq generic*/
- int16_t *prev_L_swb_norm, /* i/o: last normalize length */
- const int16_t hq_generic_exc_clas, /* i : hq generic hf excitation class */
- const int16_t *sfm_end, /* i : End of bands */
- const int16_t num_sfm, /* i : Number of bands */
- const int16_t num_env_bands, /* i : Number of coded envelope bands */
- const int16_t *R /* i : Bit allocation */
-);
-
-void map_hq_generic_fenv_norm(
- const int16_t hqswb_clas, /* i : signal classification flag */
- const float *hq_generic_fenv, /* i : HQ GENERIC envelope */
- int16_t *ynrm, /* o : high band norm indices */
- int16_t *normqlg2, /* o : high band norm values */
- const int16_t num_env_bands, /* i : Number coded envelope bands */
- const int16_t nb_sfm, /* i : Number of envelope bands */
- const int16_t hq_generic_offset /* i : Freq offset for HQ GENERIC */
-);
-
-/*! r: Number of bits consumed for the delta coding */
-int16_t calc_nor_delta_hf(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const float *t_audio, /* i : transform-domain coefficients */
- int16_t *ynrm, /* i/o: norm indices */
- int16_t *Rsubband, /* i/o: sub-band bit allocation */
- const int16_t num_env_bands, /* i : Number coded envelope bands */
- const int16_t nb_sfm, /* i : Number of envelope bands */
- const int16_t *sfmsize, /* i : band length */
- const int16_t *sfm_start, /* i : Start index of bands */
- const int16_t core_sfm /* i : index of the end band for core */
-);
-
-/*! r: Number of bits consumed for the delta coding */
-int16_t get_nor_delta_hf(
- Decoder_State *st, /* i/o: Decoder state */
- int16_t *ynrm, /* i/o: norm indices */
- int16_t *Rsubband, /* i/o: sub-band bit allocation */
- const int16_t num_env_bands, /* i : Number coded envelope bands */
- const int16_t nb_sfm, /* i : Number of envelope bands */
- const int16_t core_sfm ); /* i : index of the end band for core */
-
-void hq_wb_nf_bwe(
- const float *coeff, /* i : coded/noisefilled normal. spectrum */
- const int16_t is_transient, /* i : is transient flag */
- const int16_t prev_bfi, /* i : previous bad frame indicator */
- const float *normq_v, /* i : norms */
- const int16_t num_sfm, /* i : Number of subbands */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t *sfmsize, /* i : Subband band width */
- const int16_t last_sfm, /* i : last coded subband */
- const int16_t *R, /* i : bit allocation */
- const int16_t prev_is_transient, /* i : previous transient flag */
- float *prev_normq, /* i/o: previous norms */
- float *prev_env, /* i/o: previous noise envelopes */
- int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
- float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */
- int16_t *prev_R, /* i/o: previous frame bit allocation info. */
- float *coeff_out /* o : coded/noisefilled spectrum */
-);
-
-/*! r: Number of bits */
-int16_t encode_envelope_indices(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t num_sfm, /* i : Number of subbands */
- const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */
- int16_t *difidx, /* i/o: Diff indices/encoded diff indices */
- int16_t *LCmode, /* o : Coding mode */
- const int16_t flag_pack, /* i : indicator of packing or estimating bits */
- const int16_t flag_HQ2, /* i : indicator of HQ2 core */
- const int16_t is_transient /* i : transient flag */
-);
-
-void diff_envelope_coding(
- const int16_t is_transient, /* i : transient indicator */
- const int16_t num_env_bands, /* i : number of envelope bands to code */
- const int16_t start_norm, /* i : start of envelope coding */
- int16_t *ynrm, /* i/o: quantization indices for norms */
- int16_t *normqlg2, /* i/o: quantized norms */
- int16_t *difidx /* o : differential code */
-);
-
-/*! r: Number of bits */
-int16_t decode_envelope_indices(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t start_norm, /* i : First SDE encoded norm */
- const int16_t num_sfm, /* i : Number of norms */
- const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */
- int16_t *ynrm, /* o : Decoded norm indices */
- const int16_t flag_HQ2, /* i : indicator of HQ2 core */
- const int16_t is_transient /* i : transient flag */
-);
-
-/*! r: Number of bits */
-void dequantize_norms(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t start_norm, /* i : First SDE encoded norm */
- const int16_t num_sfm, /* i : Number of norms */
- const int16_t is_transient, /* i : Transient flag */
- int16_t *ynrm, /* o : Decoded norm indices */
- int16_t *normqlg2 /* o : Log2 of decoded norms */
-);
-
-void hq_configure(
- const int16_t length, /* i : Frame length */
- const int16_t hqswb_clas, /* i : HQ SWB class */
- const int32_t core_brate, /* i : core bitrate */
- int16_t *num_sfm, /* o : Total number of subbands */
- int16_t *nb_sfm, /* o : Total number of coded bands */
- int16_t *start_norm, /* o : First norm to be SDE encoded */
- int16_t *num_sde_norm, /* o : Number of norms for SDE encoding */
- int16_t *numnrmibits, /* o : Number of bits in fall-back norm encoding */
- int16_t *hq_generic_offset, /* o : Freq offset for HQ GENERIC */
- int16_t *sfmsize, /* o : Subband bandwidths */
- int16_t *sfm_start, /* o : Subband start coefficients */
- int16_t *sfm_end /* o : Subband end coefficients */
-);
-
-/*! r: Consumed bits */
-int16_t hvq_enc(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t bwidth, /* i : audio bandwidth */
- 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 */
- const int16_t *ynrm, /* i : Envelope coefficients */
- int16_t *R, /* i/o: Bit allocation/updated bit allocation */
- int16_t *peaks, /* i/o: Peak pos. / Encoded peak pos. */
- float *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */
- float *noise_level, /* o : Quantized noise level */
- const float *pe_gains, /* i : Peak gains */
- const float *coefs, /* i : spectrum coefficients */
- float *coefs_out /* o : encoded spectrum coefficients */
-);
-/*! r: Consumed bits */
-int16_t hq_classifier_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t core_brate, /* i : Core bitrate */
- const int16_t length, /* i : Frame length */
- int16_t *is_transient, /* o : Transient flag */
- int16_t *hqswb_clas /* o : HQ class */
-);
-
-void hq_bit_allocation(
- const int32_t core_brate, /* i : Core bitrate */
- const int16_t length, /* i : Frame length */
- const int16_t hqswb_clas, /* i : HQ class */
- int16_t *num_bits, /* i/o: Remaining bit budget */
- const int16_t *normqlg2, /* i : Quantized norms */
- const int16_t nb_sfm, /* i : Number sub bands to be encoded */
- const int16_t *sfmsize, /* i : Sub band bandwidths */
- float *noise_level, /* o : HVQ noise level */
- int16_t *R, /* o : Bit allocation per sub band */
- int16_t *Rsubband, /* o : Fractional bit allocation (Q3) */
- int16_t *sum, /* o : Sum of allocated shape bits */
- int16_t *core_sfm, /* o : Last coded band in core */
- const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
-);
-
-void enforce_zero_for_min_envelope(
- const int16_t hqswb_clas, /* i : HQ coding class */
- const int16_t *ynrm, /* i : Envelope indices */
- float *coefsq, /* i/o: Quantized spectrum/zeroed spectrum */
- int16_t nb_sfm, /* i : Number of coded sub bands */
- const int16_t *sfm_start, /* i : Sub band start indices */
- const int16_t *sfm_end /* i : Sub band end indices */
-);
-
-void apply_envelope(
- const float *coeff, /* i/o: Coded/noisefilled normalized spectrum */
- const int16_t *norm, /* i : Envelope */
- const float *norm_adj, /* i : Envelope adjustment */
- const int16_t num_sfm, /* i : Total number of bands */
- const int16_t last_sfm, /* i : Last coded band */
- const int16_t HQ_mode, /* i : HQ mode */
- const int16_t length, /* i : Frame length */
- const int16_t *sfm_start, /* i : Sub band start indices */
- const int16_t *sfm_end, /* i : Sub band end indices */
- float *normq_v, /* o : Envelope with adjustment */
- float *coeff_out, /* o : coded/noisefilled spectrum */
- float *coeff_out1 /* o : noisefilled spectrum for HQ SWB BWE */
-);
-
-void apply_envelope_enc(
- float *coeff, /* i/o: Normalized/scaled normalized spectrum */
- const int16_t *norm, /* i : Envelope */
- const int16_t num_sfm, /* i : Total number of bands */
- const int16_t *sfm_start, /* i : Sub band start indices */
- const int16_t *sfm_end /* i : Sub band end indices */
-);
-
-/*! r: Leading_sign_index, index, size, k_val */
-PvqEntry mpvq_encode_vec(
- const int16_t *vec_in, /* i : Signed pulse train */
- const int16_t dim_in, /* i : Dimension */
- int16_t k_val_local /* i/o: Num unit pulses */
-);
-
-/*! r: Size, dim, k_val */
-PvqEntry get_size_mpvq_calc_offset(
- const int16_t dim_in, /* i : Dimension */
- const int16_t k_val_in, /* i : Num unit pulses */
- uint32_t *h_mem /* o : Offsets */
-);
-
-void mpvq_decode_vec(
- const PvqEntry *entry, /* i : Sign_ind, index, dim, k_val */
- uint32_t *h_mem, /* i : A/U offsets */
- int16_t *vec_out /* o : Pulse train */
-);
-
-/*! r: Multiplication result */
-uint32_t UMult_32_32(
- const uint32_t UL_var1, /* i : factor 1 */
- const uint32_t UL_var2 /* i : factor 2 */
-);
-
-/*! r: inverse */
-uint32_t UL_inverse_float(
- const uint32_t UL_val, /* i : input value Q_exp */
- int16_t *exp /* i/o: input exp / result exp */
-);
-
-/*! r: ratio */
-Word16 ratio_float(
- const Word32 numer, /* i : numerator */
- const Word32 denom, /* i : denominator */
- Word16 *expo /* i/o: input exp / result exp */
-);
-
-/*! r: Angle between 0 and EVS_PI/2 radian (Q14) */
-Word16 atan2_fx_flt(
- const Word32 y, /* i : near side (Argument must be positive) (Q15) */
- const Word32 x /* i : opposite side (Q15) */
-);
-
-void pvq_encode_frame(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const float *coefs_norm, /* i : normalized coefficients to encode */
- float *coefs_quant, /* o : quantized coefficients */
- float *gopt, /* o : optimal shape gains */
- int16_t *npulses, /* o : number of pulses per band */
- int16_t *pulse_vector, /* o : non-normalized pulse shapes */
- const int16_t *sfm_start, /* i : indices of first coefficients in the bands */
- const int16_t *sfm_end, /* i : indices of last coefficients in the bands */
- const int16_t *sfmsize, /* i : band sizes */
- const int16_t nb_sfm, /* i : total number of bands */
- const int16_t *R, /* i : bitallocation per band (Q3) */
- const int16_t pvq_bits, /* i : number of bits avaiable */
- const int16_t core /* i : core */
-);
-
-void pvq_decode_frame(
- Decoder_State *st, /* i/o: Decoder state */
- float *coefs_quant, /* o : quantized coefficients */
- int16_t *npulses, /* o : number of pulses per band */
- int16_t *pulse_vector, /* o : non-normalized pulse shapes */
- const int16_t *sfm_start, /* i : indices of first coeffs in the bands */
- const int16_t *sfm_end, /* i : indices of last coeffs in the bands */
- const int16_t *sfmsize, /* i : band sizes */
- const int16_t nb_sfm, /* i : total number of bands */
- const int16_t *R, /* i : bitallocation per band (Q3) */
- const int16_t pvq_bits, /* i : number of bits avaiable */
- const int16_t core /* i : core */
-);
-
-void srt_vec_ind(
- const int16_t *linear, /* linear input */
- int16_t *srt, /* sorted output */
- int16_t *I, /* index for sorted output */
- const int16_t length );
-
-void srt_vec_ind_f(
- const float *linear, /* linear input */
- float *srt, /* sorted output */
- int16_t *I, /* index for sorted output */
- const int16_t length /* length of vector */
-);
-
-/*! r: floor(sqrt(input)) */
-uint32_t floor_sqrt_exact(
- const uint32_t input /* i : unsigned input [0.. UINT_MAX/4] */
-);
-
-void fine_gain_quant(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t *ord, /* i : Indices for energy order */
- const int16_t num_sfm, /* i : Number of bands */
- const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */
- float *fg_pred, /* i/o: Predicted gains / Corrected gains */
- const float *gopt /* i : Optimal gains */
-);
-
-void apply_gain(
- const int16_t *ord, /* i : Indices for energy order */
- const int16_t *band_start, /* i : Sub band start indices */
- const int16_t *band_end, /* i : Sub band end indices */
- const int16_t num_sfm, /* i : Number of bands */
- const float *gains, /* i : Band gain vector */
- float *xq /* i/o: float synthesis / gain adjusted synth */
-);
-
-void fine_gain_pred(
- const int16_t *sfm_start, /* i : Sub band start indices */
- const int16_t *sfm_end, /* i : Sub band end indices */
- const int16_t *sfm_size, /* i : Sub band bandwidths */
- const int16_t *i_sort, /* i : Energy sorting indices */
- const int16_t *K, /* i : Number of pulses per band */
- const int16_t *maxpulse, /* i : Maximum pulse per band */
- const int16_t *R, /* i : Bits per sub band (Q3) */
- const int16_t num_sfm, /* i : Number of sub bands */
- float *xq, /* i/o: Quantized vector /quantized vector with finegain adj */
- int16_t *y, /* i/o: Quantized vector */
- float *fg_pred, /* o : Predicted fine gains */
- const int16_t core /* i : Core */
-);
-
-void fine_gain_dec(
- Decoder_State *st, /* i/o: Decoder state struct */
- const int16_t *ord, /* i : Indices for energy order */
- const int16_t num_sfm, /* i : Number of bands */
- const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */
- float *fg_pred /* i/o: Predicted gains / Corrected gains */
-);
-
-void get_max_pulses(
- const int16_t *band_start, /* i : Sub band start indices */
- const int16_t *band_end, /* i : Sub band end indices */
- const int16_t *k_sort, /* i : Indices for sorting by energy */
- const int16_t *npulses, /* i : Pulses per sub band */
- const int16_t BANDS, /* i : Number of bands */
- int16_t *inp_vector, /* i/o: Encoded shape vectors */
- int16_t *maxpulse /* o : Maximum pulse height per band */
-);
-
-Word32 ar_div_ivas(
- Word32 num,
- Word32 denum );
-
-void ar_encoder_start(
- PARCODEC arInst,
- TCQ_PBITSTREAM bsInst,
- int16_t max_bits );
-
-void ar_decoder_start(
- PARCODEC arInst,
- TCQ_PBITSTREAM bsInst );
-
-void ar_encoder_done(
- PARCODEC arInst );
-
-void ar_decoder_done(
- PARCODEC arInst );
-
-
-Word32 Mult_32_16(
- Word32 a,
- Word16 b );
-
-Word32 Mult_32_32(
- Word32 a,
- Word32 b );
-
-
-void decode_mangitude_tcq_fx_ivas(
- ARCODEC *pardec,
- Word16 size,
- Word16 npulses,
- Word16 nzpos,
- Word32 *positions,
- Word32 *out,
- Word32 *surplus_fx );
-
-void decode_signs_fx_ivas(
- ARCODEC *pardec,
- Word16 size,
- Word32 *out );
-
-void srt_vec_ind_fx_ivas(
- const Word32 *linear,
- Word32 *srt,
- Word16 *I,
- Word16 length );
-
-
-void bit_allocation_second_fx2(
- Word32 *Rk,
- Word32 *Rk_sort,
- Word16 BANDS,
- const Word16 *band_width,
- Word16 *k_sort,
- Word16 *k_num,
- const Word16 *p2a_flags,
- const Word16 p2a_bands,
- const Word16 *last_bitalloc,
- const Word16 input_frame );
-
-
-Word32 encode_magnitude_tcq_fx_ivas(
- ARCODEC *parenc,
- float *magn_fx,
- Word16 size,
- Word16 npulses,
- Word16 nzpos,
- Word32 *savedstates,
- Word32 *est_frame_bits_fx );
-
-Word32 encode_signs_fx_ivas(
- ARCODEC *parenc,
- float *magn,
- Word16 size,
- Word16 npos,
- Word32 *est_frame_bits_fx );
-
-Word32 encode_magnitude_usq_fx_ivas(
- ARCODEC *parenc,
- float *magn_fx,
- Word16 size,
- Word16 npulses,
- Word16 nzpos,
- Word32 *est_frame_bits_fx );
-
-ivas_error tcq_core_LR_enc(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- int32_t inp_vector[],
- const float coefs_norm[],
- float coefs_quant[],
- const int16_t bit_budget, /* number of bits */
- const int16_t nb_sfm,
- const int16_t *sfm_start,
- const int16_t *sfm_end,
- const int16_t *sfmsize,
- Word32 *Rk_fx,
- int16_t *npulses,
- int16_t *k_sort,
- const int16_t *p2a_flags,
- const int16_t p2a_bands,
- const int16_t *last_bitalloc,
- const int16_t input_frame,
- const int16_t adjustFlag,
- const int16_t is_transient );
-
-void tcq_core_LR_dec(
- Decoder_State *st,
- int32_t *inp_vector,
- const int16_t bit_budget,
- const int16_t bands,
- const int16_t *band_start,
- const int16_t *band_width,
- Word32 *Rk_fx,
- int16_t npulses[],
- int16_t *k_sort,
- const int16_t *p2a_flags,
- const int16_t p2a_bands,
- const int16_t *last_bitalloc,
- const int16_t input_frame,
- const int16_t adjustFlag,
- const int16_t *is_transient );
-
-
-void TCQLSB(
- int16_t bcount,
- float *abuffer,
- float *mbuffer,
- float *sbuffer,
- int16_t *dpath );
-
-void RestoreTCQ(
- float *magn,
- int16_t size,
- int16_t *bcount,
- float *mbuffer );
-
-void SaveTCQdata(
- PARCODEC arInst,
- int16_t *dpath,
- int16_t bcount );
-
-void LoadTCQdata(
- PARCODEC arInst,
- int16_t *dpath,
- int16_t bcount );
-
-void RestoreTCQdec(
- int32_t *magn,
- int16_t size,
- int16_t *bcount,
- float *mbuffer );
-
-void TCQLSBdec(
- int16_t *dpath,
- float *mbuffer,
- int16_t bcount );
-
-void bit_allocation_second_fx2(
- Word32 *Rk,
- Word32 *Rk_sort,
- Word16 BANDS,
- const Word16 *band_width,
- Word16 *k_sort,
- Word16 *k_num,
- const Word16 *p2a_flags,
- const Word16 p2a_bands,
- const Word16 *last_bitalloc,
- const Word16 input_frame );
-
-void io_ini_enc(
- const int32_t argc, /* i : command line arguments number */
- char *argv[], /* i : command line arguments */
- FILE **f_input, /* o : input signal file */
- FILE **f_stream, /* o : output bitstream file */
- 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 */
- Encoder_Struct *st /* o : IVAS encoder structure */
-);
-
-void read_next_rfparam(
- int16_t *rf_fec_offset, /* o : RF offset */
- int16_t *rf_fec_indicator, /* o : RF FEC indicator */
- FILE *f_rf /* i : file pointer to read parameters */
-);
-
-void read_next_brate(
- int32_t *total_brate, /* i/o: total bitrate */
- const int32_t last_total_brate, /* i : last total bitrate */
- FILE *f_rate, /* i : bitrate switching profile (0 if N/A) */
- const int16_t element_mode, /* i : IVAS element mode */
- int32_t input_Fs, /* i : input sampling frequency */
- int16_t *Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- int16_t *Opt_SC_VBR, /* i/o: SC-VBR flag */
- int16_t *codec_mode /* i/o: Mode 1 or 2 */
-);
-
-void read_next_bwidth(
- int16_t *max_bwidth, /* i/o: maximum encoded bandwidth */
- FILE *f_bwidth, /* i : bandwidth switching profile (0 if N/A) */
- int32_t *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */
- 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_ivas_fx(
- Encoder_State *st, /* i/o: state structure */
- Encoder_Struct *st_ivas, /* i/o: encoder state structure */
- const Word16 idchan, /* i : channel ID */
- const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */
- const Word16 interval_SID, /* i : interval for SID update */
- const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */
- const ISM_MODE ism_mode, /* i : ISM mode */
- const Word32 element_brate /* i : element bitrate */
-);
-
-void LPDmem_enc_init(
- LPD_state_HANDLE hLPDmem /* i/o: LP memories */
-);
-
-ivas_error evs_enc(
- Encoder_State *st, /* i/o: state structure */
- const int16_t *data, /* i : input signal */
- float *mem_hp20_in, /* i/o: hp20 filter memory */
- const int16_t n_samples /* i : number of input samples */
-);
-void amr_wb_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t *data, /* i : input signal */
- float *mem_hp20_in, /* i/o: hp20 filter memory */
- const int16_t n_samples /* i : number of input samples */
-);
-
-void sc_vbr_enc_init(
- SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle */
-);
-
-void amr_wb_enc_init(
- AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */
-);
-
-void pre_proc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t input_frame, /* i : frame length */
- float old_inp_12k8[], /* i/o: buffer of old input signal */
- float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */
- float **inp, /* o : ptr. to inp. signal in the current frame*/
- float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */
- float *ener, /* o : residual energy from Levinson-Durbin */
- int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */
- float A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- float Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- float epsP[M + 1], /* i/o: LP prediction errors */
- float lsp_new[M], /* i/o: LSPs at the end of the frame */
- float lsp_mid[M], /* i/o: LSPs in the middle of the frame */
- int16_t *vad_hover_flag, /* i : VAD hangover flag */
- int16_t *attack_flag, /* o : attack flag */
- float *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- int16_t *Voicing_flag, /* o : voicing flag for HQ FEC */
- float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
- float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
- int16_t *hq_core_type /* o : HQ core type */
-);
-
-
-/*! r: HQ_CORE/TCX_20_CORE decision */
-int16_t mdct_classifier(
- Encoder_State *st, /* i/o: Encoder state variable */
- const float *fft_buff, /* i : FFT spectrum from fft_rel */
- const float enerBuffer[], /* i : energy buffer */
- const int32_t brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
-);
-
-void MDCT_selector(
- Encoder_State *st, /* i/o: Encoder State */
- const float sp_floor, /* i : Noise floor estimate */
- const float Etot, /* i : Total energy */
- const float cor_map_sum, /* i : sum of correlation map */
- const float enerBuffer[] /* i : energy buffer */
-);
-
-ivas_error acelp_core_enc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 inp[], /* i : input signal of the current frame Q_new*/
- Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
- const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/
- Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
- Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/
- const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
- const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/
- Word16 *q_old_syn_12k8_16,
- Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
- Word16 *unbits, /* o : number of unused bits Q0*/
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
- Word16 Q_new );
-
-ivas_error acelp_core_switch_dec_bfi(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void acelp_core_switch_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const float inp12k8[], /* i : input signal @12.8 kHz */
- const float inp16k[], /* i : input signal @16 kHz */
- const float A[NB_SUBFR16k * ( M + 1 )] /* i : A(z) unquantized for the 4 subframes */
-);
-
-/*! r: length of output */
-int16_t modify_Fs_intcub3m_sup(
- const float sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */
- const int16_t lg, /* i : length of input */
- const int32_t fin, /* i : frequency of input */
- float sigOut[], /* o : decimated signal */
- const int32_t fout, /* i : frequency of output */
- int16_t *delayout /* o : delay of output */
-);
-
-void core_switching_OLA(
- const float *mem_over_hp, /* i : upsampling filter memory */
- const int16_t last_L_frame, /* i : last L_frame lengthture */
- const int32_t output_Fs, /* i : output sampling rate */
- float *synth, /* i/o: synthesized signal from HQ core */
- const float *synth_subfr_out, /* i : synthesized signal from ACELP core */
- float *synth_subfr_bwe, /* i : synthesized BWE from ACELP core */
- const int16_t output_frame, /* i : output frame length */
- const int16_t bwidth /* i : output bandwidth */
-);
-
-void retro_interp4_5(
- const float *syn,
- float *pst_old_syn );
-
-void retro_interp5_4(
- float *pst_old_syn );
-void core_switching_hq_prepare_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t *num_bits, /* i/o: bit budget update */
- const int16_t input_frame /* i : input frame length */
-);
-
-ivas_error acelp_core_switch_dec(
- Decoder_State *st, /* i/o: decoder structure */
- float *synth_subfr_out, /* o : synthesized ACELP subframe */
- float *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE */
- const int16_t output_frame, /* i : input frame length */
- const int16_t core_switching_flag, /* i : core switching flag */
- float *mem_synth, /* o : synthesis to overlap */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-void ResetSHBbuffer_Enc(
- TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
-);
-
-void ResetSHBbuffer_Dec(
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- const int16_t extl /* i : BWE extension layer */
-);
-
-void calc_st_filt(
- const float *apond2, /* i : coefficients of numerator */
- const float *apond1, /* i : coefficients of denominator */
- float *parcor0, /* o : 1st parcor calcul. on composed filter */
- float *sig_ltp_ptr, /* i/o: input of 1/A(gamma1) : scaled by 1/g0 */
- float *mem_zero, /* i/o: All zero memory */
- const int16_t L_subfr, /* i : the length of subframe */
- const int16_t extl /* i : extension layer info */
-);
-
-
-void scale_st_ivas(
- const float *sig_in, /* i : postfilter input signal */
- float *sig_out, /* i/o: postfilter output signal */
- float *gain_prec, /* i/o: last value of gain for subframe */
- const int16_t L_subfr, /* i : the length of subframe */
- const int16_t extl /* i : extension layer info */
-);
-
-void filt_mu(
- const float *sig_in, /* i : signal (beginning at sample -1) */
- float *sig_out, /* o : output signal */
- const float parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */
- const int16_t L_subfr, /* i : the length of subframe */
- const int16_t extl /* i : extension layer info */
-);
-
-void PostShortTerm(
- float *sig_in, /* i : input signal (ptr. to current subframe */
- float *lpccoeff, /* i : LPC coefficients for current subframe */
- float *sig_out, /* o : postfiltered output */
- float *mem_stp, /* i/o: postfilter memory */
- float *ptr_mem_stp, /* i/o: pointer to postfilter memory */
- float *ptr_gain_prec, /* i/o: for gain adjustment */
- float *mem_zero, /* i/o: null memory to compute h_st */
- const float formant_fac /* i : Strength of post-filter [0,1] */
-);
-
-/*! r: Formant filter strength [0,1] */
-float swb_formant_fac(
- const float lpc_shb2, /* i : 2nd HB LPC coefficient */
- float *tilt_mem /* i/o: Tilt smoothing memory */
-);
-
-void GenShapedSHBExcitation(
- float *excSHB, /* o : synthesized shaped shb exctiation */
- const float *lpc_shb, /* i : lpc coefficients */
- float *exc16kWhtnd, /* o : whitened synthesized shb excitation */
- float *mem_csfilt, /* i/o: memory */
- float *mem_genSHBexc_filt_down_shb, /* i/o: memory */
- float *state_lpc_syn, /* i/o: memory */
- const int16_t coder_type, /* i : coding type */
- const float *bwe_exc_extended, /* i : bandwidth extended excitation */
- int16_t bwe_seed[], /* i/o: random number generator seed */
- float voice_factors[], /* i : voicing factor */
- const int16_t extl, /* i : extension layer */
- float *tbe_demph, /* i/o: de-emphasis memory */
- float *tbe_premph, /* i/o: pre-emphasis memory */
- float *lpc_shb_sf, /* i : LP coefficients */
- float *shb_ener_sf, /* i : SHB subframe energies */
- float *shb_res_gshape, /* i : SHB LP residual gain shape */
- float *shb_res, /* i : SHB residual used in encoder only */
- int16_t *vf_ind, /* i/o: Mixing factor index */
- const float formant_fac, /* i : Formant sharpening factor [0..1] */
- float fb_state_lpc_syn[], /* i/o: memory */
- float *fb_tbe_demph, /* i/o: fb de-emphasis memory */
- const int32_t total_brate, /* i : overall bitrate */
- const int16_t prev_bfi, /* i : previous frame was lost flag */
- const int16_t element_mode, /* i : element mode */
- const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
- float *nlExc16k, /* i/o: NL exc for IC-BWE */
- float *mixExc16k, /* i/o: exc spreading for IC-BWE */
- const int32_t extl_brate, /* i : TD BWE bitrate */
- const int16_t MSFlag, /* i : Multi-source flag */
- float EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
- float *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
- float *prev_mix_factor, /* i/o: mixing factor in the previous frame */
- float *Env_error, /* o : error in SHB residual envelope modelling*/
- float Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */
-);
-
-void GenSHBSynth(
- const float *shb_target_speech, /* i : input synthesized speech */
- float *shb_syn_speech_32k, /* o : output highband component */
- float Hilbert_Mem[], /* i/o: memory */
- float state_lsyn_filt_shb_local[], /* i/o: memory */
- const int16_t L_frame, /* i : ACELP Frame length */
- int16_t *syn_dm_phase );
-
-void ScaleShapedSHB(
- const int16_t length, /* i : SHB overlap length */
- float *synSHB, /* i/o: synthesized shb signal */
- float *overlap, /* i/o: buffer for overlap-add */
- const float *subgain, /* i : subframe gain */
- const float frame_gain, /* i : frame gain */
- const float *win, /* i : window */
- const float *subwin /* i : subframes window */
-);
-
-void Interpolate_allpass_steep(
- const float *in, /* i : input array of size N */
- float *mem, /* i/o: memory */
- const int16_t N, /* i : number of input samples */
- float *out /* o : output array of size 2*N */
-);
-
-void Decimate_allpass_steep(
- const float *in, /* i : input array of size N */
- float *mem, /* i/o: memory */
- const int16_t N, /* i : number of input samples */
- float *out /* o : output array of size N/2 */
-);
-
-void interpolate_3_over_2_allpass(
- const float *input, /* i : input signal */
- const int16_t len, /* i : number of input samples */
- float *out, /* o : output signal */
- float *mem /* i/o: memory */
-);
-
-void decimate_2_over_3_allpass(
- const float *input, /* i : input signal */
- const int16_t len, /* i : number of input samples */
- float *out, /* o : output signal */
- float *mem, /* i/o: memory */
- float *lp_mem );
-
-void interpolate_3_over_1_allpass(
- const float *input, /* i : input signal */
- const int16_t len, /* i : number of input samples */
- float *out, /* o : output signal */
- float *mem /* i/o: memory */
-);
-
-void InitSWBencBuffer(
- TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
-);
-
-void InitSWBencBufferStates(
- TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- float *shb_speech /* o : SHB target signal (6-14kHz) at 16kHz */
-);
-
-void swb_tbe_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
- const float *new_speech, /* i : original input signal */
- const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
- const float voice_factors[], /* i : voicing factors */
- float *White_exc16k, /* o : shaped white excitation for the FB TBE */
- const float pitch_buf[] /* i : pitch for each subframe */
-);
-
-void swb_tbe_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
- const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
- const float voice_factors[], /* i : voicing factors */
- const float old_syn_12k8_16k[], /* i : low band synthesis at 12.8kHz or 16kHz */
- float *White_exc16k, /* o : shaped white excitation for the FB TBE */
- float *synth, /* i/o: ACELP core synthesis/final synthesis */
- float *pitch_buf );
-
-void flip_and_downmix_generic(
- float input[], /* i : input spectrum */
- float output[], /* o : output spectrum */
- const int16_t length, /* i : length of spectra */
- float mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */
- float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */
- float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */
- int16_t *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
-);
-void flip_and_downmix_generic_fx_32(
- Word32 input[], /* i : input spectrum Qx*/
- Word32 output[], /* o : output spectrum Qx*/
- const Word16 length, /* i : length of spectra */
- Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/
- Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
- Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
- Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
-);
-void non_linearity(
- const float input[], /* i : input signal */
- float output[], /* i : output signal */
- float old_bwe_exc_extended[], /* i/o: memory bugffer */
- const int16_t length, /* i : input length */
- float *prev_scale, /* i/o: memory */
- const int16_t coder_type, /* i : Coder Type */
- const float *voice_factors, /* i : Voice Factors */
- const int16_t L_frame /* i : ACELP frame length */
-);
-
-void interp_code_5over2(
- const float inp_code[], /* i : input vector */
- float interp_code[], /* o : output vector */
- const int16_t inp_length /* i : length of the input vector */
-);
-
-void interp_code_4over2(
- const float inp_code[], /* i : input vector */
- float interp_code[], /* o : output vector */
- const int16_t inp_length /* i : length of the input vector */
-);
-
-void flip_spectrum_and_decimby4(
- const float input[], /* i : input spectrum */
- float output[], /* o : output spectrum */
- const int16_t length, /* i : vector length */
- float mem1[], /* i/o: memory */
- float mem2[], /* i/o: memory */
- const int16_t ramp_flag /* i : flag to trigger slow ramp-up of output */
-);
-
-void GenShapedWBExcitation(
- float *excSHB, /* o : synthesized shaped shb exctiation */
- const float *lpc_shb, /* i : lpc coefficients */
- float *exc4kWhtnd, /* o : whitened synthesized shb excitation */
- float *mem_csfilt, /* i/o: memory */
- float *mem_genSHBexc_filt_down1, /* i/o: memory */
- float *mem_genSHBexc_filt_down2, /* i/o: memory */
- float *mem_genSHBexc_filt_down3, /* i/o: memory */
- float *state_lpc_syn, /* i/o: memory */
- const int16_t coder_type, /* i : coding type */
- const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
- int16_t bwe_seed[], /* i/o: random number generator seed */
- const float voice_factors[], /* i : voicing factor */
- const int16_t uv_flag, /* i : unvoiced flag */
- const int16_t igf_flag );
-
-void GenWBSynth(
- const float *input_synspeech, /* i : input synthesized speech */
- float *shb_syn_speech_16k, /* o : output highband compnent */
- float *state_lsyn_filt_shb1, /* i/o: memory */
- float *state_lsyn_filt_shb2 /* i/o: memory */
-);
-
-void wb_tbe_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */
- const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
- const float pitch_buf[], /* i : pitch for each subframe */
- const float voicing[] /* o : OL maximum normalized correlation */
-);
-
-void wb_tbe_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
- const float voice_factors[], /* i : voicing factors */
- float *synth /* i/o: ACELP core synthesis/final synthesis */
-);
-
-void tbe_write_bitstream(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void tbe_read_bitstream(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void GenTransition(
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- float *outputHB, /* o : synthesized HB transitions signal */
- const int32_t output_Fs, /* i : output sampling rate */
- const int16_t element_mode, /* i : element mode */
- const int16_t L_frame, /* i : ACELP frame length */
- const int16_t rf_flag, /* i : RF flag */
- const int32_t total_brate /* i : total bitrate */
-);
-
-
-void GenTransition_fixed(
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */
- const Word32 output_Fs, /* i : output sampling rate : Q0 */
- const Word16 element_mode, /* i : element mode : Q0 */
- const Word16 L_frame, /* i : ACELP frame length : Q0 */
- const Word16 rf_flag, /* i : RF flag : Q0 */
- const Word32 total_brate, /* i : total bitrate : Q0 */
- const Word16 prev_Qx );
-
-void GenTransition_WB(
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- float *outputHB, /* o : synthesized HB transitions signal */
- const int32_t output_Fs /* i : output sampling rate */
-);
-
-void GenTransition_WB_fixed(
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */
- const Word32 output_Fs /* i : output sampling rate */
-);
-
-void td_bwe_dec_init(
- TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- const int16_t extl, /* i : BWE extension layer */
- const int32_t output_Fs /* i : output sampling rate */
-);
-
-void TBEreset_enc(
- TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- const int16_t last_core, /* i : last core */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void TBEreset_dec(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-/*! r: TBE bit consumption per frame */
-int16_t get_tbe_bits(
- const int32_t total_brate, /* i : overall bitrate */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t rf_mode /* i : channel aware mode */
-);
-
-void fb_tbe_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const float new_input[], /* i : input speech at 48 kHz sample rate */
- const float fb_exc[] /* i : FB excitation from the SWB part */
-);
-
-void fb_tbe_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const float fb_exc[], /* i : FB excitation from the SWB part */
- float *hb_synth, /* i/o: high-band synthesis */
- float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */
- const int16_t output_frame /* i : output frame length */
-);
-
-void calc_tilt_bwe(
- const float *sp, /* i : input signal */
- float *tilt, /* o : signal tilt */
- const int16_t N /* i : signal length */
-);
-
-void fd_bwe_enc_init(
- FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle */
-);
-
-void swb_pre_proc(
- Encoder_State *st, /* i/o: encoder state structure */
- float *new_swb_speech, /* o : original input signal at 32kHz */
- float *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz */
- float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */
- float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */
- CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
-);
-
-void wb_pre_proc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t last_element_mode, /* i : last element mode */
- const float *new_inp_resamp16k, /* i : original input signal */
- float *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */
-);
-
-void wb_bwe_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *new_wb_speech /* i : original input signal at 16kHz */
-);
-
-void wb_bwe_dec_flt(
- Decoder_State *st, /* i/o: decoder state structure */
- const float output[], /* i : synthesis @internal Fs */
- float *synth, /* i/o: ACELP core synthesis/final synthesis */
- float *hb_synth, /* o : SHB synthesis/final synthesis */
- const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const int16_t output_frame, /* i : frame length */
- const float voice_factors[], /* i : voicing factors */
- const float pitch_buf[] /* i : pitch buffer */
-);
-
-void swb_bwe_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t last_element_mode, /* i : last element mode */
- const float *old_input_12k8, /* i : input signal @12.8kHz for SWB BWE */
- const float *old_input_16k, /* i : input signal @16kHz for SWB BWE */
- const float *old_syn_12k8_16k, /* i : ACELP core synthesis at 12.8kHz or 16kHz*/
- const float *new_swb_speech, /* i : original input signal at 32kHz */
- const float *shb_speech /* i : SHB target signal (6-14kHz) at 16kHz */
-);
-
-void swb_bwe_enc_hr(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *new_input, /* i : input signal */
- const int16_t input_frame, /* i : frame length */
- const int16_t unbits /* i : number of core unused bits */
-);
-
-void fd_bwe_dec_init_flt(
- FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */
-);
-
-void swb_bwe_dec_flt(
- Decoder_State *st, /* i/o: decoder state structure */
- const float output[], /* i : synthesis @internal Fs */
- const float *synth, /* i : ACELP core synthesis/final synthesis */
- float *hb_synth, /* o : SHB synthesis/final synthesis */
- const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const int16_t output_frame /* i : frame length */
-);
-
-void hr_bwe_dec_init_flt(
- HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */
-);
-
-void swb_bwe_dec_hr(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *syn_12k8_16k, /* i : ACELP core synthesis @16kHz */
- float *hb_synth, /* o : SHB synthesis */
- const int16_t output_frame, /* i : frame length */
- const int16_t unbits, /* i : number of core unused bits */
- const float pitch_buf[] /* i : pitch buffer */
-);
-
-
-void calc_normal_length(
- const int16_t core, /* i : core */
- const float *sp, /* i : input signal */
- const int16_t mode, /* i : input mode */
- const int16_t extl, /* i : extension layer */
- int16_t *L_swb_norm, /* o : normalize length */
- int16_t *prev_L_swb_norm /* i/o: last normalize length */
-);
-
-void calc_norm_envelop(
- const float SWB_signal[], /* i : SWB spectrum */
- float *envelope, /* o : normalized envelope */
- const int16_t L_swb_norm, /* i : length of envelope */
- const int16_t SWB_flength, /* i : Length of input/output */
- const int16_t st_offset /* i : offset */
-);
-
-void time_envelop_shaping(
- float werr[], /* i/o: SHB synthesis */
- float SWB_tenv[], /* i/o: frequency envelope */
- const int16_t L /* i : frame length */
-);
-
-void time_reduce_pre_echo(
- const float *synth, /* i : ACELP core synthesis */
- float *error, /* o : SHB BWE synthesis */
- float prev_td_energy, /* o : last td energy */
- const int16_t L /* i : subframe length */
-);
-
-int16_t WB_BWE_gain_pred(
- float *WB_fenv, /* o : WB frequency envelopes */
- const float *core_dec_freq, /* i : Frequency domain core decoded signal */
- const int16_t coder_type, /* i : coding type */
- const int16_t prev_code_type, /* i : coding type of last frame */
- const float prev_WB_fenv, /* i : envelope for last frame */
- const float voice_factors[], /* i : voicing factors */
- const float pitch_buf[], /* i : pitch buffer */
- const int32_t last_core_brate, /* i : previous frame core bitrate */
- const float last_wb_bwe_ener, /* i : previous frame wb bwe signal energy */
- const int16_t last_extl, /* i : extl. layer for last frame */
- const float tilt );
-
-void WB_BWE_decoding(
- const float *core_dec_freq, /* i : Frequency domain core decoded signal */
- float *WB_fenv, /* i : WB frequency envelopes */
- float *WB_signal, /* o : WB signal in MDCT domain */
- const int16_t WB_flength, /* i : Length of input/output */
- const int16_t mode, /* i : classification for WB signal */
- const int16_t last_extl, /* i : extl. layer for last frame */
- float *prev_Energy, /* i/o: energy for last frame */
- float *prev_WB_fenv, /* i/o: envelope for last frame */
- int16_t *prev_L_wb_norm, /* i/o: length for last frame wb norm */
- const int16_t extl, /* i : extension layer */
- const int16_t coder_type, /* i : coding type */
- const int32_t total_brate, /* i : core layer bitrate */
- int16_t *Seed, /* i/o: random generator seed */
- int16_t *prev_flag, /* i/o: attenu flag of last frame */
- int16_t prev_coder_type /* i : coding type of last frame */
-);
-
-void SWB_BWE_decoding(
- const float *core_dec_freq, /* i : Frequency domain core decoded signal */
- float *SWB_fenv, /* i/o: SWB frequency envelopes */
- float *SWB_signal, /* o : SWB signal in MDCT domain */
- const int16_t SWB_flength, /* i : Length of input/output */
- const int16_t mode, /* i : classification for SWB signal */
- int16_t *frica_flag, /* o : fricative signal flag */
- float *prev_Energy, /* i/o: energy for last frame */
- float *prev_SWB_fenv, /* i/o: envelope for last frame */
- int16_t *prev_L_swb_norm, /* i/o: length for last frame wb norm */
- const float tilt_nb, /* i : tilt of synthesis wb signal */
- int16_t *Seed, /* i/o: random generator seed */
- const int16_t st_offset, /* i : offset value due to different core */
- float *prev_weight, /* i/o: excitation weight value of last frame */
- const int16_t extl, /* i : extension layer */
- const int16_t last_extl /* i : extension layer of last frame */
-);
-
-void CNG_reset_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- float *pitch_buf, /* o : floating pitch for each subframe */
- float *voice_factors, /* o : voicing factors */
- int16_t VBR_cng_reset_flag );
-
-/*! r: stability flag */
-uint16_t a2rc(
- const float *a, /* i : LPC coefficients */
- float *refl, /* o : Reflection co-efficients */
- const int16_t lpcorder /* i : LPC order */
-);
-
-
-void analy_sp(
- const int16_t element_mode, /* i : element mode */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const int32_t input_Fs, /* i : input sampling rate */
- float *speech, /* i : speech buffer */
- float *Bin_E, /* o : per bin log energy spectrum */
- float *Bin_E_old, /* o : per bin log energy spectrum for mid-frame */
- float *fr_bands, /* o : per band energy spectrum (2 analyses) */
- float lf_E[], /* o : per bin E for first VOIC_BINS bins (without DC) */
- float *Etot, /* o : total input energy */
- const int16_t min_band, /* i : minimum critical band */
- const int16_t max_band, /* i : maximum critical band */
- float *band_ener, /* o : energy in critical frequency bands without minimum noise floor E_MIN */
- float *PS, /* o : Per bin energy spectrum */
- float *fft_buff /* o : FFT coefficients */
-);
-
-void CNG_enc(
- Encoder_State *st, /* i/o: State structure */
- float Aq[], /* o : LP coefficients */
- const float *speech, /* i : pointer to current frame input speech buffer */
- float enr, /* i : frame energy output from Levinson recursion */
- const float *lsp_mid, /* i : mid frame LSPs */
- float *lsp_new, /* i/o: current frame LSPs */
- float *lsf_new, /* i/o: current frame LSFs */
- int16_t *allow_cn_step, /* o : allow CN step */
- float *q_env,
- int16_t *sid_bw );
-
-void swb_CNG_enc(
- Encoder_State *st, /* i/o: State structure */
- const float *shb_speech, /* i : SHB target signal (6-14kHz) at 16kHz */
- const float *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz */
-);
-
-void lsf_enc(
- Encoder_State *st, /* i/o: state structure */
- float *lsf_new, /* o : quantized LSF vector */
- float *lsp_new, /* i/o: LSP vector to quantize/quantized */
- float *lsp_mid, /* i : mid-frame LSP vector */
- float *Aq, /* o : quantized A(z) for 4 subframes */
- const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */
- const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
-);
-
-void isf_enc_amr_wb(
- Encoder_State *st, /* i/o: state structure */
- float *isf_new, /* o : quantized ISF vector */
- float *isp_new, /* i/o: ISP vector to quantize/quantized */
- float *Aq /* o : quantized A(z) for 4 subframes */
-);
-
-void find_targets(
- const float *speech, /* i : pointer to the speech frame */
- const float *mem_syn, /* i : memory of the synthesis filter */
- const int16_t i_subfr, /* i : subframe index */
- float *mem_w0, /* i/o: weighting filter denominator memory */
- const float *p_Aq, /* i : interpolated quantized A(z) filter */
- const float *res, /* i : residual signal */
- const int16_t L_subfr, /* i : length of vectors for gain quantization */
- const float *Ap, /* i : unquantized A(z) filter with bandwidth expansion */
- const float tilt_fac, /* i : tilt factor */
- float *xn, /* o : Close-loop Pitch search target vector */
- float *cn, /* o : target vector in residual domain */
- float *h1 /* o : impulse response of weighted synthesis filter */
-);
-
-Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */
- const Word16 pos1, /* i: position of the pulse 1 */
- const Word16 pos2, /* i: position of the pulse 2 */
- const Word16 N /* i: number of bits FOR position */
-);
-void find_tilt(
- const float fr_bands[], /* i : energy in frequency bands */
- const float bckr[], /* i : per band background noise energy estimate */
- float ee[2], /* o : lf/hf E ration for present frame */
- const int16_t pitch[3], /* i : open loop pitch values for 3 half-frames */
- const float voicing[3], /* i : normalized correlation for 3 half-frames */
- const float *lf_E, /* i : per bin energy for low frequencies */
- const float corr_shift, /* i : normalized correlation correction */
- const int16_t bwidth, /* i : input signal bandwidth */
- const int16_t max_band, /* i : maximum critical band */
- float hp_E[], /* o : energy in HF */
- const int16_t codec_mode, /* i : Mode 1 or 2 */
- float *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise */
- int16_t Opt_vbr_mode );
-
-void init_gp_clip(
- float mem[] /* o : memory of gain of pitch clipping algorithm */
-);
-
-int16_t gp_clip(
- const int16_t element_mode, /* i : element mode */
- const int32_t core_brate, /* i : core bitrate */
- const float *voicing, /* i : normalized correlations (from OL pitch) */
- const int16_t i_subfr, /* i : subframe index */
- const int16_t coder_type, /* i : coding type */
- const float xn[], /* i : target vector */
- float mem[] /* i/o: memory of gain of pitch clipping algorithm */
-);
-
-void gp_clip_test_lsf(
- const int16_t element_mode, /* i : element mode */
- const int32_t core_brate, /* i : core bitrate */
- const float lsf[], /* i : LSF vector */
- float mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
-);
-
-void gp_clip_test_gain_pit(
- const int16_t element_mode, /* i : element mode */
- const int32_t core_brate, /* i : core bitrate */
- const float gain_pit, /* i : gain of quantized pitch */
- float mem[] /* i/o: memory of gain of pitch clipping algorithm */
-);
-
-void analy_lp(
- const float speech[], /* i : pointer to the denoised speech frame */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t L_look, /* i : look-ahead length */
- float *ener, /* o : residual signal energy */
- float A[], /* o : A(z) filter coefficients */
- float epsP[], /* o : LP analysis residual energies for each iteration */
- float lsp_new[], /* o : current frame ISPs */
- float lsp_mid[], /* o : current mid-frame ISPs */
- float lsp_old[], /* i/o: previous frame unquantized ISPs */
- const int16_t Top[2], /* i : open loop pitch lag */
- const float Tnc[2], /* i : open loop pitch gain */
- const int32_t sr_core, /* i : internal sampling rate */
- const int16_t sec_chan_low_rate /* i : TD secondary channel flag */
-);
-
-void analy_lp_AMR_WB(
- const float speech[], /* i : pointer to the speech frame */
- float *ener, /* o : residual energy from Levinson-Durbin */
- float A[], /* o : A(z) filter coefficients */
- float epsP[], /* o : LP analysis residual energies for each iteration */
- float isp_new[], /* o : current frame ISPs */
- float isp_old[], /* i/o: previous frame unquantized ISPs */
- float isf_new[], /* o : current frame ISFs */
- const int16_t Top, /* i : open loop pitch lag */
- const float Tnc /* i : open loop pitch gain */
-);
-
-void noise_est_init(
- NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */
-);
-
-void speech_music_clas_init(
- SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */
-);
-
-void long_enr(
- Encoder_State *st, /* i/o: encoder state structure */
- const float Etot, /* i : total channel energy */
- const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
- const int16_t high_lpn_flag, /* i : sp/mus LPN flag */
- FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
- const int16_t n_chan, /* i : number of channels */
- const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover LR channels */
- const float Etot_LR[] /* i : total channel energy LR channels */
-);
-
-void noise_est_pre(
- const float Etot, /* i : Energy of current frame */
- const int16_t ini_frame, /* i : Frame number (init) */
- NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation data handle */
- const int16_t idchan, /* i : channel ID */
- const int16_t element_mode, /* i : element mode */
- const int16_t last_element_mode /* i : last element mode */
-);
-
-void noise_est_down(
- const float fr_bands[], /* i : per band input energy (contains 2 vectors) */
- float bckr[], /* i/o: per band background noise energy estimate */
- float tmpN[], /* o : temporary noise update */
- float enr[], /* o : averaged energy over both subframes */
- const int16_t min_band, /* i : minimum critical band */
- const int16_t max_band, /* i : maximum critical band */
- float *totalNoise, /* o : noise estimate over all critical bands */
- const float Etot, /* i : Energy of current frame */
- float *Etot_last, /* i/o: Energy of last frame */
- float *Etot_v_h2 /* i/o: Energy variaions of noise frames */
-);
-
-void noise_est(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t old_pitch1, /* i : previous frame OL pitch[1] */
- const float tmpN[], /* i : temporary noise update */
- const float *epsP, /* i : LP prediction error energies */
- const float Etot, /* i : total channel E */
- const float relE, /* i : relative frame energy */
- const float corr_shift, /* i : normalized correlation correction */
- const float enr[], /* i : averaged energy over both subframes */
- float fr_bands[], /* i : spectrum per critical bands of the current frame */
- float *cor_map_sum, /* o : sum of correlation map from mult-harm analysis */
- float *ncharX, /* o : noise character for sp/mus classifier */
- float *sp_div, /* o : soectral diversity feature */
- float *non_staX, /* o : non-stationarity for sp/mus classifier */
- int16_t *loc_harm, /* o : multi-harmonicity flag for UV classifier */
- const float *lf_E, /* i : per bin energy for low frequencies */
- int16_t *st_harm_cor_cnt, /* i : 1st harm correlation timer */
- const float Etot_l_lp, /* i : Smoothed low energy */
- float *sp_floor, /* o : noise floor estimate */
- float S_map[], /* o : short-term correlation map */
- STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
- FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */
- const int16_t ini_frame /* i : Frame number (init) */
-);
-
-void vad_param_updt(
- Encoder_State *st, /* i/o: encoder state structure */
- const float corr_shift, /* i : correlation shift */
- const float corr_shiftR, /* i : correlation shift right channel */
- const float A[], /* i : A(z) unquantized for the 4 subframes */
- const int16_t old_pitch1, /* i : previous frame OL pitch[1] */
- FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
- const int16_t n_channels /* i : number of channels */
-);
-
-
-void lp_gain_updt(
- const int16_t i_subfr, /* i : subframe number */
- const float gain_pit, /* i : Decoded gain pitch */
- const float norm_gain_code, /* i : Normalised gain code */
- float *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) */
- float *lp_gainc, /* i/o: LP-filtered code gain (FEC) */
- const int16_t L_frame /* i : length of the frame */
-);
-
-void GSC_enc_init(
- GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */
-);
-
-
-/*! r: index of the last band where pitch contribution is significant */
-int16_t Pit_exc_contribution_len(
- Encoder_State *st, /* i/o: state structure */
- const float *dct_res, /* i : DCT of residual */
- float *dct_pitex, /* i/o: DCT of pitch contribution */
- float *pitch_buf, /* i/o: Pitch per subframe */
- int16_t *hangover /* i : Hangover for the time contribution switching */
-);
-
-int16_t stab_est(
- float etot, /* i : Total energy of the current frame */
- float *lt_diff_etot, /* i/o: Long term total energy variation */
- float *mem_etot, /* i/o: Total energy memory */
- int16_t *nb_thr_3, /* i/o: Number of consecutives frames of level 3 */
- int16_t *nb_thr_1, /* i/o: Number of consecutives frames of level 1 */
- float *thresh, /* i/o: Detection thresold */
- int16_t *last_music_flag, /* i/o: Previous music detection ouptut */
- const int16_t vad_flag /* i : VAD flag */
-);
-
-float gsc_gainQ(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- const float y_gain4[], /* i : gain per band */
- float y_gainQ[], /* o : quantized gain per band */
- const int32_t core_brate, /* i : Core rate */
- const int16_t coder_type, /* i : coding type */
- const int16_t bwidth, /* i : input signal bandwidth */
- const int16_t L_frame, /* i : frame length */
- const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const int32_t core_brate_inp /* i : true core brate */
-);
-
-void Comp_and_apply_gain(
- float exc_diffQ[], /* i/o: gain per band */
- float Ener_per_bd_iQ[], /* o : Quant Ener per band */
- float Ener_per_bd_yQ[], /* o : Ener per band for quantize y */
- int16_t Mbands_gn, /* i : number of bands */
- const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */
-);
-
-void bands_and_bit_alloc_ivas_fx(
- const Word16 cor_strong_limit, /* i : HF correlation */
- const Word16 noise_lev, /* i : dwn scaling factor */
- const Word32 core_brate, /* i : core bit rate */
- const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
- const Word16 bits_used, /* i : Number of bit used before frequency Q */
- Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
- const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */
- Word16 *max_ener_band, /* o : Sorted order */
- Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */
- Word16 *nb_subbands, /* o : Number of subband allowed */
- const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */
- Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
- Word16 *pvq_len, /* o : Number of bin covered with the PVQ */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */
- const Word16 L_frame, /* i : frame length */
- const Word16 element_mode, /* i : element mode */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
-);
-
-void GSC_dec_init_ivas(
- GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
-);
-
-void decod_audio(
- Decoder_State *st, /* i/o: decoder static memory */
- float dct_epit[], /* o : GSC excitation in DCT domain */
- const float *Aq, /* i : LP filter coefficient */
- float *tmp_noise, /* o : long term temporary noise energy */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *exc_dct_in, /* i/o: adapt. excitation exc */
- float *exc2, /* i/o: adapt. excitation/total exc */
- float *bwe_exc, /* o : excitation for SWB TBE */
- float *lsf_new, /* i : current frame ISF vector */
- float *gain_buf, /* o : floating pitch gain for each subframe */
- const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag */
- const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-);
-
-void gsc_dec(
- Decoder_State *st, /* i/o: State structure */
- float exc_dct_in[], /* i/o: dct of pitch-only/total excitation */
- const int16_t pit_band_idx, /* i : pitch band index */
- const int16_t Diff_len, /* i : */
- const int16_t bits_used, /* i : total number of bits used */
- const int16_t nb_subfr, /* i : Number of subframe considered */
- const int16_t coder_type, /* i : coding type */
- int16_t *last_bin, /* i : last bin of bit allocation */
- const float *lsf_new, /* i : ISFs at the end of the frame */
- float *exc_wo_nf, /* o : excitation (in f domain) without noisefill*/
- float *tmp_noise /* o : long-term noise energy */
-);
-
-void dec_pit_exc(
- Decoder_State *st, /* i/o: decoder static memory */
- const int16_t L_frame, /* i : length of the frame */
- const float *Aq, /* i : LP filter coefficient */
- const float Es_pred, /* i : predicted scaled innov. energy */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *code, /* o : innovation */
- float *exc, /* i/o: adapt. excitation exc */
- const int16_t nb_subfr, /* i : Number of subframe considered */
- float *gain_buf, /* o : floating pitch gain for each subframe */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-);
-
-void music_postfilt_init_flt(
- MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */
-);
-
-void LD_music_post_filter(
- MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
- const float dtc_in[], /* i : input synthesis */
- float dtc_out[], /* o : output synthesis */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t coder_type, /* i : Coder type : -1 in case of IO */
- const int16_t Last_coder_type /* i : last Coder type */
-);
-
-void Post_music_postP(
- float dct_buffer_in[], /* i/o: excitation buffer */
- float exc_buffer_out[], /* o : DCT output buffer */
- float *exc2, /* i/o: Current excitation to be overwriten */
- const float *mem_tmp, /* i : previous frame synthesis memory */
- float *st_mem_syn2, /* i/o: current frame synthesis memory */
- const float *Aq, /* i : LPC filter coefficients */
- float *syn /* i/o: 12k8 synthesis */
-);
-
-void Prep_music_postP(
- float exc_buffer_in[], /* i/o: excitation buffer */
- float dct_buffer_out[], /* o : DCT output buffer */
- float filt_lfE[], /* i/o: long term spectrum energy */
- const int16_t last_core, /* i : last core */
- const float *pitch_buf, /* i : current frame pitch information */
- float *LDm_enh_lp_gbin /* o : smoothed suppression gain, per bin FFT */
-);
-
-void speech_music_classif(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *new_inp, /* i : new input signal */
- const float *inp, /* i : input signal to locate attach position */
- const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
- const float lsp_new[M], /* i : LSPs in current frame */
- const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */
- const float epsP[M + 1], /* i : LP prediciton error */
- const float PS[], /* i : energy spectrum */
- const float Etot, /* i : total frame energy */
- const float old_cor, /* i : max correlation from previous frame */
- int16_t *attack_flag, /* o : attack flag (GSC or TC) */
- const float non_staX, /* i : unbound non-stationarity for sp/mus classifier */
- const float relE, /* i : relative frame energy */
- int16_t *high_lpn_flag, /* o : sp/mus LPN flag */
- const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
-);
-void ivas_find_wsp_fx(
- const Word16 L_frame, /* i : length of the frame Q0*/
- const Word16 L_subfr, /* i : length of subframe Q0*/
- const Word16 nb_subfr, /* i : number of subframes Q0*/
- const Word16 *A_fx,
- /* i : A(z) filter coefficients */ // Q12
- Word16 *Aw_fx,
- /* o : weighted A(z) filter coefficients */ // Q12
- const Word16 *speech_fx,
- /* i : pointer to the denoised speech frame */ // Q_new
- const Word16 tilt_fact,
- /* i : tilt factor */ // Q15
- Word16 *wsp_fx,
- /* o : poitnter to the weighted speech frame */ // Q_new
- Word16 *mem_wsp_fx,
- /* i/o: W(Z) denominator memory */ // Q_new
- const Word16 gamma,
- /* i : weighting factor */ // Q15
- const Word16 L_look /* i : look-ahead Q0*/
-);
-
-void gain_enc_amr_wb(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const float *xn, /* i : target vector */
- const float *y1, /* i : zero-memory filtered adaptive excitation */
- const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const float *code, /* i : algebraic excitation */
- const int32_t core_brate, /* i : core bitrate */
- float *gain_pit, /* i/o: Pitch gain / Quantized pitch gain */
- float *gain_code, /* o : Quantized codebook gain */
- float *gain_inov, /* o : innovation gain */
- float *norm_gain_code, /* o : norm. gain of the codebook excitation */
- float *coeff, /* i/o: correlations , -2,, -2 and 2 */
- const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- float *past_qua_en /* i/o: gain quantization memory (4 words) */
-);
-
-void gain_enc_lbr(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t gains_mode[], /* i : gain bits */
- const int16_t coder_type, /* i : coding type */
- const int16_t i_subfr, /* i : subframe index */
- const float *xn, /* i : target vector */
- const float *y1, /* i : zero-memory filtered adaptive excitation */
- const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const float *code, /* i : algebraic excitation */
- float *gain_pit, /* o : quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- float *gain_inov, /* o : gain of the innovation (used for normalization) */
- float *norm_gain_code, /* o : norm. gain of the codebook excitation */
- float *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */
- const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subfr Lenght */
-);
-
-void gain_enc_mless(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t gains_mode[], /* i : gain bits */
- const int16_t element_mode, /* i : element mode */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t i_subfr, /* i : subframe index */
- const int16_t tc_subfr, /* i : TC subframe index */
- const float *xn, /* i : target vector */
- const float *y1, /* i : zero-memory filtered adaptive excitation */
- const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const float *code, /* i : algebraic excitation */
- const float Es_pred, /* i : predicted scaled innovation energy */
- float *gain_pit, /* o : quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- float *gain_inov, /* o : innovation gain */
- float *norm_gain_code, /* o : norm. gain of the codebook excitation */
- float *coeff, /* i/o: correlations , -2,, -2 and 2 */
- const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */
-);
-
-void gain_enc_SQ(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t gains_mode[], /* i : gain bits */
- const int16_t i_subfr, /* i : subframe index */
- const float *xn, /* i : target vector */
- const float *yy1, /* i : zero-memory filtered adaptive excitation */
- const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const float *code, /* i : algebraic excitation */
- const float Es_pred, /* i : predicted scaled innovation energy */
- float *gain_pit, /* o : quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- float *gain_inov, /* o : gain of the innovation (used for normalization) */
- float *norm_gain_code, /* o : norm. gain of the codebook excitation */
- float *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */
-);
-
-/*! r: Return index of quantization */
-int16_t gain_enc_gaus(
- float *gain, /* i/o: Code gain to quantize */
- const int16_t bits, /* i : number of bits to quantize */
- const float lowBound, /* i : lower bound of quantizer (dB) */
- const float topBound /* i : upper bound of quantizer (dB) */
-);
-
-void E_corr_xy2(
- const float xn[], /* i : target vector */
- const float y1[], /* i : filtered excitation components 1 */
- const float y2[], /* i : filtered excitation components 2 */
- float g_corr[], /* o : correlations between x, y1, y2, y3, y4 */
- const int16_t L_subfr /* i : subframe size */
-);
-
-
-/*! r: coding type */
-int16_t find_uv(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *pitch_fr, /* i : pointer to adjusted fractional pitch (4 val.) */
- const float *voicing_fr, /* i : refined correlation for each subframes */
- const float *speech, /* i : pointer to speech signal for E computation */
- const float *ee, /* i : lf/hf Energy ratio for present frame */
- float *dE1X, /* o : sudden energy increase for S/M classifier */
- const float corr_shift, /* i : normalized correlation correction in noise */
- const float relE, /* i : relative frame energy */
- const float Etot, /* i : total energy */
- const float hp_E[], /* i : energy in HF */
- int16_t *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
- const int16_t last_core_orig, /* i : original last core */
- STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure */
-);
-
-/*! r: classification for current frames */
-int16_t signal_clas(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *speech, /* i : pointer to speech signal for E computation */
- const float *ee, /* i : lf/hf E ration for 2 half-frames */
- const float relE, /* i : frame relative E to the long term average */
- const int16_t L_look, /* i : look-ahead */
- int16_t *clas_mod /* o : class flag for NOOP detection */
-);
-
-void select_TC(
- const int16_t codec_mode, /* i : codec mode */
- const int16_t tc_cnt, /* i : TC frame counter */
- int16_t *coder_type, /* i/o: coder type */
- const int16_t localVAD /* i : VAD without hangover */
-);
-
-
-void wb_vad_init(
- VAD_HANDLE hVAD /* i/o: VAD data handle */
-);
-
-int16_t dtx_hangover_addition(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t vad_flag, /* i : VAD flag */
- const float snr, /* i : input single SNR estimate */
- const int16_t cldfb_subtraction, /* i : */
- int16_t *vad_hover_flag, /* o : VAD hangover flag */
- VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */
- NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */
- int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */
-);
-
-int16_t wb_vad(
- Encoder_State *st, /* i/o: encoder state structure */
- const float fr_bands[], /* i : per band input energy (contains 2 vectors) */
- int16_t *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */
- int16_t *clean_speech_HO, /* o : SC-VBR clean speech HO flag */
- int16_t *NB_speech_HO, /* o : SC-VBR NB speech HO flag */
- float *snr_sum_he, /* i : voicing metric from SAD */
- int16_t *localVAD_HE_SAD, /* o : HE_SAD decision without hangovers */
- int16_t *flag_noisy_speech_snr, /* o : */
- VAD_HANDLE hVAD, /* i/o: VAD handle */
- NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */
- float lp_speech, /* i : long term active speech energy average */
- float lp_noise /* i : long term noise energy */
-);
-
-void bw_detect(
- Encoder_State *st, /* i/o: Encoder State */
- const float signal_in[], /* i : input signal */
- float *spectrum, /* i : MDCT spectrum */
- const float *enerBuffer, /* i : energy buffer */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t mct_on /* i : flag MCT mode */
-);
-
-void set_bw(
- const int16_t element_mode, /* i : element mode */
- const int32_t element_brate, /* i : element bitrate */
- Encoder_State *st, /* i/o: Encoder State */
- const int16_t codec_mode /* i : codec mode */
-);
-
-float gaus_encode(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t i_subfr, /* i : subframe index */
- const float *h1, /* i : weighted filter input response */
- const float *xn, /* i : target vector */
- float *exc, /* o : pointer to excitation signal frame */
- float *mem_w0, /* o : weighting filter denominator memory */
- float *gp_clip_mem, /* o : memory of gain of pitch clipping algorithm */
- float *tilt_code, /* o : synthesis excitation spectrum tilt */
- float *code, /* o : algebraic excitation */
- float *gain_code, /* o : Code gain. */
- float *y2, /* o : zero-memory filtered adaptive excitation */
- float *gain_inov, /* o : innovation gain */
- float *voice_fac, /* o : voicing factor */
- float *gain_pit, /* o : adaptive excitation gain */
- float *norm_gain_code /* o : normalized innovative cb. gain */
-);
-
-void td_cng_enc_init(
- TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const int16_t Opt_DTX_ON, /* i : flag indicating DTX operation */
- const int16_t max_bwidth /* i : maximum encoded bandwidth */
-);
-
-void dtx(
- Encoder_State *st, /* i/o: encoder state structure */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t vad, /* i : VAD flag for DTX */
- const float speech[] /* i : Pointer to the speech frame */
-);
-
-void dtx_hangover_control(
- Encoder_State *st, /* i/o: encoder state structure */
- const float lsp_new[M] /* i : current frame LSPs */
-);
-
-
-void updt_enc_common(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void updt_IO_switch_enc(
- Encoder_State *st, /* i/o: state structure */
- const int16_t input_frame /* i : input frame length */
-);
-
-void transition_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t i_subfr, /* i : subframe index */
- int16_t *tc_subfr, /* i/o: TC subframe index */
- int16_t *Jopt_flag, /* i : joint optimization flag */
- int16_t *position, /* i/o: maximum of residual signal index */
- int16_t *T0, /* i/o: close loop integer pitch */
- int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
- int16_t *T0_min, /* i/o: lower limit for close-loop search */
- int16_t *T0_max, /* i/o: higher limit for close-loop search */
- float *exc, /* i/o: pointer to excitation signal frame */
- float *y1, /* o : zero-memory filtered adaptive excitation */
- const float *h1, /* i : weighted filter input response */
- const float *xn, /* i : target vector */
- float *xn2, /* o : target vector for innovation search */
- float *gp_cl, /* i/o: memory of gain of pitch clipping algorithm */
- float *gain_pit, /* o : adaptive excitation gain */
- float *g_corr, /* o : ACELP correlation values */
- int16_t *clip_gain, /* i/o: adaptive gain clipping flag */
- float **pt_pitch, /* o : floating pitch values */
- float *bwe_exc, /* i/o: excitation for SWB TBE */
- int16_t *unbits /* i/o: unused bits */
-);
-
-void tc_classif_enc(
- const int16_t L_frame, /* i : length of the frame */
- int16_t *tc_subfr, /* i/o: TC subframe index */
- int16_t *position, /* i/o: maximum of residual signal index */
- const int16_t attack_flag, /* i : attack flag */
- const int16_t pitch, /* i : open loop pitch estimates for first halfframe */
- const float *res /* i : pointer to the LP residual signal frame */
-);
-
-
-void gain_enc_tc(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t gains_mode[], /* i : gain bits */
- const int16_t i_subfr, /* i : subframe index */
- const float xn[], /* i : target vector */
- const float y2[], /* i : zero-memory filtered algebraic codebook excitation */
- const float code[], /* i : algebraic excitation */
- const float Es_pred, /* i : predicted scaled innovation energy */
- float *gain_pit, /* o : pitch gain / Quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- float *gain_inov, /* o : innovation gain */
- float *norm_gain_code /* o : norm. gain of the codebook excitation */
-);
-
-
-/*! r: comfort noise gain factor */
-float AVQ_cod(
- const float xri[], /* i : vector to quantize */
- int16_t xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */
- const int16_t nb_bits, /* i : number of allocated bits */
- const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
-);
-
-void AVQ_encmux(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t extl, /* i : extension layer */
- int16_t xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
- int16_t *nb_bits, /* i/o: number of allocated bits */
- const int16_t Nsv, /* i : number of subvectors */
- int16_t nq[], /* o : AVQ nq index */
- int16_t avq_bit_sFlag, /* i : flag indicating AVQ bit savings */
- int16_t trgtSvPos /* i : target SV for AVQ bit savings */
-);
-
-void ordr_esti(
- const int16_t k, /* i : sub-vector index */
- int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */
- int16_t svOrder[], /* i/o: AVQ sub-vector order */
- const int16_t Nsv /* i : total sub-vectors in a sub-frames */
-);
-
-void re8_cod(
- int16_t x[], /* i : point in RE8 (8-dimensional integer vector) */
- int16_t *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
- uint16_t *I, /* o : index of c (pointer to unsigned 16-bit word) */
- int16_t k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
-);
-
-void pre_exc(
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const int16_t L_frame, /* i : frame length */
- const float *speech, /* i : input speech */
- const float *p_Aq, /* i : 12k8 Lp coefficient */
- const float *p_A, /* i : unquantized A(q) filter with bandwidth expansion */
- const int16_t coder_type, /* i : coding type */
- const int16_t i_subfr, /* i : current sub frame indicator */
- float *Ap, /* o : weighted LP filter coefficients */
- const float *res, /* i : residual signal */
- float *h1, /* o : impulse response of weighted synthesis filter */
- float *xn, /* o : close-loop Pitch search target vector */
- float *cn, /* o : target vector in residual domain */
- float *mem_syn, /* i/o: memory of the synthesis filter */
- float *mem_w0, /* i/o: weighting filter denominator memory */
- const int16_t L_subfr /* i : subframe length */
-);
-
-
-void encod_amr_wb(
- Encoder_State *st, /* i/o: state structure */
- const float speech[], /* i : input speech */
- const float Aw[], /* i : weighted A(z) unquantized for subframes */
- const float Aq[], /* i : 12k8 Lp coefficient */
- const float *res, /* i : residual signal */
- float *syn, /* i/o: core synthesis */
- float *exc, /* i/o: current non-enhanced excitation */
- float *exc2, /* i/o: current enhanced excitation */
- float *pitch_buf, /* i/o: floating pitch values for each subframe */
- int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */
- const float *speech16k /* i : input speech @16kHz */
-);
-
-void stat_noise_uv_enc(
- Encoder_State *st, /* i/o: state structure */
- const float *epsP, /* i : LP prediction errors */
- const float *isp_new, /* i : immittance spectral pairs at 4th sfr */
- const float *isp_mid, /* i : immittance spectral pairs at 2nd sfr */
- float *Aq, /* i/o: A(z) quantized for the 4 subframes */
- float *exc2, /* i/o: excitation buffer */
- const int16_t uc_two_stage_flag /* o : flag undicating two-stage UC */
-);
-
-void re8_compute_base_index(
- const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */
- const int16_t ka, /* i : Identifier of the absolute leader related to x */
- uint16_t *I /* o : index */
-);
-
-void transf_cdbk_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const int16_t i_subfr, /* i : subframe index */
- float cn[], /* i/o: target vector in residual domain */
- float exc[], /* i/o: pointer to excitation signal frame */
- const float *p_Aq, /* i : 12k8 Lp coefficient */
- const float Ap[], /* i : weighted LP filter coefficients */
- const float h1[], /* i : weighted filter input response */
- float xn[], /* i/o: target vector */
- float xn2[], /* i/o: target vector for innovation search */
- float y1[], /* i/o: zero-memory filtered adaptive excitation */
- const float y2[], /* i : zero-memory filtered innovative excitation */
- const float Es_pred, /* i : predicited scaled innovation energy */
- float *gain_pit, /* i/o: adaptive excitation gain */
- const float gain_code, /* i : innovative excitation gain */
- float g_corr[], /* o : ACELP correlation values */
- const int16_t clip_gain, /* i : adaptive gain clipping flag */
- float *gain_preQ, /* o : prequantizer excitation gain */
- float code_preQ[], /* o : prequantizer excitation */
- int16_t *unbits /* i/o: number of AVQ unused bits */
-);
-void deemph_lpc(
- float *p_Aq_cuerr, /* i : LP coefficients current frame */
- float *p_Aq_old, /* i : LP coefficients previous frame */
- float *LPC_de_curr, /* o : De-emphasized LP coefficients current frame */
- float *LPC_de_old, /* o : De-emphasized LP coefficients previous frame*/
- const int16_t deemph_old );
-
-void Interpol_delay(
- float *out, /* o : pitch interpolation output */
- float *last, /* i : last frame pitch lag */
- float *current, /* i : current frame pitch lag */
- int16_t SubNum, /* i : subframe number */
- const float *frac /* i : interpolation constant */
-);
-
-void dequantize_uvg(
- int16_t iG1, /* i : gain 1 index */
- int16_t *iG2, /* i : gain 2 index */
- float *G, /* o : quantized gain */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void generate_nelp_excitation(
- int16_t *seed, /* i/o: random number seed */
- float *Gains, /* i : excitation gains */
- float *output, /* o : excitation output */
- float gain_fac /* i : gain factor */
-);
-
-void nelp_encoder(
- Encoder_State *st, /* i/o: encoder state */
- float *in, /* i : residual signal */
- float *exc, /* o : NELP quantized excitation signal */
- const int16_t reduce_gains );
-
-void encod_nelp(
- Encoder_State *st, /* i/o: state structure */
- const float *speech, /* i : input speech */
- const float Aw[], /* i : weighted A(z) unquantized for subframes */
- const float *Aq, /* i : 12k8 Lp coefficient */
- float *res, /* o : residual signal */
- float *synth, /* o : core synthesis */
- float *tmp_noise, /* o : long-term noise energy */
- float *exc, /* i/o: current non-enhanced excitation */
- float *exc2, /* i/o: current enhanced excitation */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc /* o : excitation for SWB TBE */
-);
-
-void realft(
- float *data, /* i/o: data array */
- int16_t n, /* i : length of data array */
- int16_t isign /* i : sign +1 or -1 */
-);
-
-ivas_error DTFS_new(
- DTFS_STRUCTURE **dtfs_out );
-
-void DTFS_copy(
- DTFS_STRUCTURE *Xout, /* o : DTFS */
- DTFS_STRUCTURE Xinp /* i : DTFS */
-);
-
-void DTFS_sub(
- DTFS_STRUCTURE *tmp, /* o : output DFTS */
- DTFS_STRUCTURE X1, /* i : DTFS input 1 */
- DTFS_STRUCTURE X2 /* i : DTFS input 2 */
-);
-
-void DTFS_to_fs(
- const float *x, /* i : Time domain signal */
- const int16_t N, /* i : Length of input vector */
- DTFS_STRUCTURE *X, /* o : DTFS structure with a, b, lag */
- const int32_t sampling_rate,
- const int16_t FR_flag /* i : FR flag */
-);
-
-void DTFS_fs_inv(
- DTFS_STRUCTURE *X, /* i : DTFS */
- float *x, /* o : time domain sig */
- const int16_t N, /* i : Output length */
- float ph0 /* i : Input phase */
-);
-
-void DTFS_car2pol(
- DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */
- /* input in Cartesion, output in Polar */
-);
-
-void DTFS_pol2car(
- DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */
- /* input in Polar, output in Cartesian */
-);
-
-/*! r: Return Input RMS between f1/f2 b4 scaling */
-float DTFS_setEngyHarm(
- float f1, /* i : lower band freq of input to control energy */
- float f2, /* i : upper band freq of input to control energy */
- float g1, /* i : lower band freq of output to control energy */
- float g2, /* i : upper band freq of output to control energy */
- float en2, /* i : Target Energy to set the DTFS to */
- DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of */
-);
-
-void DTFS_to_erb(
- DTFS_STRUCTURE X, /* i : DTFS input */
- float *out /* o : ERB output */
-);
-
-void DTFS_zeroPadd(
- const int16_t N, /* i : Target lag */
- DTFS_STRUCTURE *X /* i/o: DTFS */
-);
-
-/*! r: Energy */
-float DTFS_getEngy(
- DTFS_STRUCTURE X /* i : DTFS to compute energy of */
-);
-
-void DTFS_adjustLag(
- DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for */
- const int16_t N /* i : Target lag */
-);
-
-void DTFS_poleFilter(
- DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace */
- const float *LPC, /* i : LPCs */
- const int16_t N /* i : LPCORDER */
-);
-
-void DTFS_zeroFilter(
- DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace */
- const float *LPC, /* i : LPCs */
- const int16_t N /* i : LPCORDER */
-);
-
-float DTFS_alignment_full(
- DTFS_STRUCTURE X1_DTFS, /* i : reference DTFS */
- DTFS_STRUCTURE X2_DTFS, /* i : DTFS to shift */
- const int16_t num_steps /* i : resolution */
-);
-
-void DTFS_phaseShift(
- DTFS_STRUCTURE *X, /* i : DTFS to shift */
- float ph /* i : phase to shift */
-);
-
-void erb_add(
- float *curr_erb, /* i/o: current ERB */
- const int16_t l, /* i : current lag */
- const float *prev_erb, /* i : previous ERB */
- const int16_t pl, /* i : previous lag */
- const int16_t *index, /* i : ERB index */
- const int16_t num_erb /* i : number of ERBs */
-);
-
-void erb_slot(
- int16_t lag, /* i : input lag */
- int16_t *out, /* o : ERB slots */
- float *mfreq, /* i : ERB frequencies */
- int16_t num_erb /* i : number of ERBs */
-);
-
-void erb_diff(
- const float *prev_erb, /* i : previous ERB */
- const int16_t pl, /* i : previous lag */
- const float *curr_erb, /* i : current ERB */
- const int16_t l, /* i : current lag */
- const float *curr_lsp, /* i : current LSP coefficients */
- float *out, /* o : ERB difference */
- int16_t *index, /* i : ERB index */
- const int16_t num_erb /* i : Number of ERBs */
-);
-
-void DTFS_erb_inv(
- float *in, /* i : ERB inpt */
- int16_t *slot, /* i : ERB slots filled based on lag */
- float *mfreq, /* i : erb frequence edges */
- DTFS_STRUCTURE *X, /* o : DTFS after erb-inv */
- const int16_t num_erb /* i : Number of ERB bands */
-);
-
-ivas_error ppp_quarter_encoder(
- int16_t *returnFlag, /* o : return value */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- DTFS_STRUCTURE *CURRCW_Q, /* o : Quantized (amp/phase) DTFS */
- DTFS_STRUCTURE *TARGETCW, /* o : DTFS with quant phase but unquant Amp */
- const int16_t prevCW_lag, /* i : previous lag */
- DTFS_STRUCTURE vCURRCW_NQ, /* i : Unquantized DTFS */
- const float *curr_lpc, /* i : LPCS */
- float *lastLgainE, /* i/o: last low band gain */
- float *lastHgainE, /* i/o: last high band gain */
- float *lasterbE, /* i/o: last ERB vector */
- DTFS_STRUCTURE PREV_CW_E /* i : past DTFS */
-);
-
-ivas_error WIsyn(
- DTFS_STRUCTURE PREVCW, /* i : Prev frame DTFS */
- DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS */
- const float *curr_lpc, /* i : LPC */
- float *ph_offset, /* i/o: Phase offset to line up at end of frame */
- float *out, /* o : Waveform Interpolated time domain signal */
- const int16_t N, /* i : Number of samples of output to generate */
- const int16_t FR_flag /* i : called for post-smoothing in FR */
-);
-
-void set_ppp_mode(
- Encoder_State *st, /* i/o: encoder state structure */
- const int16_t noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */
- const int16_t clean_speech_HO, /* i : SC-VBR clean speech HO flag */
- const int16_t NB_speech_HO, /* i : SC-VBR NB speech HO flag */
- const int16_t localVAD_he /* i : HE-SAD flag without hangover */
-);
-
-ivas_error ppp_voiced_encoder(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t last_coder_type_raw, /* i : raw last_coder_type */
- const float old_pitch_buf[], /* i : buffer of old subframe pitch values */
- float *in, /* i : residual signal */
- float *out, /* o : Quantized residual signal */
- const int16_t delay, /* i : open loop pitch */
- float *lpc1, /* i : prev frame de-emphasized LPC */
- float *lpc2, /* i : current frame de-emphasized LPC */
- float *exc, /* i : previous frame quantized excitation */
- float *pitch /* o : floating pitch values for each subframe */
-);
-
-ivas_error encod_ppp(
- Encoder_State *st, /* i/o: state structure */
- const float speech[], /* i : input speech */
- const float Aw[], /* i : weighted A(z) unquantized for subframes */
- const float Aq[], /* i : 12k8 Lp coefficient */
- float *res, /* i/o: residual signal */
- float *synth, /* i/o: core synthesis */
- float *exc, /* i/o: current non-enhanced excitation */
- float *exc2, /* i/o: current enhanced excitation */
- float *pitch_buf, /* i/o: floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc /* o : excitation for SWB TBE */
-);
-
-void reset_rf_indices(
- RF_ENC_HANDLE hRF, /* i/o: RF state structure */
- const int16_t L_frame, /* i : frame length */
- int16_t *rf_target_bits_write );
-
-void signaling_enc_rf(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-ivas_error acelp_core_dec(
- Decoder_State *st, /* i/o: Decoder state structure */
- float output[], /* o : synthesis @internal Fs */
- float synth[], /* o : synthesis */
- float save_hb_synth[], /* o : HB synthesis */
- float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- float *voice_factors, /* o : voicing factors */
- float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- const int16_t sharpFlag, /* i : formant sharpening flag */
- float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
- int16_t *unbits, /* o : number of unused bits */
- int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
- const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const int16_t last_element_mode, /* i : last element mode */
- const int32_t last_element_brate, /* i : last element bitrate */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const int16_t read_sid_info /* i : read SID info flag */
-);
-
-void bass_psfilter_init(
- BPF_DEC_HANDLE hBPF /* o : BPF data handle */
-);
-
-void bass_psfilter(
- BPF_DEC_HANDLE hBPF, /* o : BPF data handle */
- const int16_t Opt_AMR_WB, /* i : AMR-WB IO flag */
- const float synth_in[], /* i : synthesis (at 16kHz) */
- const int16_t L_frame, /* i : length of the last frame */
- const float pitch_buf[], /* i : pitch for every subfr [0,1,2,3] */
- const int16_t bpf_off, /* i : do not use BPF when set to 1 */
- float v_stab, /* i : stability factor */
- float *v_stab_smooth, /* i : smoothed stability factor */
- const int16_t coder_type, /* i : coder_type */
- float bpf_noise_buf[] /* o : BPF error signal (at int_fs) */
-);
-
-void CNG_reset_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- float *pitch_buf, /* o : floating pitch for each subframe */
- float *voice_factors /* o : voicing factors */
-);
-
-void updt_dec(
- Decoder_State *st, /* i/o: state structure */
- const float *old_exc, /* i : buffer of excitation */
- const float *pitch_buf, /* i : floating pitch values for each subframe */
- const float Es_pred, /* i : predicited scaled innovation energy */
- const float *Aq, /* i : A(z) quantized for all subframes */
- const float *lsf_new, /* i : current frame LSF vector */
- const float *lsp_new, /* i : current frame LSP vector */
- const float voice_factors[], /* i : voicing factors */
- const float *old_bwe_exc, /* i : buffer of excitation */
- const float *gain_buf /* o : floating pitch gain for each subframe */
-);
-
-void updt_IO_switch_dec(
- const int16_t output_frame, /* i : output frame length */
- Decoder_State *st /* i/o: state structure */
-);
-
-void updt_dec_common(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t hq_core_type, /* i : HQ core type */
- const int16_t concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
- const float *synth /* i : decoded synthesis */
-);
-
-void td_cng_dec_init(
- DEC_CORE_HANDLE st /* i/o: decoder state structure */
-);
-
-void CNG_dec(
- Decoder_State *st, /* i/o: State structure */
- const int16_t last_element_mode, /* i : last element mode */
- float Aq[], /* o : LP coefficients */
- float *lsp_new, /* i/o: current frame LSPs */
- float *lsf_new, /* i/o: current frame LSFs */
- int16_t *allow_cn_step, /* o : allow cn step */
- int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- float *q_env );
-
-void swb_CNG_dec(
- Decoder_State *st, /* i/o: State structure */
- const float *synth, /* i : ACELP core synthesis at 32kHz */
- float *shb_synth, /* o : high-band CNG synthesis */
- const int16_t sid_bw /* i : 0-NB/WB, 1-SWB SID */
-);
-
-void lsf_dec(
- Decoder_State *st, /* i/o: State structure */
- const int16_t tc_subfr, /* i : TC subframe index */
- float *Aq, /* o : quantized A(z) for 4 subframes */
- int16_t *LSF_Q_prediction, /* o : LSF prediction mode */
- float *lsf_new, /* o : de-quantized LSF vector */
- float *lsp_new, /* o : de-quantized LSP vector */
- float *lsp_mid, /* o : de-quantized mid-frame LSP vector */
- const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
-);
-
-void isf_dec_amr_wb(
- Decoder_State *st, /* i/o: State structure */
- float *Aq, /* o : quantized A(z) for 4 subframes */
- float *isf_new, /* o : de-quantized ISF vector */
- float *isp_new /* o : de-quantized ISP vector */
-);
-
-void Es_pred_dec(
- float *Es_pred, /* o : predicted scaled innovation energy */
- const int16_t enr_idx, /* i : indice */
- const int16_t nb_bits, /* i : number of bits */
- const int16_t no_ltp /* i : no LTP flag */
-);
-
-void gaus_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t i_subfr, /* i : subframe index */
- float *code, /* o : gaussian excitation */
- float *norm_gain_code, /* o : gain of the normalized gaussian excitation */
- float *lp_gainp, /* i/o: lp filtered pitch gain(FER) */
- float *lp_gainc, /* i/o: lp filtered code gain (FER) */
- float *gain_inov, /* o : unscaled innovation gain */
- float *tilt_code, /* o : synthesis excitation spectrum tilt */
- float *voice_fac, /* o : estimated voicing factor */
- float *gain_pit, /* o : reset pitch gain */
- float *pt_pitch, /* o : reset floating pitch buffer */
- float *exc, /* o : excitation signal frame */
- float *gain_code, /* o : gain of the gaussian excitation */
- float *exc2 /* o : scaled excitation signal frame */
-);
-
-void gain_dec_amr_wb(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t core_brate, /* i : core bitrate */
- float *gain_pit, /* o : Quantized pitch gain */
- float *gain_code, /* o : Quantized codeebook gain */
- float *past_qua_en, /* i/o: gain quantization memory (4 words) */
- float *gain_inov, /* o : unscaled innovation gain */
- const float *code, /* i : algebraic code excitation */
- float *norm_gain_code /* o : norm. gain of the codebook excitation */
-);
-
-void gain_dec_lbr(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t coder_type, /* i : coding type */
- const int16_t i_subfr, /* i : subframe index */
- const float *code, /* i : algebraic excitation */
- float *gain_pit, /* o : quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- float *gain_inov, /* o : gain of the innovation (used for normalization) */
- float *norm_gain_code, /* o : norm. gain of the codebook excitation */
- float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */
- const int16_t L_subfr /* i : subframe length */
-);
-
-void gain_dec_mless(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t coder_type, /* i : coding type */
- const int16_t i_subfr, /* i : subframe number */
- const int16_t tc_subfr, /* i : TC subframe index */
- const float *code, /* i : algebraic code excitation */
- const float Es_pred, /* i : predicted scaled innov. energy */
- float *gain_pit, /* o : Quantized pitch gain */
- float *gain_code, /* o : Quantized codeebook gain */
- float *gain_inov, /* o : unscaled innovation gain */
- float *norm_gain_code /* o : norm. gain of the codebook excitation */
-);
-
-void gain_dec_SQ(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t i_subfr, /* i : subframe number */
- const float *code, /* i : algebraic code excitation */
- const float Es_pred, /* i : predicted scaled innov. energy */
- float *gain_pit, /* o : Quantized pitch gain */
- float *gain_code, /* o : Quantized codeebook gain */
- float *gain_inov, /* o : unscaled innovation gain */
- float *norm_gain_code /* o : norm. gain of the codebook excitation */
-);
-
-/*! r: quantized codebook gain */
-float gain_dec_gaus(
- const int16_t index, /* i : quantization index */
- const int16_t bits, /* i : number of bits to quantize */
- const float lowBound, /* i : lower bound of quantizer (dB) */
- const float topBound, /* i : upper bound of quantizer (dB) */
- const float gain_inov, /* i : unscaled innovation gain */
- float *norm_gain_code /* o : gain of normalized gaus. excit. */
-);
-
-/*! r: floating pitch value */
-float pit_decode_flt(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const int16_t L_frame, /* i : length of the frame */
- int16_t i_subfr, /* i : subframe index */
- const int16_t coder_type, /* i : coding type */
- int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- int16_t *T0, /* o : close loop integer pitch */
- int16_t *T0_frac, /* o : close loop fractional part of the pitch */
- int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */
- int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const int16_t L_subfr, /* i : subframe length */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-);
-
-void abs_pit_dec_flt(
- const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */
- int16_t pitch_index, /* i : pitch index */
- const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
- int16_t *T0, /* o : integer pitch lag */
- int16_t *T0_frac /* o : pitch fraction */
-);
-
-void delta_pit_dec_flt(
- const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */
- const int16_t pitch_index, /* i : pitch index */
- int16_t *T0, /* o : integer pitch lag */
- int16_t *T0_frac, /* o : pitch fraction */
- const int16_t T0_min /* i : delta search min */
-);
-
-void pit_Q_dec_flt(
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const int16_t pitch_index, /* i : pitch index */
- const int16_t nBits, /* i : # of Q bits */
- const int16_t delta, /* i : Half the CL searched interval */
- const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */
- const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
- int16_t *T0, /* o : integer pitch lag */
- int16_t *T0_frac, /* o : pitch fraction */
- int16_t *T0_min, /* i/o: delta search min */
- int16_t *T0_max, /* i/o: delta search max */
- int16_t *BER_detect /* o : BER detect flag */
-);
-
-void pit16k_Q_dec_flt(
- const int16_t pitch_index, /* i : pitch index */
- const int16_t nBits, /* i : # of Q bits */
- const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
- int16_t *T0, /* o : integer pitch lag */
- int16_t *T0_frac, /* o : pitch fraction */
- int16_t *T0_min, /* i/o: delta search min */
- int16_t *T0_max, /* i/o: delta search max */
- int16_t *BER_detect /* o : BER detect flag */
-);
-
-
-void inov_decode(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t sharpFlag, /* i : formant sharpening flag */
- const int16_t i_subfr, /* i : subframe index */
- const float *p_Aq, /* i : LP filter coefficients */
- const float tilt_code, /* i : tilt of of the excitation of previous subframe */
- const float pt_pitch, /* i : pointer to current subframe fractional pitch */
- float *code, /* o : algebraic excitation */
- const int16_t L_subfr /* i : subframe length */
-);
-
-void dec_acelp_1t64(
- Decoder_State *st, /* i/o: decoder state structure */
- float code[], /* o : algebraic (fixed) codebook excitation */
- const int16_t L_subfr /* i : subframe length */
-);
-
-void dec_acelp_2t32(
- Decoder_State *st, /* i/o: decoder state structure */
- float code[] /* o : algebraic (fixed) codebook excitation */
-);
-
-void dec_acelp_4t64(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t nbbits, /* i : number of bits per codebook */
- float code[], /* o : algebraic (fixed) codebook excitation */
- const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
-);
-
-
-void FEC_exc_estim(
- Decoder_State *st, /* i/o: Decoder static memory */
- const int16_t L_frame, /* i : length of the frame */
- float *old_exc, /* i/o: excitation buffer */
- float *exc2, /* o : excitation buffer (for synthesis) */
- float *exc_dct_in, /* o : GSC excitation in DCT domain */
- float *pitch_buf, /* o : Floating pitch for each subframe */
- float *tmp_tc, /* o : FEC pitch */
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc, /* i/o: excitation for SWB TBE */
- float *lsf_new, /* i : ISFs at the end of the frame */
- float *tmp_noise /* o : long-term noise energy */
-);
-
-void FEC_lsf2lsp_interp_flt(
- Decoder_State *st, /* i/o: Decoder static memory */
- const int16_t L_frame, /* i : length of the frame */
- float *Aq, /* o : calculated A(z) for 4 subframes */
- float *lsf, /* o : estimated LSF vector */
- float *lsp /* o : estimated LSP vector */
-);
-
-void FEC_lsf_estim_enc(
- Encoder_State *st, /* i : Encoder static memory */
- float *lsf /* o : estimated LSF vector */
-);
-
-float frame_energy(
- const int16_t L_frame, /* i : length of the frame */
- const float *pitch, /* i : pitch values for each subframe */
- const float *speech, /* i : pointer to speech signal for E computation */
- const float lp_speech, /* i : long term active speech energy average */
- float *frame_ener /* o : pitch-synchronous energy at frame end */
-);
-
-void FEC_SinOnset(
- float *exc, /* i/o: exc vector to modify */
- int16_t puls_pos, /* i : Last pulse position desired */
- int16_t T0, /* i : decoded first frame pitch */
- float enr_q, /* i : energy provided by the encoder */
- float *Aq, /* i : Lsp coefficient */
- const int16_t L_frame /* i : Frame length */
-);
-
-int16_t FEC_enhACB(
- const int16_t L_frame, /* i : Frame length */
- const int16_t last_L_frame, /* i : frame length of last frame */
- float *exc_io, /* i/o: Adaptive codebook memory */
- const int16_t new_pit, /* i : decoded first frame pitch */
- const int16_t puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */
- const float bfi_pitch /* i : Pitch used for concealment */
-);
-
-void FEC_scale_syn(
- const int16_t L_frame, /* i : length of the frame */
- int16_t clas, /* i/o: frame classification */
- const int16_t last_good, /* i : last good frame classification */
- float *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */
- const float *pitch, /* i : pitch values for each subframe */
- float enr_old, /* i : energy at the end of prvious frame */
- float enr_q, /* i : transmitted energy for current frame */
- const int16_t coder_type, /* i : coding type */
- const int16_t LSF_Q_prediction, /* i : LSF prediction mode */
- int16_t *scaling_flag, /* i/o: flag to indicate energy control of syn */
- float *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */
- float *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */
- const int16_t bfi, /* i : current frame BFI */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t prev_bfi, /* i : previous frame BFI */
- const int32_t last_core_brate, /* i : previous frame core bitrate */
- float *exc, /* i/o: excitation signal without enhancement */
- float *exc2, /* i/o: excitation signal with enhancement */
- const float Aq[], /* i : LP filter coefs */
- float *old_enr_LP, /* i/o: LP filter E of last good voiced frame */
- const float *mem_tmp, /* i : temp. initial synthesis filter states */
- float *mem_syn, /* o : initial synthesis filter states */
- const int16_t avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const int16_t force_scaling /* i : force scaling */
-);
-
-void FEC_pitch_estim(
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const int16_t last_core, /* i : last core */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t clas, /* i : current frame classification */
- const int16_t last_good, /* i : last good clas information */
- const float pitch_buf[], /* i : Floating pitch for each subframe */
- const float old_pitch_buf[], /* i : buffer of old subframe pitch values */
- float *bfi_pitch, /* i/o: update of the estimated pitch for FEC */
- int16_t *bfi_pitch_frame, /* o : frame length when pitch was updated */
- int16_t *upd_cnt, /* i/o: update counter */
- const int16_t coder_type );
-
-void FEC_encode(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i : configuration of the ACELP */
- const float *synth, /* i : pointer to synthesized speech for E computation */
- const int16_t coder_type, /* i : type of coder */
- int16_t clas, /* i : signal clas for current frame */
- const float *fpit, /* i : close loop fractional pitch buffer */
- const float *res, /* i : LP residual signal frame */
- int16_t *last_pulse_pos, /* i/o: Position of the last pulse */
- const int16_t L_frame, /* i : Frame length */
- const int32_t total_brate /* i : total codec bitrate */
-);
-
-int16_t FEC_pos_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */
- float *enr_q, /* o : Decoded energy */
- const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */
-);
-
-void improv_amr_wb_gs(
- const int16_t clas, /* i : bitrate allocated to the core */
- const int16_t coder_type, /* i : coder_type */
- const int32_t core_brate, /* i : bitrate allocated to the core */
- int16_t *seed_tcx, /* i/o: Seed used for noise generation */
- float *old_Aq, /* i/o: old LPC filter coefficient */
- float *mem_syn2, /* i/o: synthesis memory */
- const float lt_voice_fac, /* i/o: long term voice factor */
- const int16_t locattack, /* i : Flag for a detected attack */
- float *Aq, /* i/o: Decoded LP filter coefficient */
- float *exc2, /* i/o: Decoded complete excitation */
- float *mem_tmp, /* i/o: synthesis temporary memory */
- float *syn, /* i/o: Decoded synthesis to be updated */
- const float *pitch_buf, /* i : Decoded pitch buffer */
- const float Last_ener, /* i : Last energy */
- const int16_t rate_switching_reset, /* i : rate switching reset flag */
- const int16_t last_coder_type, /* i : Last coder_type */
- const int16_t VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
-);
-
-int16_t tc_classif(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void transition_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t i_subfr, /* i : subframe index */
- const int16_t tc_subfr, /* i : TC subframe index */
- int16_t *Jopt_flag, /* i : joint optimization flag */
- float *exc, /* i/o: current frame excitation signal */
- int16_t *T0, /* o : close loop integer pitch */
- int16_t *T0_frac, /* o : close loop fractional part of the pitch */
- int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */
- int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */
- float **pt_pitch, /* o : floating pitch values */
- int16_t *position, /* i/o: first glottal impulse position in frame */
- float *bwe_exc /* i/o: excitation for SWB TBE */
-);
-
-void gain_dec_tc(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t i_subfr, /* i : subframe number */
- const float Es_pred, /* i : predicted scaled innov. energy */
- const float *code, /* i : algebraic code excitation */
- float *gain_pit, /* o : pitch gain */
- float *gain_code, /* o : Quantized codeebook gain */
- float *gain_inov, /* o : unscaled innovation gain */
- float *norm_gain_code /* o : norm. gain of the codebook excit. */
-);
-
-void stat_noise_uv_dec(
- Decoder_State *st, /* i/o: decoder static memory */
- const float *lsp_new, /* i : end-frame LSP vector */
- const float *lsp_mid, /* i : mid-frame LSP vector */
- float *Aq, /* o : A(z) quantized for the 4 subframes */
- float *exc2, /* i/o: excitation buffer */
- const int16_t uc_two_stage_flag /* 1 : flag undicating two-stage UC */
-);
-
-void sc_vbr_dec_init_flt(
- SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */
-);
-
-void decod_nelp(
- Decoder_State *st, /* i/o: decoder static memory */
- float *tmp_noise, /* o : long term temporary noise energy */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *exc, /* o : adapt. excitation exc */
- float *exc2, /* o : adapt. excitation/total exc */
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc, /* o : excitation for SWB TBE */
- const int16_t bfi, /* i : bad frame indicator */
- float *gain_buf /* o : floating pitch gain for each subframe */
-);
-
-void nelp_decoder(
- Decoder_State *st, /* i/o: decoder static memory */
- float *exc_nelp, /* o : adapt. excitation/total exc */
- float *exc, /* o : adapt. excitation exc */
- int16_t bfi, /* i : frame error rate */
- const int16_t coder_type, /* i : coding type */
- float *gain_buf /* o : floating pitch gain for each subframe */
-);
-
-ivas_error decod_ppp(
- Decoder_State *st, /* i/o: state structure */
- const float Aq[], /* i : 12k8 Lp coefficient */
- float *pitch_buf, /* i/o: floating pitch values for each subframe */
- float *exc, /* i/o: current non-enhanced excitation */
- float *exc2, /* i/o: current enhanced excitation */
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc, /* o : excitation for SWB TBE */
- float *gain_buf, /* o : floating pitch gain for each subframe */
- const int16_t bfi /* i : BFI flag */
-);
-
-ivas_error ppp_quarter_decoder(
- Decoder_State *st, /* i/o: decoder state structure */
- DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS */
- int16_t prevCW_lag, /* i : Previous lag */
- float *lastLgainD, /* i/o: Last gain lowband */
- float *lastHgainD, /* i/o: Last gain highwband */
- float *lasterbD, /* i/o: Last ERB vector */
- int16_t bfi, /* i : FER flag */
- DTFS_STRUCTURE PREV_CW_D /* i : Previous DTFS */
-);
-
-ivas_error ppp_voiced_decoder(
- Decoder_State *st, /* i/o: state structure */
- float *out, /* o : residual signal */
- const float *lpc2, /* i : current frame LPC */
- float *exc, /* i : previous frame excitation */
- float *pitch, /* o : floating pitch values for each subframe */
- const int16_t bfi /* i : BFI flag */
-);
-
-void AVQ_demuxdec(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t xriq[], /* o : decoded subvectors [0..8*Nsv-1] */
- int16_t *nb_bits, /* i/o: number of allocated bits */
- const int16_t Nsv, /* i : number of subvectors */
- int16_t nq[], /* i/o: AVQ nq index */
- int16_t avq_bit_sFlag, /* i : flag for AVQ bit saving solution*/
- int16_t trgtSvPos /* i : target SV for AVQ bit savings */
-);
-
-
-void Init_post_filter_ivas(
- PFSTAT_HANDLE hPFstat /* i : post-filter state memories */
-);
-
-void nb_post_filt_ivas(
- const int16_t L_frame, /* i : frame length */
- const int16_t L_subfr, /* i : sub-frame length */
- PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */
- float *lp_noise, /* i/o: long term noise energy */
- const float tmp_noise, /* i : noise energy */
- float *synth, /* i/o: synthesis */
- const float *Aq, /* i : LP filter coefficient */
- const float *pitch_buf, /* i : Floating pitch for each subframe */
- const int16_t coder_type, /* i : coder_type -> deactivated in AUDIO */
- const int16_t BER_detect, /* i : BER detect flag */
- const int16_t disable_hpf /* i : flag to diabled HPF */
-);
-
-void decod_unvoiced(
- Decoder_State *st, /* i/o: decoder static memory */
- const float *Aq, /* i : LP filter coefficient */
- const float Es_pred, /* i : predicted scaled innov. energy */
- const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
- float *tmp_noise, /* o : long term temporary noise energy */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *exc, /* o : adapt. excitation exc */
- float *exc2, /* o : adapt. excitation/total exc */
- float *bwe_exc, /* i/o: excitation for SWB TBE */
- float *gain_buf /* o : floating pitch gain for each subfram */
-);
-
-void decod_tran(
- Decoder_State *st, /* i/o: decoder static memory */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t tc_subfr, /* i : TC subframe index */
- const float *Aq, /* i : LP filter coefficient */
- const float Es_pred, /* i : predicted scaled innov. energy */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *exc, /* i/o: adapt. excitation exc */
- float *exc2, /* i/o: adapt. excitation/total exc */
- float *bwe_exc, /* i/o: excitation for SWB TBE */
- int16_t *unbits, /* i/o: number of unused bits */
- const int16_t sharpFlag, /* i : formant sharpening flag */
- float *gain_buf /* o : floating pitch gain for each subframe */
-);
-
-ivas_error decod_gen_voic(
- Decoder_State *st, /* i/o: decoder static memory */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t sharpFlag, /* i : formant sharpening flag */
- const float *Aq, /* i : LP filter coefficient */
- const float Es_pred, /* i : predicted scaled innov. energy */
- const int16_t do_WI, /* i : FEC fast recovery flag */
- float *pitch_buf, /* o : floating pitch for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *exc, /* i/o: adapt. excitation exc */
- float *exc2, /* i/o: adapt. excitation/total exc */
- float *bwe_exc, /* i/o: excitation for SWB TBE */
- int16_t *unbits, /* i/o: number of unused bits */
- float *gain_buf, /* o : floating pitch gain for each subframe */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-);
-
-void decod_amr_wb(
- Decoder_State *st, /* i/o: decoder static memory */
- const float *Aq, /* i : LP filter coefficients */
- float *pitch_buf, /* o : floating pitch values for each subframe */
- float *exc, /* i/o: adapt. excitation exc */
- float *exc2, /* i/o: adapt. excitation/total exc */
- int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */
- float *voice_factors, /* o : voicing factors */
- float *gain_buf /* o : floating pitch gain for each subframe */
-);
-
-ivas_error init_decoder(
- Decoder_State *st, /* o : Decoder static variables structure */
- const int16_t idchan, /* i : channel ID */
- const MC_MODE mc_mode /* i : MC mode */
-);
-
-void destroy_cldfb_decoder_flt(
- Decoder_State *st /* o : Decoder static variables structure */
-);
-
-void HQ_core_dec_init_flt(
- HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */
-);
-
-void HQ_nbfec_init_flt(
- HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */
-);
-
-ivas_error evs_dec(
- Decoder_State *st, /* i/o: Decoder state structure */
- float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */
- float *output, /* o : output synthesis signal */
- FRAME_MODE frameMode /* i : Decoder frame mode */
-);
-
-void get_next_frame_parameters(
- Decoder_State *st /* i/o: Decoder state structure */
-);
-
-ivas_error amr_wb_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */
- float *output /* o : synthesis output */
-);
-
-void transf_cdbk_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const int16_t i_subfr, /* i : subframe index */
- const float Es_pred, /* i : predicited scaled innovation energy */
- const float gain_code, /* i : innovative excitation gain */
- float *gain_preQ, /* o : prequantizer excitation gain */
- float *norm_gain_preQ, /* o : normalized prequantizer excitation gain */
- float code_preQ[], /* o : prequantizer excitation */
- int16_t *unbits /* o : number of AVQ unused bits */
-);
-
-/*! r: decoded gain */
-float gain_dequant(
- int16_t index, /* i : quantization index */
- const float min_val, /* i : value of lower limit */
- const float max_val, /* i : value of upper limit */
- const int16_t bits /* i : number of bits to dequantize */
-);
-
-void hq_core_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *audio, /* i : input audio signal */
- const int16_t input_frame, /* i : frame length */
- const int16_t hq_core_type, /* i : HQ core type */
- const int16_t Voicing_flag, /* i : Voicing flag for FER method selection */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-int16_t detect_transient(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *in, /* i : input signal */
- const int16_t L /* i : length */
-);
-
-void wtda(
- const float *new_audio, /* i : input audio */
- float *wtda_audio, /* o : windowed audio */
- float *old_wtda, /* i/o: windowed audio from previous frame */
- const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
- const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
- const int16_t L /* i : length */
-);
-
-void wtda_ext(
- const float *new_audio, /* i : input audio */
- float *wtda_audio, /* o : windowed audio */
- const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
- const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
- const int16_t L, /* i : length */
- const uint16_t kernel_type /* i : transform kernel type (0 - 3) */
-);
-
-void tcx_get_windows_mode1_flt(
- const int16_t left_mode, /* i : overlap mode of left window half */
- const int16_t right_mode, /* i : overlap mode of right window half */
- float *left_win, /* o : left overlap window */
- float *right_win, /* o : right overlap window */
- float *left_win_int, /* o : left overlap window */
- float *right_win_int, /* o : right overlap window */
- const int16_t L /* i : length */
-);
-
-void direct_transform(
- const float *in32, /* i : input signal */
- float *out32, /* o : output transformation */
- const int16_t is_transient, /* i : transient flag */
- const int16_t L, /* i : length */
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-
-void interleave_spectrum(
- float *coefs, /* i/o: input and output coefficients */
- const int16_t length /* i : length of spectrum */
-);
-
-void hq_hr_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- float *coefs, /* i/o: transform-domain coefficients */
- const int16_t length, /* i : length of spectrum */
- int16_t *num_bits, /* i/o: number of available bits */
- const int16_t is_transient, /* i : transient flag */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void huff_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t N, /* i : Number of codewords to decode */
- const int16_t buffer_len, /* i : Number of bits to read */
- const int16_t num_lengths, /* i : Number of different huffman codeword lengths */
- const int16_t *thres, /* i : Threshold of first codeword of each length */
- const int16_t *offset, /* i : Offset for first codeword */
- const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */
- int16_t *index /* o : Decoded index */
-);
-
-void reordernorm(
- const int16_t *ynrm, /* i : quantization indices for norms */
- const int16_t *normqlg2, /* i : quantized norms */
- int16_t *idxbuf, /* o : reordered quantization indices */
- int16_t *normbuf, /* o : reordered quantized norms */
- const int16_t nb_sfm /* i : number of bands */
-);
-
-void diffcod(
- const int16_t N, /* i : number of sub-vectors */
- int16_t *y, /* i/o: indices of quantized norms */
- int16_t *difidx /* o : differential code */
-);
-
-void diffcod_lrmdct(
- const int16_t N, /* i : number of sub-vectors */
- const int16_t be_ref, /* i : band energy reference */
- int16_t *y, /* i/o: indices of quantized norms */
- int16_t *difidx, /* o : differential code */
- const int16_t is_transient /* i : transient flag */
-);
-
-void bitallocsum(
- int16_t *R, /* i : bit-allocation vector */
- const int16_t nb_sfm, /* i : number of sub-vectors */
- int16_t *sum, /* o : total number of bits allocated */
- int16_t *Rsubband, /* o : rate per subband (Q3) */
- const int16_t num_bits, /* i : number of bits */
- const int16_t length, /* i : length of spectrum */
- const int16_t *sfmsize /* i : Length of bands */
-);
-/*! r: BWE class */
-int16_t swb_bwe_gain_deq_flt(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t core, /* i : core */
- float *SWB_tenv, /* o : time-domain BWE envelope */
- float *SWB_fenv, /* o : frequency-domain BWE envelope */
- const int16_t hr_flag, /* i : high rate flag */
- const int16_t hqswb_clas /* i : HQ BWE class */
-);
-
-void save_old_syn(
- const int16_t L_frame, /* i : frame length */
- const float syn[], /* i : ACELP synthesis */
- float old_syn[], /* o : old synthesis buffer */
- float old_syn_12k8_16k[], /* i/o: old synthesis buffer */
- const float preemph_fac, /* i : preemphasis factor */
- float *mem_deemph /* i/o: deemphasis filter memory */
-);
-
-void hq_generic_hf_decoding(
- const int16_t HQ_mode, /* i : HQ mode */
- float *coeff_out1, /* i/o: BWE input & temporary buffer */
- const float *hq_generic_fenv, /* i : SWB frequency envelopes */
- float *coeff_out, /* o : SWB signal in MDCT domain */
- const int16_t hq_generic_offset, /* i : frequency offset for representing hq swb bwe*/
- int16_t *prev_L_swb_norm, /* i/o: last normalize length */
- const int16_t hq_swb_bwe_exc_clas, /* i : bwe excitation class */
- const int16_t *R );
-
-void hq_core_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- float out[], /* o : output synthesis */
- const int16_t output_frame, /* i : output frame length */
- const int16_t hq_core_type, /* i : HQ core type */
- const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */
- float *output /* o : LB synthesis in case of ACELP-HQ switch */
-);
-
-void IMDCT(
- float *x,
- float *old_syn_overl,
- float *syn_Overl_TDAC,
- float *xn_buf,
- const float *tcx_aldo_window_1_trunc,
- const float *tcx_aldo_window_2,
- const float *tcx_mdct_window_half,
- const float *tcx_mdct_window_minimum,
- const float *tcx_mdct_window_trans,
- const int16_t tcx_mdct_window_half_length,
- const int16_t tcx_mdct_window_min_length,
- int16_t index,
- const uint16_t kernel_type, /* i : TCX transform kernel type */
- const int16_t left_rect,
- const int16_t tcx_offset,
- const int16_t overlap,
- const int16_t L_frame,
- const int16_t L_frameTCX,
- const int16_t L_spec_TCX5,
- const int16_t L_frame_glob,
- const int16_t frame_cnt,
- const int16_t bfi,
- float *old_out,
- const int16_t FB_flag,
- Decoder_State *st,
- const int16_t fullband,
- float *acelp_zir );
-
-void hq_hr_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- float *t_audio_q, /* o : transform-domain coefficients */
- const int16_t length, /* i : frame length */
- const int16_t num_bits, /* i : number of available bits */
- int16_t *ynrm, /* o : norm quantization index vector */
- int16_t *is_transient, /* o : transient flag */
- int16_t *hqswb_clas, /* o : HQ SWB class */
- float *SWB_fenv, /* o : SWB frequency envelopes */
- const int16_t core_switching_flag /* i : Core switching flag */
-
-);
-
-void hdecnrm_context(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t N, /* i : number of norms */
- int16_t *index, /* o : indices of quantized norms */
- int16_t *n_length /* o : decoded stream length */
-);
-
-void hdecnrm_tran(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t N, /* i : number of norms */
- int16_t *index /* o : indices of quantized norms */
-);
-
-void hdecnrm_resize(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t N, /* i : number of SFMs */
- int16_t *index /* o : norm quantization index vector */
-);
-
-void hdecnrm(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t N, /* i : number of norms */
- int16_t *index /* o : indices of quantized norms */
-);
-
-/*! r: index of last band */
-int16_t find_last_band(
- const int16_t *bitalloc, /* i : bit allocation */
- const int16_t nb_sfm /* i : number of possibly coded bands */
-);
-
-void fill_spectrum(
- float *coeff, /* i/o: normalized MLT spectrum / nf spectrum */
- int16_t *R, /* i : number of pulses per band */
- const int16_t is_transient, /* i : transient flag */
- int16_t norm[], /* i : quantization indices for norms */
- const float *hq_generic_fenv, /* i : HQ GENERIC envelope */
- const int16_t hq_generic_offset, /* i : HQ GENERIC offset */
- const int16_t nf_idx, /* i : noise fill index */
- const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */
- const float env_stab, /* i : Envelope stability measure [0..1] */
- int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */
- float *energy_lt, /* i/o: Long-term energy measure for transient detection */
- int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
- const int16_t hq_generic_exc_clas, /* i : HF excitation class */
- const int16_t core_sfm, /* i : index of the end band for core */
- int16_t HQ_mode, /* i : HQ mode */
- float noise_level[], /* i : noise level for harmonic modes */
- int32_t core_brate, /* i : target bitrate */
- float prev_noise_level[], /* i/o: noise factor in previous frame */
- int16_t *prev_R, /* i/o: bit allocation info. in previous frame */
- float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */
- const int16_t *peak_idx, /* i : peak positions */
- const int16_t Npeaks, /* i : number of peaks */
- const int16_t *npulses, /* i : Number of assigned pulses per band */
- int16_t prev_is_transient, /* i : previous transient flag */
- float *prev_normq, /* i : previous norms */
- float *prev_env, /* i : previous noise envelopes */
- int16_t prev_bfi, /* i : previous bad frame indicator */
- const int16_t *sfmsize, /* i : Length of bands */
- const int16_t *sfm_start, /* i : Start of bands */
- const int16_t *sfm_end, /* i : End of bands */
- int16_t *prev_L_swb_norm, /* i/o: last normalize length for harmonic mode */
- int16_t prev_hq_mode, /* i : previous HQ mode */
- const int16_t num_sfm, /* i : Number of bands */
- const int16_t num_env_bands, /* i : Number of envelope bands */
- const int16_t element_mode /* i : element mode */
-);
-
-void de_interleave_spectrum(
- float *coefs, /* i/o: input and output coefficients */
- int16_t length /* i : length of spectrum */
-);
-
-void inverse_transform(
- const float *InMDCT, /* i : input MDCT vector */
- float *Out, /* o : output vector */
- const int16_t IsTransient, /* i : transient flag */
- const int16_t L, /* i : output frame length */
- const int16_t L_inner, /* i : length of the transform */
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-void window_ola(
- const float *ImdctOut, /* i : input */
- float *auOut, /* o : output audio */
- float *OldauOut, /* i/o: audio from previous frame */
- const int16_t L, /* i : length */
- const int16_t right_mode,
- const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
- const int16_t use_bfi_win, /* i : use BFI windowing */
- const int16_t oldHqVoicing, /* i : previous HqVoicing */
- float *oldgapsynth /* i : previous gapsynth */
-);
-
-void window_ola_ext(
- const float *ImdstOut, /* i : input */
- float *auOut, /* o : output audio */
- float *OldauOut, /* i/o: audio from previous frame */
- const int16_t L, /* i : length */
- const int16_t right_mode,
- const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
- const uint16_t kernel_type /* i : transform kernel type */
-);
-
-void map_quant_weight(
- const int16_t normqlg2[], /* i : quantized norms */
- int16_t wnorm[], /* o : weighted norm */
- const int16_t is_transient /* i : transient flag */
-);
-
-void recovernorm(
- const int16_t *const idxbuf, /* i : reordered quantization indices */
- int16_t *ynrm, /* o : recovered quantization indices */
- int16_t *normqlg2, /* o : recovered quantized norms */
- const int16_t nb_sfm /* i : number of subbands */
-);
-
-void reordvct(
- int16_t *y, /* i/o: vector to rearrange */
- const int16_t N, /* i : dimensions */
- int16_t *idx /* o : reordered vector index */
-);
-
-void bitalloc(
- int16_t *y, /* i : reordered norm of sub-vectors */
- int16_t *idx, /* i : reordered sub-vector indices */
- int16_t sum, /* i : number of available bits */
- int16_t N, /* i : number of norms */
- int16_t K, /* i : maximum number of bits per dimension */
- int16_t *r, /* o : bit-allacation vector */
- const int16_t *sfmsize, /* i : Length of bands */
- const int16_t hqswb_clas /* i : signal classification flag */
-);
-
-/*! r: Integer (truncated) number of allocated bits */
-int16_t BitAllocF(
- int16_t *y, /* i : norm of sub-vectors */
- int32_t bit_rate, /* i : bitrate */
- int16_t B, /* i : number of available bits */
- int16_t N, /* i : number of sub-vectors */
- int16_t *R, /* o : bit-allocation indicator */
- int16_t *Rsubband, /* o : sub-band bit-allocation vector (Q3) */
- const int16_t hqswb_clas, /* i : hq swb class */
- const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
-);
-
-/*! r: Integer (truncated) number of allocated bits */
-int16_t BitAllocWB(
- int16_t *y, /* i : norm of sub-vectors */
- int16_t B, /* i : number of available bits */
- int16_t N, /* i : number of sub-vectors */
- int16_t *R, /* o : bit-allocation indicator */
- int16_t *Rsubband ); /* o : sub-band bit-allocation vector (Q3) */
-
-/*! r: Number of low frequency bands */
-int16_t hvq_pvq_bitalloc(
- int16_t num_bits, /* i/o: Number of available bits (including gain bits) */
- const int32_t core_brate, /* i : bitrate */
- const int16_t bwidth, /* i : Encoded bandwidth */
- const int16_t *ynrm, /* i : Envelope coefficients */
- const int32_t manE_peak, /* i : Peak energy mantissa */
- const int16_t expE_peak, /* i : Peak energy exponent */
- int16_t *Rk, /* o : bit allocation for concatenated vector */
- int16_t *R, /* i/o: Global bit allocation */
- int16_t *sel_bands, /* o : Selected bands for encoding */
- int16_t *n_sel_bands /* o : No. of selected bands for encoding */
-);
-
-void floating_point_add_float(
- int32_t *mx, /* i/o: mantissa of the addend Q31 */
- int16_t *ex, /* i/o: exponent of the addend Q0 */
- const int32_t my, /* i : mantissa of the adder Q31 */
- const int16_t ey /* i : exponent of the adder Q0 */
-);
-
-/*! r: Number of bits needed */
-int16_t rc_get_bits2(
- const int16_t N, /* i : Number of bits currently used */
- const uint32_t range /* i : Range of range coder */
-);
-
-void rc_enc_init(
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- int16_t tot_bits /* i : Total bit budget */
-);
-
-void rc_encode(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- const uint32_t cum_freq, /* i : Cumulative frequency up to symbol */
- const uint32_t sym_freq, /* i : Symbol probability */
- const uint32_t tot /* i : Total cumulative frequency */
-);
-
-void rc_enc_finish(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */
-);
-
-void rc_enc_bits(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- const uint32_t value, /* i : Value to encode */
- const int16_t bits /* i : Number of bits used */
-);
-
-void rc_enc_uniform(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- uint32_t value, /* i : Value to encode */
- uint32_t tot /* i : Maximum value */
-);
-
-void rc_dec_init(
- Decoder_State *st, /* i/o: Decoder State */
- PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
- int16_t tot_bits /* i : Total bit budget */
-);
-
-/*! r: Decoded value */
-uint32_t rc_decode(
- int16_t *BER_detect, /* o : Bit error detection flag */
- PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
- uint32_t tot /* i : Total cumulative frequency */
-);
-
-void rc_dec_update(
- Decoder_State *st, /* i/o: Decoder State */
- PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
- const uint32_t cum_freq, /* i : Cumulative frequency */
- const uint32_t sym_freq /* i : Symbol frequency */
-);
-
-/*! r: Decoded value */
-uint32_t rc_dec_bits(
- Decoder_State *st, /* i/o: Decoder State */
- PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
- const int16_t bits /* i : Number of bits */
-);
-
-/*! r: Decoded value */
-uint32_t rc_dec_uniform(
- Decoder_State *st, /* i/o: Decoder State */
- PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
- const uint32_t tot /* i : Maximum value */
-);
-
-void rc_dec_finish(
- Decoder_State *st, /* i/o: decoder state structure */
- PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */
-);
-
-/*! r: number of bits encoded */
-int16_t pvq_core_enc(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- float coefs_norm[], /* i/o: normalized coefficients to encode */
- float coefs_quant[], /* o : quantized coefficients */
- const int16_t bits_tot, /* i : total number of bits */
- const int16_t nb_sfm, /* i : number of bands */
- const int16_t *sfm_start, /* i : Subband start coefficient */
- const int16_t *sfm_end, /* i : Subband end coefficient */
- const int16_t *sfmsize, /* i : subband width */
- int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
- int16_t *Rs, /* i/o: Integer bit allocation */
- int16_t *npulses, /* o : number of pulses */
- int16_t *maxpulse, /* i : maximum pulse per band */
- const int16_t core /* i : number of bands */
-);
-
-/*! r: number of bits decoded */
-int16_t pvq_core_dec(
- Decoder_State *st, /* i/o: Decoder state */
- const int16_t *sfm_start, /* i : indices of first coeffs in the bands */
- const int16_t *sfm_end, /* i : indices of last coeffs in the bands */
- const int16_t *sfmsize, /* i : band sizes */
- float coefs_quant[], /* o : output MDCT */
- const int16_t bits_tot, /* i : bit budget */
- const int16_t nb_sfm, /* i : number of bands */
- int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */
- int16_t *Rs, /* i/o: Integer bit allocation */
- int16_t *npulses, /* o : number of pulses per band */
- int16_t *maxpulse, /* o : maximum pulse per band */
- const int16_t core /* i : core */
-);
-
-void pvq_encode(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- const float *x, /* i : vector to quantize */
- int16_t *y, /* o : quantized vector (non-scaled integer)*/
- float *xq, /* o : quantized vector (scaled float) */
- const int16_t pulses, /* i : number of allocated pulses */
- const int16_t N, /* i : Length of vector */
- const float gain /* i : Gain */
-);
-
-void pvq_decode(
- Decoder_State *st, /* i/o: Decoder State */
- PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
- float *xq, /* o : decoded vector (scaled float) */
- int16_t *y, /* o : decoded vector (non-scaled short)*/
- const int16_t K, /* i : number of allocated pulses */
- const int16_t N, /* i : Length of vector */
- const float gain /* i : Gain */
-);
-
-void rangeCoderFinalizationFBits(
- const int16_t Brc, /* i : Current number of decoded bits */
- const uint32_t INTrc, /* i : Range coder state */
- int16_t *FBits /* i : Fractional finalization bits */
-);
-
-void bandBitsAdjustment(
- const int16_t Brc, /* i : Current number of read quanta in range coder */
- const uint32_t INTrc, /* i : Range coder state */
- const int16_t Bavail, /* i : Available number of quanta */
- const int16_t Nbands, /* i : Number of bands */
- const int16_t D, /* i : Remaining number of bands to encode */
- const int16_t L, /* i : Size of current band */
- const int16_t Bband, /* i : Quanta allocation for current band */
- const int16_t Breserv, /* i : Quanta reservoir */
- int16_t *Bband_adj, /* o : Actual used number of quanta */
- int16_t *Brem, /* o : Quanta remaining */
- int16_t *Breservplus /* o : Quanta pool size */
-);
-
-void conservativeL1Norm(
- const int16_t L, /* i : Length of vector segment */
- const int16_t Qvec, /* i : Assigned number of quanta */
- const int16_t Fcons, /* i : Conservative rounding flag */
- const int16_t Qavail, /* i : Input quanta remaining */
- const int16_t Qreserv, /* i : Input quanta in reservoir */
- const int16_t Dspec, /* i : assigned diracs from bitalloc */
- int16_t *Dvec, /* o : actual number of diracs */
- int16_t *Qspare, /* o : Output quanta remaining */
- int16_t *Qreservplus, /* o : Output quanta in reservoir */
- int16_t *Dspecplus /* o : Output number of diracs */
-);
-
-void NearOppSplitAdjustment(
- const int16_t qband, /* i : quanta for current band */
- const int16_t qzero, /* i : range coder finalization quanta */
- const int16_t Qac, /* i : range coder current quanta */
- const uint32_t INTac, /* i : range coder state */
- const int16_t qglobal, /* i : quanta input */
- const int16_t FlagCons, /* i : conservative rounding flag */
- const int16_t Np, /* i : number of parts */
- const int16_t Nhead, /* i : first part */
- const int16_t Ntail, /* i : remaining parts */
- const int16_t Nnear, /* i : length of near component */
- const int16_t Nopp, /* i : length of opposite component */
- int16_t oppRQ3, /* i : ratio */
- int16_t *qnear, /* o : quantized near */
- int16_t *qopp, /* o : quantized opposite */
- int16_t *qglobalupd /* o : quanta remaining */
-);
-
-/*! r: Approximate integer division for positive input */
-int32_t intLimCDivPos(
- const int32_t NUM, /* i : numerator */
- const int16_t DEN /* i : denominator */
-);
-
-/*! r: Approximate integer division */
-int16_t shrtCDivSignedApprox_flt(
- const int16_t num, /* i : numerator */
- const int16_t den /* i : denominator */
-);
-
-void QuantaPerDsDirac(
- const int16_t td, /* i : Length of vector segment */
- const int16_t dsDiracIndex, /* i : Quanta table index */
- const uint8_t *const *dimFrQuanta, /* i : Quanta lookup table */
- int16_t *Quanta /* i : Quanta */
-);
-
-void obtainEnergyQuantizerDensity(
- const int16_t L_in, /* i : left vector energy */
- const int16_t R_in, /* i : right vector energy */
- int16_t *Density /* o : quantizer density */
-);
-
-void densityAngle2RmsProjDec(
- const int16_t D, /* i : density */
- const int16_t indexphi, /* i : decoded index from AR dec */
- int16_t *oppQ15, /* o : opposite */
- int16_t *nearQ15, /* o : near */
- int16_t *oppRatioQ3 /* o : ratio */
-);
-
-void densityAngle2RmsProjEnc(
- const int16_t D, /* i : density */
- const int16_t phiQ14uq, /* i : angle */
- int16_t *indexphi, /* o : index */
- int16_t *oppQ15, /* o : opposite */
- int16_t *nearQ15, /* o : near */
- int16_t *oppRatioQ3 /* o : ratio */
-);
-
-void env_adj(
- const int16_t *pulses, /* i : number of pulses per band */
- const int16_t length, /* i : length of spectrum */
- const int16_t last_sfm, /* i : Index of last band */
- float *adj, /* o : Adjustment factors for the envelope */
- const float env_stab, /* i : Envelope stability parameter */
- const int16_t *sfmsize /* i : Length of bands */
-);
-
-float env_stability(
- const int16_t *ynrm, /* i : Norm vector for current frame */
- const int16_t nb_sfm, /* i : Number of sub-bands */
- int16_t *mem_norm, /* i/o: Norm vector memory from past frame */
- int16_t *mem_env_delta, /* i/o: Envelope stability memory for smoothing*/
- const int16_t core_switching_flag /* i : Core switching flag */
-);
-
-/*! r: New speech/music state */
-float env_stab_smo(
- float env_stab, /* i : env_stab value */
- float *env_stab_state_p, /* i/o: env_stab state probabilities */
- int16_t *ho_cnt /* i/o: hangover counter for speech state */
-);
-void core_switching_post_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- // const float *old_inp_12k8, /* i : old input signal @12.8kHz */
- float *old_inp_12k8, /* i : old input signal @12.8kHz */
- // const float *old_inp_16k, /* i : old input signal @16kHz */
- float *old_inp_16k, /* i : old input signal @16kHz */
- // const float A[] /* i : unquant. LP filter coefs. */
- Word16 A_fx[], /* i : unquant. LP filter coefs. */
- Word16 Q_new );
-ivas_error core_switching_post_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- float *synth, /* i/o: output synthesis */
- float *output, /* i/o: LB synth/upsampled LB synth */
- float output_mem[], /* i : OLA memory from last TCX/HQ frame */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const int16_t output_frame, /* i : frame length */
- const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */
- const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */
- const int16_t nchan_out, /* i : number of output channels */
- const int16_t last_element_mode /* i : element mode of previous frame */
-);
-
-ivas_error core_switching_pre_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t output_frame, /* i : frame length */
- const int32_t last_core_brate_st0, /* i : channel 0 last core bitrate */
- const int16_t nchan_out, /* i : number of output channels */
- const int16_t last_element_mode, /* i : last_element_mode */
- const int32_t last_element_brate /* i : last element bitrate */
-);
-
-void bandwidth_switching_detect(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void bw_switching_pre_proc(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *old_syn_12k8_16k, /* i : ACELP core synthesis @ 12.8kHz or 16kHz */
- const int32_t last_element_brate, /* i : last element bitrate */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-void updt_bw_switching(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *synth /* i : float synthesis signal */
-);
-
-void swb_tbe_reset(
- float mem_csfilt[],
- float mem_genSHBexc_filt_down_shb[],
- float state_lpc_syn[],
- float syn_overlap[],
- float state_syn_shbexc[],
- float *tbe_demph,
- float *tbe_premph,
- float mem_stp_swb[],
- float *gain_prec_swb );
-
-void swb_tbe_reset_synth(
- float genSHBsynth_Hilbert_Mem[],
- float genSHBsynth_state_lsyn_filt_shb_local[] );
-
-void find_td_envelope(
- const float inp[],
- const int16_t len,
- const int16_t len_h,
- float mem_h[],
- float out[] );
-
-void fb_tbe_reset_enc(
- float elliptic_bpf_2_48k_mem[][4],
- float *prev_fb_energy );
-
-void fb_tbe_reset_synth(
- float fbbwe_hpf_mem[][4],
- float *prev_fbbwe_ratio );
-
-void wb_tbe_extras_reset(
- float mem_genSHBexc_filt_down_wb2[],
- float mem_genSHBexc_filt_down_wb3[] );
-
-void wb_tbe_extras_reset_synth(
- float state_lsyn_filt_shb[],
- float state_lsyn_filt_dwn_shb[],
- float mem_resamp_HB[] );
-
-void tbe_celp_exc_flt(
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- float *bwe_exc, /* i/o: BWE excitation */
- const int16_t L_frame, /* i : frame length */
- const int16_t L_subfr, /* i : subframe length */
- const int16_t i_subfr, /* i : subframe index */
- const int16_t T0, /* i : integer pitch lag */
- const int16_t T0_frac, /* i : fraction of lag */
- float *error, /* i/o: error */
- const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
-);
-
-void prep_tbe_exc(
- const int16_t L_frame, /* i : length of the frame */
- const int16_t L_subfr, /* i : subframe length */
- const int16_t i_subfr, /* i : subframe index */
- const float gain_pit, /* i : Pitch gain */
- const float gain_code, /* i : algebraic codebook gain */
- const float code[], /* i : algebraic excitation */
- const float voice_fac, /* i : voicing factor */
- float *voice_factors, /* o : TBE voicing factor */
- float bwe_exc[], /* i/o: excitation for TBE */
- const float gain_preQ, /* i : prequantizer excitation gain */
- const float code_preQ[], /* i : prequantizer excitation */
- const int16_t T0, /* i : integer pitch variables */
- const int16_t coder_type, /* i : coding type */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- const int16_t flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
-);
-
-void synthesise_fb_high_band(
- const float excitation_in[], /* i : full band excitation */
- float output[], /* o : high band speech - 14.0 to 20 kHz */
- const float fb_exc_energy, /* i : full band excitation energy */
- const float ratio_float, /* i : energy ratio */
- const int16_t L_frame, /* i : ACELP frame length */
- const int16_t bfi, /* i : BFI flag */
- float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */
- float bpf_memory[][4] /* i/o: memory for elliptic bpf 48k */
-);
-
-void elliptic_bpf_48k_generic(
- const float input[], /* i : input signal */
- float output[], /* o : output signal */
- float memory[][4], /* i/o: 4 arrays for memory */
- const float full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 */
-);
-
-void HQ_FEC_processing(
- Decoder_State *st, /* i/o: decoder state structure */
- float *t_audio_q, /* o : MDCT coeffs. (for synthesis) */
- int16_t is_transient, /* i : Old flag for transient */
- float ynrm_values[][MAX_PGF], /* i : Old average Norm values for each group of bands */
- float r_p_values[][MAX_ROW], /* i : Computed y-intercept and slope by Regression */
- int16_t num_Sb, /* i : Number of sub-band group */
- int16_t nb_sfm, /* i : Number of sub-band */
- int16_t *Num_bands_p, /* i : Number of coeffs. for each sub-band */
- int16_t output_frame, /* i : Frame size */
- const int16_t *sfm_start, /* i : Start of bands */
- const int16_t *sfm_end /* i : End of bands */
-);
-
-void HQ_FEC_Mem_update(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *t_audio_q,
- float *normq,
- int16_t *ynrm,
- const int16_t *Num_bands_p,
- const int16_t is_transient,
- const int16_t hqswb_clas,
- const int16_t c_switching_flag,
- const int16_t nb_sfm,
- const int16_t num_Sb,
- float *mean_en_high,
- const int16_t hq_core_type, /* i : normal or low-rate MDCT(HQ) core */
- const int16_t output_frame /* i : Frame size */
-);
-
-void time_domain_FEC_HQ(
- Decoder_State *st, /* i : Decoder State */
- float *wtda_audio, /* i : input */
- float *out, /* o : output audio */
- const float mean_en_high, /* i : transient flag */
- const int16_t output_frame /* i : Frame size */
-);
-
-void save_synthesis_hq_fec(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *output, /* i : decoded synthesis */
- const int16_t output_frame, /* i : decoded synthesis */
- CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
-);
-
-void Next_good_after_burst_erasures(
- const float *ImdctOut, /* i : input */
- float *auOut, /* o : output audio */
- float *OldauOut, /* i/o: audio from previous frame */
- const int16_t ol_size /* i : overlap size */
-);
-
-
-void reset_preecho_dec(
- HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle */
-);
-
-void preecho_sb(
- const int32_t core_brate, /* i : core bitrate */
- const float wtda_audio[], /* i : imdct signal */
- float *rec_sig, /* i : reconstructed signal, output of the imdct transform */
- const int16_t framelength, /* i : frame length */
- float *memfilt_lb, /* i/o: memory */
- float *mean_prev_hb, /* i/o: memory */
- float *smoothmem, /* i/o: memory */
- float *mean_prev, /* i/o: memory */
- float *mean_prev_nc, /* i/o: memory */
- float *wmold_hb, /* i/o: memory */
- int16_t *prevflag, /* i/o: flag */
- int16_t *pastpre, /* i/o: flag */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void hq2_core_configure(
- const int16_t frame_length, /* i : frame length */
- const int16_t num_bits, /* i : number of bits */
- const int16_t is_transient, /* i : transient flag */
- int16_t *bands,
- int16_t *length,
- int16_t band_width[],
- int16_t band_start[],
- int16_t band_end[],
- Word32 *L_qint, /* o : Q29 */
- Word16 *eref_fx, /* o : Q10 */
- Word16 *bit_alloc_weight_fx, /* o : Q13 */
- int16_t *gqlevs,
- int16_t *Ngq,
- int16_t *p2a_bands,
- float *p2a_th,
- float *pd_thresh,
- float *ld_slope,
- float *ni_coef,
- float *ni_pd_th,
- int32_t bwe_br );
-
-void hq_lr_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- float t_audio[], /* i/o: transform-domain coefs. */
- const int16_t inner_frame, /* i : inner frame length */
- int16_t *num_bits, /* i/o: number of available bits */
- const int16_t is_transient /* i : transient flag */
-);
-
-void hq_lr_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- float yout[], /* o : transform-domain output coefs. */
- const int16_t inner_frame, /* i : inner frame length */
- int16_t num_bits, /* i : number of available bits */
- int16_t *is_transient /* o : transient flag */
-);
-
-void hq2_bit_alloc(
- const float band_energy[], /* i : band energy of each subband */
- const int16_t bands, /* i : total number of subbands in a frame */
- Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */
- int16_t *bit_budget, /* i/o: bit bugdet */
- int16_t *p2a_flags, /* i : HF tonal indicator */
- const Word16 weight_fx, /* i : weight (Q13) */
- const int16_t band_width[], /* i : Sub band bandwidth */
- const int16_t num_bits, /* i : available bits */
- const int16_t hqswb_clas, /* i : HQ2 class information */
- const int16_t bwidth, /* i : input bandwidth */
- const int16_t is_transient /* i : indicator HQ_TRANSIENT or not */
-);
-
-void hq2_noise_inject(
- float y2hat[],
- const int16_t band_start[],
- const int16_t band_end[],
- const int16_t band_width[],
- float Ep[],
- float Rk[],
- const int16_t npulses[],
- int16_t ni_seed,
- const int16_t bands,
- const int16_t ni_start_band,
- const int16_t bw_low,
- const int16_t bw_high,
- const float enerL,
- const float enerH,
- float last_ni_gain[],
- float last_env[],
- int16_t *last_max_pos_pulse,
- int16_t *p2a_flags,
- int16_t p2a_bands,
- const int16_t hqswb_clas,
- const int16_t bwidth,
- const int32_t bwe_br );
-
-void mdct_spectrum_denorm(
- const int32_t inp_vector[],
- float y2[],
- const int16_t band_start[],
- const int16_t band_end[],
- const int16_t band_width[],
- const float band_energy[],
- const int16_t npulses[],
- const int16_t bands,
- const float ld_slope,
- const float pd_thresh );
-
-void reverse_transient_frame_energies(
- float band_energy[], /* o : band energies */
- const int16_t bands /* i : number of bands */
-);
-
-
-void hvq_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t num_bits, /* i : Number of available bits */
- const int32_t core_brate, /* i : Core bitrate */
- const int16_t *ynrm, /* i : Envelope coefficients */
- int16_t *R, /* i/o: Bit allocation/updated bit allocation */
- float *noise_level, /* o : Noise level */
- int16_t *peak_idx, /* o : Peak position vector */
- int16_t *Npeaks, /* o : Total number of peaks */
- float *coefsq_norm, /* o : Output vector */
- const int16_t core /* i : Core */
-);
-
-void hq_configure_bfi(
- int16_t *nb_sfm, /* o : Number of sub bands */
- int16_t *num_Sb, /* o : Number of FEC sub bands ? */
- int16_t *num_bands_p, /* o : FEC sub bands */
- const int16_t **sfmsize, /* o : Subband bandwidths */
- const int16_t **sfm_start, /* o : Subband start coefficients */
- const int16_t **sfm_end /* o : Subband end coefficients */
-);
-
-void swb_bwe_enc_lr(
- Encoder_State *st, /* i/o: encoder state structure */
- const float m_core[], /* i : core synthesis (MDCT) */
- const float m_orig[], /* i/o: scaled orig signal (MDCT) */
- float m[], /* o : output, SWB part (MDCT) */
- const int32_t total_brate, /* i : total bitrate for selecting subband pattern */
- int16_t BANDS,
- int16_t *band_start,
- int16_t *band_end,
- float *band_energy,
- int16_t *p2a_flags,
- const int16_t hqswb_clas,
- int16_t lowlength,
- int16_t highlength,
- int16_t *prev_frm_index,
- const int16_t har_bands,
- int16_t *prev_frm_hfe2,
- int16_t *prev_stab_hfe2,
- int16_t band_width[],
- const float y2_ni[],
- int16_t *ni_seed );
-
-void swb_bwe_dec_lr(
- Decoder_State *st, /* i/o: decoder state structure */
- const float m_core[], /* i : lowband synthesis */
- float m[], /* o : highband synthesis with lowband zeroed */
- const int32_t total_brate, /* i : total bitrate for selecting subband pattern */
- int16_t BANDS,
- int16_t *band_start,
- int16_t *band_end,
- float *band_energy,
- int16_t *p2a_flags,
- const int16_t hqswb_clas,
- int16_t lowlength,
- int16_t highlength,
- const int16_t har_bands,
- int16_t *prev_frm_hfe2,
- int16_t *prev_stab_hfe2,
- int16_t band_width[],
- const float y2_ni[],
- int16_t *ni_seed );
-
-int16_t get_usebit_npswb(
- const int16_t hqswb_clas );
-
-void GetPredictedSignal(
- const float *predBuf, /* i : prediction buffer */
- float *outBuf, /* o : output buffer */
- const int16_t lag, /* i : prediction buffer offset */
- const int16_t fLen, /* i : length of loop (output) */
- const float gain /* i : gain to be applied */
-);
-
-void convert_lagIndices_pls2smp(
- int16_t lagIndices_in[],
- int16_t nBands_search,
- int16_t lagIndices_out[],
- const float sspectra[],
- const int16_t sbWidth[],
- const int16_t fLenLow );
-
-void FindNBiggest2_simple(
- const float *inBuf, /* i : input buffer (searched) */
- GainItem *g, /* o : N biggest components found */
- const int16_t nIdx, /* i : search length */
- int16_t *n, /* i : number of components searched (N biggest) */
- const int16_t N_NBIGGESTSEARCH );
-
-void updat_prev_frm(
- float y2[],
- float t_audio[],
- const int32_t bwe_br,
- const int16_t length,
- const int16_t inner_frame,
- const int16_t bands,
- const int16_t bwidth,
- const int16_t is_transient,
- const int16_t hqswb_clas,
- int16_t *prev_hqswb_clas,
- int16_t *prev_SWB_peak_pos,
- int16_t prev_SWB_peak_pos_tmp[],
- int16_t *prev_frm_hfe2,
- int16_t *prev_stab_hfe2,
- const int16_t bws_cnt );
-
-void hf_parinitiz(
- const int32_t total_brate,
- const int16_t hqswb_clas,
- int16_t lowlength,
- int16_t highlength,
- int16_t wBands[],
- const int16_t **subband_search_offset,
- const int16_t **subband_offsets,
- int16_t *nBands,
- int16_t *nBands_search,
- int16_t *swb_lowband,
- int16_t *swb_highband );
-
-float spectrumsmooth_noiseton(
- float spectra[],
- const float spectra_ni[],
- float sspectra[],
- float sspectra_diff[],
- float sspectra_ni[],
- const int16_t fLenLow,
- int16_t *ni_seed );
-
-void noiseinj_hf(
- float xSynth_har[],
- const float th_g[],
- const float band_energy[],
- float *prev_En_sb,
- const int16_t p2a_flags[],
- const int16_t BANDS,
- const int16_t band_start[],
- const int16_t band_end[],
- const int16_t fLenLow );
-
-void noise_extr_corcod(
- float spectra[],
- const float spectra_ni[],
- float sspectra[],
- float sspectra_diff[],
- float sspectra_ni[],
- const int16_t fLenLow,
- int16_t prev_hqswb_clas,
- float *prev_ni_ratio );
-
-void genhf_noise(
- float noise_flr[],
- float xSynth_har[],
- float *predBuf,
- int16_t bands, /* i : total number of subbands in a frame */
- int16_t harmonic_band, /* i : Number of LF harmonic frames */
- int16_t har_freq_est2,
- int16_t pos_max_hfe2,
- int16_t *pul_res,
- GainItem pk_sf[],
- const int16_t fLenLow,
- const int16_t fLenHigh,
- const int16_t sbWidth[],
- const int16_t lagIndices[],
- const int16_t subband_offsets[],
- const int16_t subband_search_offset[] );
-
-void ton_ene_est(
- float xSynth_har[],
- float be_tonal[],
- float band_energy[],
- int16_t band_start[],
- int16_t band_end[],
- int16_t band_width[],
- const int16_t fLenLow,
- const int16_t fLenHigh,
- int16_t bands,
- int16_t har_bands,
- float ni_lvl,
- GainItem pk_sf[],
- int16_t *pul_res );
-
-void Gettonl_scalfact(
- float *outBuf, /* o : synthesized spectrum */
- const float *codbuf, /* i : core coder */
- const int16_t fLenLow, /* i : lowband length */
- const int16_t fLenHigh, /* i : highband length */
- int16_t harmonic_band, /* i : Number of LF harmonic frames */
- int16_t bands, /* i : total number of subbands in a frame */
- float *band_energy, /* i : band energy of each subband */
- int16_t *band_start, /* i : subband start indices */
- int16_t *band_end, /* i : subband end indices */
- const int16_t p2aflags[],
- float be_tonal[],
- GainItem *pk_sf,
- int16_t *pul_res );
-
-void SpectrumSmoothing(
- float *inBuf,
- float *outBuf,
- const int16_t fLen,
- const float th_cut );
-
-void hq2_bit_alloc_har(
- float *y, /* i : band energy of sub-vectors */
- int16_t B, /* i : number of available bits */
- int16_t N, /* i : number of sub-vectors */
- Word32 *L_Rsubband,
- int16_t p2a_bands,
- int32_t core_brate, /* i : core bitrate */
- int16_t p2a_flags[],
- int16_t band_width[] );
-
-void GetSynthesizedSpecThinOut(
- const float *predBuf,
- float *outBuf,
- const int16_t nBands,
- const int16_t *sbWidth,
- const int16_t *lagIndices,
- const float *lagGains,
- const int16_t predBufLen );
-
-void return_bits_normal2(
- int16_t *bit_budget,
- const int16_t p2a_flags[],
- const int16_t bands,
- const int16_t bits_lagIndices[] );
-
-void GetlagGains(
- const float *predBuf,
- const float *band_energy,
- const int16_t nBands,
- const int16_t *sbWidth,
- const int16_t *lagIndices,
- const int16_t predBufLen,
- float *lagGains );
-
-void preset_hq2_swb(
- const int16_t hqswb_clas,
- const int16_t band_end[],
- int16_t *har_bands,
- int16_t p2a_bands,
- const int16_t length,
- const int16_t bands,
- int16_t *lowlength,
- int16_t *highlength,
- float m[] );
-
-void post_hq2_swb(
- const float m[],
- const int16_t lowlength,
- const int16_t highlength,
- const int16_t hqswb_clas,
- const int16_t har_bands,
- const int16_t bands,
- const int16_t p2a_flags[],
- const int16_t band_start[],
- const int16_t band_end[],
- float y2[],
- int16_t npulses[] );
-
-void har_denorm_pulcnt(
- float spectra[], /* i/o: MDCT domain spectrum */
- const int16_t band_start[], /* i : Number subbands/Frame */
- const int16_t band_end[], /* i : Band Start of each SB */
- const float band_energy[], /* i : Band end of each SB */
- const int16_t band_width[],
- const int16_t npulses[],
- const int16_t har_bands /* i : No. of harmonic bands */
-);
-
-int16_t har_est(
- float spectra[],
- const int16_t N,
- int16_t *har_freq_est1,
- int16_t *har_freq_est2,
- int16_t *flag_dis,
- int16_t *prev_frm_hfe2,
- const int16_t subband_search_offset[],
- const int16_t sbWidth[],
- int16_t *prev_stab_hfe2 );
-
-void spt_shorten_domain_pre(
- const int16_t band_start[],
- const int16_t band_end[],
- const int16_t prev_SWB_peak_pos[],
- const int16_t BANDS,
- const int32_t bwe_br,
- int16_t new_band_start[],
- int16_t new_band_end[],
- int16_t new_band_width[] );
-
-void spt_shorten_domain_band_save(
- const int16_t bands,
- const int16_t band_start[],
- const int16_t band_end[],
- const int16_t band_width[],
- int16_t org_band_start[],
- int16_t org_band_end[],
- int16_t org_band_width[] );
-
-void spt_shorten_domain_band_restore(
- const int16_t bands,
- int16_t band_start[],
- int16_t band_end[],
- int16_t band_width[],
- const int16_t org_band_start[],
- const int16_t org_band_end[],
- const int16_t org_band_width[] );
-
-void spt_swb_peakpos_tmp_save(
- const float y2[],
- const int16_t bands,
- const int16_t band_start[],
- const int16_t band_end[],
- int16_t prev_SWB_peak_pos_tmp[] );
-
-void hq_ecu(
- const float *prevsynth, /* i : buffer of previously synthesized signal */
- float *ecu_rec, /* o : reconstructed frame in tda domain */
- int16_t *time_offs, /* i/o: Sample offset for consecutive frame losses*/
- float *X_sav, /* i/o: Stored spectrum of prototype frame */
- int16_t *num_p, /* i/o: Number of identified peaks */
- int16_t *plocs, /* i/o: Peak locations */
- float *plocsi, /* i/o: Interpolated peak locations */
- const float env_stab, /* i : Envelope stability parameter */
- int16_t *last_fec, /* i/o: Flag for usage of pitch dependent ECU */
- const int16_t ph_ecu_HqVoicing, /* i : HQ Voicing flag */
- int16_t *ph_ecu_active, /* i : Phase ECU active flag */
- float *gapsynth, /* o : Gap synthesis */
- const int16_t prev_bfi, /* i : indicating burst frame error */
- const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/
- float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/
- float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */
- float *beta_mute, /* o : Factor for long-term mute */
- const int16_t output_frame, /* i : frame length */
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void peakfinder(
- const float *x0, /* i : vector from which the maxima will be found */
- const int16_t len0, /* i : length of input vector */
- int16_t *plocs, /* o : the indicies of the identified peaks in x0 */
- int16_t *cInd, /* o : number of identified peaks */
- const float sel, /* i : The amount above surrounding data for a peak to be identified */
- const int16_t endpoints /* i : Flag to include endpoints in peak search */
-);
-
-/*! r: interpolated maximum position */
-float imax_pos(
- const float *y /* i : Input vector for peak interpolation */
-);
-
-
-void fft3(
- const float X[], /* i : input frame */
- float Y[], /* o : DFT of input frame */
- const int16_t n /* i : block length (must be radix 3) */
-);
-
-void ifft3(
- const float X[], /* i : input frame */
- float Y[], /* o : iDFT of input frame */
- const int16_t n /* i : block length (must be radix 3) */
-);
-
-/*! r: updated estimate of background noise */
-void minimumStatistics(
- float *noiseLevelMemory, /* i/o: internal state */
- int16_t *noiseLevelIndex, /* i/o: internal state */
- int16_t *currLevelIndex, /* i/o: internal state (circular buffer) */
- float *noiseEstimate, /* i/o: previous estimate of background noise */
- float *lastFrameLevel, /* i/o: level of the last frame */
- float currentFrameLevel, /* i : level of the current frame */
- const float minLev, /* i : minimum level */
- const int16_t buffSize /* i : buffer size */
-);
-
-void E_ACELP_toeplitz_mul(
- const float R[],
- const float c[],
- float d[] );
-
-void E_ACELP_innovative_codebook(
- const float *exc, /* i : pointer to the excitation frame */
- const int16_t T0, /* i : integer pitch lag */
- const int16_t T0_frac, /* i : fraction of lag */
- const int16_t T0_res, /* i : pitch resolution */
- const float pitch_gain, /* i : adaptive codebook gain */
- const float tilt_code, /* i : tilt factor */
- ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */
- const int16_t i_subfr, /* i : subframe index */
- const float *Aq, /* i : quantized LPC coefficients */
- const float *h1, /* i : impulse response of weighted synthesis filter */
- const float *xn, /* i : Close-loop Pitch search target vector */
- const float *cn, /* i : Innovative codebook search target vector */
- const float *y1, /* i : zero-memory filtered adaptive excitation */
- float *y2, /* o : zero-memory filtered algebraic excitation */
- const int16_t acelpautoc, /* i : autocorrelation mode enabled */
- int16_t **pt_indice, /* i/o: quantization indices pointer */
- float *code, /* o : innovative codebook */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t last_L_frame, /* i : length of the last frame */
- const int32_t total_brate /* i : total bitrate */
-);
-
-int16_t E_ACELP_code43bit(
- const float code[],
- uint32_t *ps,
- int16_t *p,
- uint16_t idxs[] );
-void D_ACELP_indexing_ivas(
- float code[],
- PulseConfig config,
- const int16_t num_tracks,
- int16_t prm[],
- int16_t *BER_detect );
-
-void D_ACELP_decode_43bit(
- uint16_t idxs[],
- float code[],
- int16_t *pulsestrack );
-
-void fcb_pulse_track_joint_decode_ivas(
- uint16_t *idxs,
- const int16_t wordcnt,
- uint32_t *index_n,
- const int16_t *pulse_num,
- const int16_t track_num );
-
-void lag_wind_flt(
- float r[], /* i/o: autocorrelations */
- const int16_t m, /* i : order of LP filter */
- const int32_t sr_core, /* i : sampling rate */
- const int16_t strength /* i : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
-);
-
-void adapt_lag_wind_fx(
- float r[], /* i/o: autocorrelations */
- const int16_t m, /* i : order of LP filter */
- const int16_t Top, /* i : open loop pitch lags from curr. frame (or NULL if n/a) */
- const float Tnc, /* i : open loop pitch gains from curr. frame (NULL if n/a) */
- const int32_t sr_core /* i : core sampling rate */
-);
-
-void core_coder_reconfig(
- Encoder_State *st, /* i/o: encoder state structure */
- const int32_t last_total_brate /* i : last total bitrate */
-);
-
-void core_coder_mode_switch(
- Encoder_State *st, /* i/o: encoder state structure */
- const int32_t last_total_brate, /* i : last bitrate */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
-);
-
-void enc_acelp_tcx_main(
- Encoder_State *st, /* i/o: encoder state structure */
- const float new_samples[], /* i : new samples */
- float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const float lsp_new[M], /* i : LSPs at the end of the frame */
- const float lsp_mid[M], /* i : LSPs at the middle of the frame */
- float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- float *voice_factors, /* o : voicing factors */
- float pitch_buf[], /* o : floating pitch for each subframe */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void getTCXMode_ivas(
- Decoder_State *st, /* i/o: decoder memory state */
- Decoder_State *st0, /* i : bitstream */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
-);
-
-void getTCXWindowing_ivas(
- const Word16 core, /* i : current frame mode */
- const Word16 last_core, /* i : last frame mode */
- const Word16 element_mode, /* i : element mode */
- TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
- Decoder_State *st0 /* i : bitstream */
-);
-
-void getLPCparam_ivas(
- Decoder_State *st, /* i/o: decoder memory state */
- int16_t param_lpc[], /* o : LTP parameters */
- Decoder_State *st0, /* i : bitstream */
- const int16_t ch, /* i : channel */
- const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */
-);
-
-void getTCXparam_ivas(
- Decoder_State *st, /* i/o: Decoder State handle */
- Decoder_State *st0, /* i : bitstream */
- CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */
- int16_t param[], /* o : decoded parameters */
- const int16_t bits_common, /* i : number of common bits */
- const int16_t start_bit_pos, /* i : position of the start bit */
- const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */
- int16_t p_param[2], /* o : pointer to parameters for next round of bs reading*/
- int16_t nTnsBitsTCX10[2],
- const int16_t pre_past_flag );
-
-void pitch_pred_linear_fit_flt(
- const int16_t nbLostCmpt, /* i : bfi counter */
- const int16_t last_good, /* i : last classification type */
- float *old_pitch_buf, /* i : pitch lag buffer */
- float *old_fpitch, /* i/o: pitch used for initial ACB generation */
- float *T0_out, /* o : estimated close loop pitch */
- const int16_t pit_min, /* i : Minimum pitch lag */
- const int16_t pit_max, /* i : Maximum pitch lag */
- float *mem_pitch_gain, /* i : lag pitch gain [0] is the most recent subfr lag */
- const int16_t limitation,
- const int16_t plc_use_future_lag, /* i : number of subframes to predict */
- int16_t *extrapolationFailed, /* o : flag if extrap decides not to change the pitch */
- const int16_t nb_subfr /* i : number of ACELP subframes */
-);
-
-void get_subframe_pitch_flt(
- const int16_t nSubframes, /* i : number of subframes */
- float pitchStart, /* i : starting pitch lag (in subframe -1) */
- float pitchEnd, /* i : ending pitch lag (in subframe nSubframes-1) */
- float *pitchBuf /* o : interpolated pitch lag per subframe */
-);
-
-void core_encode_openloop(
- Encoder_State *st, /* i/o: encoder state structure */
- const float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const float lsp_new[M], /* i : LSPs at the end of the frame */
- const float lsp_mid[M], /* i : LSPs at the middle of the frame */
- float *pitch_buf, /* i/o: floating pitch values for each subfr*/
- float *voice_factors, /* o : voicing factors */
- float *ptr_bwe_exc, /* o : excitation for SWB TBE */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void core_acelp_tcx20_switching(
- Encoder_State *st, /* i/o: encoder state structure */
- float non_staX, /* i : unbound non-stationarity for sp/mu clas */
- float *pitch_fr, /* i/o: fraction pitch values */
- float *voicing_fr, /* i/o: fractional voicing values */
- const float currTempFlatness, /* i : flatness */
- const float lsp_mid[M], /* i : LSPs at the middle of the frame */
- const float stab_fac /* i : LP filter stability */
-);
-
-void core_encode_twodiv(
- Encoder_State *st, /* i/o: coder memory state */
- const float new_samples[], /* i : new samples */
- float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void core_encode_update(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void core_encode_update_cng(
- Encoder_State *st, /* i/o: encoder state structure */
- float *timeDomainBuffer,
- float *A,
- const float Aw[] /* i : weighted A(z) unquant. for subframes*/
-);
-
-void core_signal_analysis_high_bitrate(
- const float *new_samples,
- const int16_t T_op[3], /* i : open-loop pitch values for quantiz. */
- float lsp_new[],
- float lsp_mid[],
- Encoder_State *st,
- float *mdst_spectrum[2],
- int16_t pTnsSize[],
- int16_t pTnsBits[],
- int16_t param_core[],
- int16_t *ltpBits,
- float *windowed_samples, /* i/o: backup of windowed time signal */
- const int16_t L_frame,
- const int16_t L_frameTCX,
- const int16_t last_element_mode,
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void encode_acelp_gains(
- const float *code,
- const int16_t gains_mode,
- const float mean_ener_code,
- const int16_t clip_gain,
- ACELP_CbkCorr *g_corr,
- float *gain_pit,
- float *gain_code,
- int16_t **pt_indice,
- float *past_gcode,
- float *gain_inov,
- const int16_t L_subfr,
- float *code2,
- float *gain_code2,
- const int16_t noisy_speech_flag );
-
-int16_t gain_enc_gacelp_uv(
- const float *code, /* i : algebraic excitation */
- const float *code2, /* i : gaussian excitation */
- const int16_t lcode, /* i : Subframe size */
- const float mean_ener, /* i : quantized mean energy of the frame */
- float *gain_pit, /* o : quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- float *gain_code2, /* o : quantized codebook gain */
- ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */
- float *past_gcode, /* i/o: past gain of code */
- float *gain_inov, /* o : unscaled innovation gain */
- const int16_t noisy_speech_flag /* i : noisy speech flag */
-);
-
-int16_t Mode2_gain_enc_mless(
- const float *code, /* i : algebraic excitation */
- const int16_t lcode, /* i : Subframe size */
- float *gain_pit, /* o : quantized pitch gain */
- float *gain_code, /* o : quantized codebook gain */
- ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */
- const float mean_ener, /* i : mean_ener defined in open-loop (3 bits) */
- const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- float *past_gcode, /* i/o: past gain of code */
- float *gain_inov, /* o : unscaled innovation gain */
- const int16_t coder_type /* i : type of coder */
-);
-
-void decode_acelp_gains(
- const float *code,
- const int16_t gains_mode,
- const float mean_ener_code,
- float *gain_pit,
- float *gain_code,
- int16_t **pt_indice,
- float *past_gpit,
- float *past_gcode,
- float *gain_inov,
- const int16_t L_subfr,
- float *code2,
- float *gain_code2 );
-
-void gain_dec_gacelp_uv(
- int16_t index, /* i/o: Quantization index vector */
- const float *code, /* i : algebraic code excitation */
- const float *code2, /* i : algebraic code excitation */
- const float mean_ener, /* i : mean energy */
- const int16_t lcode, /* i : Subframe size */
- float *gain_pit, /* o : Quantized pitch gain */
- float *gain_code, /* o : Quantized codebook gain */
- float *gain_code2, /* o : Quantized codebook gain */
- float *past_gpit, /* i/o: past gain of pitch */
- float *past_gcode, /* i/o: past energy of code */
- float *gain_inov /* o : unscaled innovation gain */
-);
-
-void limit_T0_voiced_ivas(
- const int16_t nbits,
- const int16_t res,
- const int16_t T0, /* i : rough pitch estimate around which the search is done */
- const int16_t T0_frac, /* i : pitch estimate fractional part */
- const int16_t T0_res, /* i : pitch resolution */
- int16_t *T0_min, /* o : lower pitch limit */
- int16_t *T0_min_frac, /* o : lower pitch limit */
- int16_t *T0_max, /* o : higher pitch limit */
- int16_t *T0_max_frac, /* o : higher pitch limit */
- const int16_t pit_min, /* i : Minimum pitch lag */
- const int16_t pit_max /* i : Maximum pitch lag */
-);
-
-
-/*! r: floating pitch value */
-float Mode2_pit_decode_flt(
- const int16_t coder_type, /* i : coding model */
- const int16_t i_subfr, /* i : subframe index */
- const int16_t L_subfr, /* i : sub-frame length */
- int16_t **pt_indice, /* i/o: quantization indices pointer */
- int16_t *T0, /* o : close loop integer pitch */
- int16_t *T0_frac, /* o : close loop fractional part of the pitch */
- int16_t *T0_res, /* i/o: pitch resolution */
- int16_t *T0_min, /* i/o: lower limit for close-loop search */
- int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */
- int16_t *T0_max, /* i/o: higher limit for close-loop search */
- int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */
- const int16_t pit_min,
- const int16_t pit_fr1,
- const int16_t pit_fr1b,
- const int16_t pit_fr2,
- const int16_t pit_max,
- const int16_t pit_res_max );
-
-void Mode2_abs_pit_dec_flt(
- int16_t *T0, /* o : integer pitch lag */
- int16_t *T0_frac, /* o : pitch fraction */
- int16_t *T0_res, /* o : pitch resolution */
- int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
- const int16_t pit_min,
- const int16_t pit_fr1,
- const int16_t pit_fr2,
- const int16_t pit_res_max );
-
-void Mode2_delta_pit_dec_flt(
- int16_t *T0, /* o : integer pitch lag */
- int16_t *T0_frac, /* o : pitch fraction */
- int16_t T0_res, /* i : pitch resolution */
- int16_t *T0_min, /* i : delta search min */
- int16_t *T0_min_frac, /* i : delta search min */
- int16_t **pt_indice /* i/o: pointer to Vector of Q indexes */
-);
-
-void formant_post_filt_ivas(
- PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */
- float *synth_in, /* i : 12k8 synthesis */
- const float *Aq, /* i : LP filter coefficient */
- float *synth_out, /* i/o: input signal */
- const int16_t L_frame, /* i : frame length */
- const int16_t L_subfr, /* i : sub-frame length */
- const float lp_noise, /* i : background noise energy */
- const int32_t brate, /* i : bitrate */
- const int16_t off_flag /* i : Off flag */
-);
-
-
-int16_t dlpc_avq(
- int16_t *index, /* i : Quantization indices */
- float *LSF_Q, /* o : Quantized LSF vectors */
- const int16_t numlpc, /* i : Number of sets of lpc */
- const int32_t sr_core /* i : internal sampling rate */
-);
-
-int16_t decode_lpc_avq(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t numlpc, /* i : Number of sets of lpc */
- int16_t *param_lpc, /* o : lpc parameters */
- const int16_t ch, /* i : channel */
- const int16_t element_mode, /* i : element mode */
- const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */
-);
-
-
-void vlpc_2st_dec_flt(
- float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */
- int16_t *indx, /* i : index[] (4 bits per words) */
- const int16_t mode, /* i : 0=abs, >0=rel */
- const int32_t sr_core /* i : internal sampling rate */
-);
-
-void lsf_weight_2st_flt(
- const float *lsfq,
- float *w,
- const int16_t mode,
- const int32_t sr_core );
-
-void mdct_window_sine_flt(
- float *window,
- const int32_t Fs,
- const int16_t n,
- const int16_t window_type,
- const int16_t element_mode );
-
-void mdct_window_aldo_flt(
- float *window1,
- float *window2,
- const int16_t n );
-
-void AVQ_cod_lpc(
- const float nvec[], /* i : vector to quantize */
- int16_t nvecq[], /* o : quantized normalized vector (assuming the bit budget is enough) */
- int16_t *indx, /* o : index[] (4 bits per words) */
- const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
-);
-
-void AVQ_dec_lpc_ivas(
- const int16_t indx[], /* i : index[] (4 bits per words) */
- int16_t nvecq[], /* o : vector quantized */
- const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
-);
-
-void vlpc_1st_dec_flt(
- const int16_t index, /* i : codebook index */
- float *lsfq, /* i/o: i:prediction o:quantized lsf */
- const int32_t sr_core );
-
-void WindowSignal_flt(
- TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- int16_t offset, /* i : left folding point offset relative to the input signal pointer */
- const int16_t left_overlap_mode, /* i : overlap mode of left window half */
- const int16_t right_overlap_mode, /* i : overlap mode of right window half */
- int16_t *left_overlap_length, /* o : TCX window left overlap length */
- int16_t *right_overlap_length, /* o : TCX window right overlap length */
- const float in[], /* i : input signal */
- int16_t *L_frame, /* i/o: frame length */
- float out[], /* o : output windowed signal */
- const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */
- const int16_t fullband /* i : fullband flag */
-);
-
-void HBAutocorrelation(
- TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- const int16_t left_mode, /* i : overlap mode of left window half */
- const int16_t right_mode, /* i : overlap mode of right window half */
- float speech[], /* i : speech */
- int16_t L_frame_glob, /* i/o: frame length */
- float *r /* o : autocorrelations vector */
-);
-
-void TNSAnalysis(
- TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- const int16_t L_frame, /* i : frame length */
- int16_t L_spec, /* i : length of the spectrum */
- const int16_t transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
- const int16_t isAfterACELP, /* i : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
- float spectrum[], /* i : MDCT spectrum of the subframe */
- TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */
- const float ltp_gain, /* i : ltp gain */
- STnsData *pTnsData, /* o : TNS data */
- int8_t *pfUseTns, /* o : Flag indicating if TNS is used */
- float *predictionGain /* o : TNS prediction gain */
-);
-
-void CalculateTnsFilt(
- STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
- const float pSpectrum[], /* i : MDCT spectrum */
- STnsData *pTnsData, /* o : TNS data struct */
- float *predictionGain /* o : TNS prediction gain */
-);
-
-void ShapeSpectrum(
- TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- const float A[], /* i : quantized coefficients NxAz_q[M+1] */
- float gainlpc[], /* o : MDCT gains for the previous frame */
- const int16_t L_frame_glob, /* i : frame length */
- int16_t L_spec, /* i : length of the spectrum */
- float spectrum[], /* i/o: MDCT spectrum */
- const int8_t fUseTns, /* i : Flag indicating if TNS is used */
- Encoder_State *st, /* i/o: encoder state structure */
- float *scf /* i : scale factors */
-);
-
-void QuantizeSpectrum(
- Encoder_State *st, /* i/o: encoder state structure */
- const float A[], /* i : quantized coefficients NxAz_q[M+1] */
- const Word16 Aqind[], /* i : frame-independent quantized coeffs (M+1) */
- float gainlpc[], /* i : MDCT gains of the previous frame */
- float synth[], /* o : synthesis buffer */
- const int16_t nb_bits, /* i : bit budget */
- const int16_t tnsSize, /* i : number of tns parameters put into prm */
- int16_t prm[], /* o : tcx parameters */
- const int16_t frame_cnt, /* i : frame counter in the super_frame */
- CONTEXT_HM_CONFIG *hm_cfg, /* i : HM configuration */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-/*! r: index of next coefficient */
-int16_t get_next_coeff_mapped_ivas(
- int16_t ii[2], /* i/o: coefficient indexes */
- int32_t *pp, /* o : peak(1)/hole(0) indicator */
- int16_t *idx, /* o : index in unmapped domain */
- CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
-);
-
-
-void ACcontextMapping_encode2_no_mem_s17_LC(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- int16_t *x,
- int16_t nt,
- int16_t lastnz,
- int16_t nbbits,
- int16_t resQMaxBits,
- CONTEXT_HM_CONFIG *hm_cfg );
-
-int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas(
- Decoder_State *st, /* i/o: decoder state */
- int16_t *x, /* o : decoded spectrum */
- int16_t nt, /* i : size of spectrum */
- int16_t nbbits, /* i : bit budget */
- int16_t resQMaxBits, /* i : residual coding maximum bits */
- CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
-);
-
-int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC(
- const int16_t *x,
- const int16_t nt,
- int16_t *lastnz,
- int16_t *nEncoded,
- const int16_t target,
- int16_t *stop,
- CONTEXT_HM_CONFIG *hm_cfg );
-
-void RCcontextMapping_encode2_no_mem_s17_LCS(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- int16_t *x,
- const int16_t nt,
- int16_t lastnz,
- const int16_t nbbits,
- const int16_t resQMaxBits,
- CONTEXT_HM_CONFIG *hm_cfg );
-
-int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
- Decoder_State *st, /* i/o: decoder state */
- int16_t *x, /* o : decoded spectrum */
- const int16_t nt, /* i : size of spectrum */
- const int16_t nbbits, /* i : bit budget */
- const int16_t resQMaxBits, /* i : residual coding maximum bits */
- CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
-);
-
-int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
- int16_t *x, /* Spectral coefficients */
- const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
- int16_t *lastnz_out,
- int16_t *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
- const int16_t target, /* Target bits */
- int16_t *stop,
- int16_t mode,
- CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
-);
-
-Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
- Word16 *x, /* Q0 */
- const Word16 nt, /* Q0 */
- const Word16 target, /* Q0 */
- HANDLE_RC_CONTEXT_MEM hContextMem );
-
-Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
- Word16 *x, /* Q0 */
- const Word16 start_line, /* Q0 */
- const Word16 end_line, /* Q0 */
- HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */
-);
-
-void tcx_get_windows_flt(
- TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */
- const int16_t left_mode, /* i : overlap mode of left window half */
- const int16_t right_mode, /* i : overlap mode of right window half */
- int16_t *left_overlap, /* o : left overlap length */
- const float **left_win, /* o : left overlap window */
- int16_t *right_overlap, /* o : right overlap length */
- const float **right_win, /* o : right overlap window */
- const int16_t fullband /* i : fullband flag */
-);
-
-void tcx_windowing_analysis_flt(
- const float *signal, /* i : signal vector */
- const int16_t L_frame, /* i : frame length */
- const int16_t left_overlap, /* i : left overlap length */
- const float *left_win, /* i : left overlap window */
- const int16_t right_overlap, /* i : right overlap length */
- const float *right_win, /* i : right overlap window */
- float *output /* o : windowed signal vector */
-);
-
-void tcx_windowing_synthesis_current_frame_flt(
- float *signal, /* i/o: signal vector */
- const float *window, /* i : TCX window vector */
- const float *window_half, /* i : TCX window vector for half-overlap window */
- const float *window_min, /* i : TCX minimum overlap window */
- const int16_t window_length, /* i : TCX window length */
- const int16_t window_half_length, /* i : TCX half window length */
- const int16_t window_min_length, /* i : TCX minimum overlap length */
- const int16_t left_rect, /* i : left part is rectangular */
- const int16_t left_mode, /* i : overlap mode of left window half */
- float *acelp_zir, /* i/o: acelp ZIR */
- const float *old_syn, /* i : old synthesis */
- const float *syn_overl, /* i : overlap synthesis */
- const float *A_zir,
- const float *window_trans, /* i : window for transition from ACELP */
- int16_t acelp_zir_len,
- const int16_t acelp_mem_len,
- const int16_t last_core_bfi, /* i : last mode */
- const int16_t last_is_cng,
- const int16_t fullbandScale );
-
-void tcx_windowing_synthesis_past_frame_flt(
- float *signal, /* i/o: signal vector */
- const float *window, /* i : TCX window vector */
- const float *window_half, /* i : TCX window vector for half-overlap window */
- const float *window_min, /* i : TCX minimum overlap window */
- const int16_t window_length, /* i : TCX window length */
- const int16_t window_half_length, /* i : TCX half window length */
- const int16_t window_min_length, /* i : TCX minimum overlap length */
- const int16_t right_mode /* i : overlap mode (left_mode of current frame) */
-);
-
-void ProcessIGF(
- Encoder_State *st, /* i : Encoder state */
- float *pMDCTSpectrum, /* i : MDCT spectrum */
- const float *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
- float *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
- const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
- const int16_t frameno, /* i : flag indicating index of current subframe */
- const int16_t sp_aud_decision0, /* i : first stage switching decision */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void ProcessStereoIGF(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
- Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
- int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
- float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
- float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
- float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
- const int16_t frameno, /* i : flag indicating index of current subframe*/
- const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
-);
-
-void AnalyzePowerSpectrum(
- Encoder_State *st, /* i/o: encoder states */
- const int16_t L_frame, /* i : frame length */
- const int16_t L_frameTCX, /* i : full band frame length */
- const int16_t left_overlap, /* i : left overlap length */
- const int16_t right_overlap, /* i : right overlap length */
- const float mdctSpectrum[], /* i : MDCT spectrum */
- const float signal[], /* i : windowed signal corresponding to mdctSpectrum */
- float powerSpec[] /* o : Power spectrum */
-);
-
-void lpc2mdct_flt(
- float *lpcCoeffs,
- const int16_t lpcOrder,
- float mdct_gains[],
- const int16_t length,
- const int16_t noInverse );
-
-void mdct_preShaping(
- float x[],
- const int16_t lg,
- const float gains[] );
-
-void mdct_noiseShaping_flt(
- float x[],
- const int16_t lg,
- const float gains[],
- const int16_t nBands );
-
-
-void PsychAdaptLowFreqDeemph_flt(
- float x[],
- const float lpcGains[],
- float lf_deemph_factors[] );
-
-void AdaptLowFreqDeemph_flt(
- float x[],
- int16_t tcx_lpc_shaped_ari,
- const float lpcGains[],
- const int16_t lg,
- float lf_deemph_factors[] );
-
-
-void tcx_noise_filling_flt(
- float *Q,
- const int16_t noiseFillSeed,
- const int16_t iFirstLine,
- const int16_t lowpassLine,
- const int16_t nTransWidth,
- const int16_t L_frame,
- const float tiltCompFactor,
- float fac_ns,
- Word16 *infoTCXNoise,
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-
-void tcx_decoder_memory_update_flt(
- Decoder_State *st, /* i/o: decoder memory state */
- const float *xn_buf, /* i : mdct output buffer */
- float *synth, /* i/o: synth */
- const float *A /* i : Quantized LPC coefficients */
-);
-
-
-/*! r: number of bits used (including "bits") */
-int16_t tcx_ari_res_invQ_spec_flt(
- float x_Q[], /* i/o: quantized spectrum */
- const int16_t L_frame, /* i : number of lines */
- const int16_t prm[], /* i : bitstream */
- int16_t target_bits, /* i : number of bits available */
- int16_t bits, /* i : number of bits used so far */
- const float deadzone, /* i : quantizer deadzone */
- const float x_fac[] /* i : spectrum post-quantization factors */
-);
-
-
-void ari_copy_states(
- Tastat *source,
- Tastat *dest );
-
-
-void ari_start_encoding_14bits(
- Tastat *s );
-
-
-void ari_start_decoding_14bits_ivas(
- Decoder_State *st,
- Tastat *s );
-
-int16_t ari_start_decoding_14bits_prm_ivas(
- const int16_t *ptr,
- int16_t bp,
- Tastat *s );
-
-void ari_decode_14bits_s17_ext_ivas(
- Decoder_State *st,
- uint16_t *res,
- Tastat *s,
- const uint16_t *cum_freq );
-
-void ari_decode_14bits_s27_ext_ivas(
- Decoder_State *st,
- uint16_t *res,
- Tastat *s,
- const uint16_t *cum_freq );
-
-void ari_decode_14bits_bit_ext_ivas(
- Decoder_State *st,
- uint16_t *res,
- Tastat *s );
-
-/*! r: Q15 */
-Word16 expfp_evs_fx(
- const Word16 x, /* i : mantissa Q15-e */
- const Word16 x_e /* i : exponent Q0 */
-);
-
-
-void tcx_arith_render_envelope_ivas_fx(
- const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/
- const Word16 L_frame, /* i : number of spectral lines Q0*/
- const Word16 L_spec, /* i : length of the coded spectrum Q0*/
- const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/
- const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/
- const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/
- Word32 env[] /* o : shaped signal envelope Q16*/
-);
-
-int16_t ari_encode_14bits_range(
- int16_t *ptr,
- int16_t bp,
- int32_t bits,
- Tastat *s,
- uint16_t cum_freq_low,
- uint16_t cum_freq_high );
-
-
-int16_t ari_done_cbr_encoding_14bits(
- int16_t *ptr,
- int16_t bp,
- int32_t bits,
- Tastat *s );
-
-
-void tcx_arith_encode_envelope(
- float spectrum[], /* i/o: MDCT coefficients */
- int16_t signs[], /* o : signs (spectrum[.]<0) */
- const int16_t L_frame, /* i : frame or MDCT length */
- const int16_t L_spec, /* i : length w/o BW limitation */
- Encoder_State *st, /* i/o: coder state */
- const Word16 A_ind[], /* i : quantised LPC coefficients */
- int16_t target_bits, /* i : number of available bits */
- int16_t prm[], /* o : bitstream parameters */
- const int16_t use_hm, /* i : use HM in current frame? */
- int16_t prm_hm[], /* o : HM parameter area */
- const int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
- int16_t *arith_bits, /* o : bits used for ari. coding */
- int16_t *signaling_bits, /* o : bits used for signaling */
- const int16_t low_complexity /* i : low-complexity flag */
-);
-
-void tcx_arith_decode_envelope(
- Decoder_State *st, /* i/o: coder state */
- float q_spectrum[], /* o : quantised MDCT coefficients */
- const int16_t L_frame, /* i : frame or MDCT length */
- int16_t L_spec, /* i : length w/o BW limitation */
- const Word16 A_ind[], /* i : quantised LPC coefficients */
- const int16_t target_bits, /* i : number of available bits */
- const int16_t prm[], /* i : bitstream parameters */
- const int16_t use_hm, /* i : use HM in current frame? */
- const int16_t prm_hm[], /* i : HM parameter area */
- int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
- int16_t *arith_bits, /* o : bits used for ari. coding */
- int16_t *signaling_bits, /* o : bits used for signaling */
- const int16_t low_complexity /* i : low-complexity flag */
-);
-
-void tcx_arith_decode_envelope_ivas_fx(
- Decoder_State *st, /* i/o: coder state */
- Word32 q_spectrum[], /* o : quantised MDCT coefficients */
- Word16 *q_spectrum_e, /* o : MDCT exponent */
- const Word16 L_frame, /* i : frame or MDCT length */
- Word16 L_spec, /* i : length w/o BW limitation */
- const Word16 A_ind[], /* i : quantised LPC coefficients */
- const Word16 target_bits, /* i : number of available bits */
- Word16 prm[], /* i : bitstream parameters */
- const Word16 use_hm, /* i : use HM in current frame? */
- const Word16 prm_hm[], /* i : HM parameter area */
- Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
- Word16 *arith_bits, /* o : bits used for ari. coding */
- Word16 *signaling_bits, /* o : bits used for signaling */
- const Word16 low_complexity /* i : low-complexity flag */
-);
-
-
-void UnmapIndex_fx(
- const Word16 PeriodicityIndex, /* Q0 */
- const Word16 Bandwidth, /* Q0 */
- const Word16 LtpPitchLag, /* Q0 */
- const Word8 SmallerLags, /* Q0 */
- Word16 *FractionalResolution, /* Q0 */
- Word32 *Lag /* Q0 */
-);
-
-/*! r: PeriodicityIndex */
-int16_t SearchPeriodicityIndex(
- const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */
- const float UnfilteredMdct[], /* i : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */
- const int16_t NumCoeffs, /* i : Number of coefficients */
- const int16_t shortTargetBits, /* i : Target bit budget (excl. Done flag) */
- const int16_t LtpPitchLag, /* i : TCX-LTP pitch */
- const float LtpGain, /* i : LTP gain */
- float *RelativeScore /* o : Energy concentration factor */
-);
-
-
-int16_t EncodeIndex(
- const int16_t Bandwidth, /* o : NB, 1: (S)WB */
- int16_t PeriodicityIndex,
- BSTR_ENC_HANDLE hBstr );
-
-
-Word16 CountIndexBits_fx(
- Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/
- Word16 PeriodicityIndex /* Q0 */
-);
-
-int16_t DecodeIndex(
- Decoder_State *st,
- const int16_t Bandwidth, /* o : NB, 1: (S)WB */
- int16_t *PeriodicityIndex );
-
-#define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution )
-#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
-
-
-Word32 tcx_hm_render_fx(
- const Word32 lag, /* i: pitch lag Q0 */
- const Word16 fract_res, /* i: fractional resolution of the lag Q0 */
- Word16 p[] /* o: harmonic model Q13 */
-);
-
-
-void tcx_hm_modify_envelope_fx(
- const Word16 gain, /* i: HM gain Q11 */
- const Word32 lag, /* i: pitch lag Q0 */
- const Word16 fract_res, /* i: fractional resolution of the lag Q0 */
- const Word16 p[], /* i: harmonic model Q13 */
- Word32 env[], /* i/o: envelope Q16 */
- const Word16 L_frame /* i: number of spectral lines Q0 */
-);
-
-void tcx_hm_analyse(
- const float abs_spectrum[], /* i : absolute spectrum */
- const int16_t L_frame, /* i : number of spectral lines */
- Word32 env[], /* i/o: envelope shape (Q16) */
- const int16_t targetBits, /* i : target bit budget */
- const int16_t coder_type, /* i : GC/VC coder type */
- int16_t prm_hm[], /* o : HM parameters */
- int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */
- const float LtpGain, /* i : LTP gain */
- int16_t *hm_bits /* o : bit consumption */
-);
-
-void tcx_hm_decode_ivas(
- const int16_t L_frame, /* i : number of spectral lines */
- Word32 env[], /* i/o: envelope shape (Q16) */
- const int16_t targetBits, /* i : target bit budget */
- const int16_t coder_type, /* i : GC/VC coder type */
- const int16_t prm_hm[], /* i : HM parameters */
- const int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */
- int16_t *hm_bits /* o : bit consumption */
-);
-
-void tcx_hm_decode(
- const Word16 L_frame, /* i : number of spectral lines */
- Word32 env[], /* i/o: envelope shape (Q16) */
- const Word16 targetBits, /* i : target bit budget */
- const Word16 coder_type, /* i : GC/VC coder type */
- const Word16 prm_hm[], /* i : HM parameters */
- const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */
- Word16 *hm_bits /* o : bit consumption */
-);
-
-void coder_tcx(
- Encoder_State *st, /* i/o: encoder state structure */
- TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- const float A[], /* i : quantized coefficients NxAz_q[M+1] */
- const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */
- float synth[], /* o : decoded synthesis */
- const int16_t L_frame_glob, /* i : frame length */
- const int16_t L_frameTCX_glob,
- const int16_t L_spec,
- int16_t nb_bits, /* i : bit budget */
- float spectrum[], /* i/o: MDCT spectrum */
- int16_t prm[], /* o : tcx parameters */
- CONTEXT_HM_CONFIG *hm_cfg,
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void coder_tcx_post(
- Encoder_State *st, /* i/o: encoder memory state */
- float *A, /* o : Quantized LPC coefficients */
- const float *Ai /* i : Unquantized (interpolated) LPC coefficients */
-);
-
-void decoder_tcx(
- Decoder_State *st, /* i/o: coder memory state */
- int16_t prm[], /* i : parameters */
- float A[], /* i : coefficients NxAz[M+1] */
- Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/
- float synth[], /* i/o: synth[-M..lg] */
- float synthFB[], /* i/o: encoder memory state */
- const int16_t bfi, /* i : Bad frame indicator */
- const int16_t frame_cnt, /* i : frame counter in the super_frame */
- const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-);
-
-void decoder_tcx_post(
- Decoder_State *st, /* i/o: decoder memory state */
- float *synth,
- float *synthFB,
- float *A, /* i : A(z) filter coefficients */
- const int16_t bfi,
- const int16_t isMCT );
-
-void coder_acelp(
- Encoder_State *st, /* i/o: coder memory state */
- const float A[], /* i : coefficients 4xAz[M+1] */
- const float Aq[], /* i : coefficients 4xAz_q[M+1] */
- const float speech[], /* i : speech[-M..lg] */
- LPD_state *LPDmem, /* i/o: ACELP memories */
- int16_t *prm, /* o : acelp parameters */
- const float stab_fac,
- const int16_t target_bits,
- float *gain_pitch_buf, /* o : gain pitch values */
- float *gain_code_buf, /* o : gain code values */
- float *pitch_buf, /* o : pitch values for each subfr.*/
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc /* o : excitation for SWB TBE */
-);
-
-void coder_acelp_rf(
- const int16_t target_bits, /* i : target bits */
- const float speech[], /* i : speech[-M..lg] */
- const int16_t coder_type, /* i : coding type */
- const int16_t rf_frame_type, /* i : rf_frame_type */
- const float A[], /* i : coefficients 4xAz[M+1] */
- const float Aq[], /* i : coefficients 4xAz_q[M+1] */
- const float voicing[], /* i : open-loop LTP gain */
- const int16_t T_op[], /* i : open-loop LTP lag */
- const float stab_fac, /* i : LP stability factor */
- Encoder_State *st, /* i/o: coder memory state */
- ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */
- float *exc_rf, /* i/o: pointer to RF excitation */
- float *syn_rf /* i/o: pointer to RF synthesis */
-);
-
-void decoder_acelp(
- Decoder_State *st, /* i/o: coder memory state */
- int16_t prm[], /* i : parameters */
- const float A[], /* i : coefficients NxAz[M+1] */
- ACELP_config acelp_cfg, /* i : ACELP config */
- float synth[], /* i/o: synthesis */
- int16_t *pT, /* o : pitch for all subframe */
- float *pgainT, /* o : pitch gain for all subfr */
- const float stab_fac, /* i : stability of isf */
- float *pitch_buffer, /* o : pitch values for each subfr.*/
- float *voice_factors, /* o : voicing factors */
- const int16_t LSF_Q_prediction, /* i : LSF prediction mode */
- float *bwe_exc /* o : excitation for SWB TBE */
-);
-
-void writeTCXMode_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
- Word16 *nbits_start /* o : nbits start Q0*/
-);
-
-void writeTCXWindowing_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 overlap_mode /* i : overlap mode Q0*/
-);
-
-void writeLPCparam(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const int16_t param_lpc[], /* i : LPC parameters to write */
- const int16_t bits_param_lpc[], /* i : bits per LPC parameter */
- const int16_t no_param_lpc, /* i : number of LPC parameters */
- int16_t *nbits_lpc /* o : LPC bits written */
-);
-
-void enc_prm(
- Encoder_State *st, /* i/o: encoder state structure */
- int16_t param[], /* i : parameters */
- int16_t param_lpc[], /* i : LPC parameters */
- CONTEXT_HM_CONFIG hm_cfg[],
- const int16_t bits_param_lpc[],
- const int16_t no_param_lpc );
-
-void writeTCXparam(
- Encoder_State *st, /* i/o: Encoder State handle */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
- int16_t param[], /* i : parameters */
- const int16_t nbits_header,
- const int16_t nbits_start,
- const int16_t nbits_lpc,
- const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */
- int16_t p_param[2], /* i/o: pointer to parameters from previous bs writing */
- const int16_t target_bitsTCX10[2],
- const int16_t pre_past_flag );
-
-void enc_prm_rf(
- Encoder_State *st, /* i/o: encoder memory state */
- const int16_t rf_frame_type,
- const int16_t fec_offset );
-
-void dec_prm_hm_ivas(
- Decoder_State *st, /* i/o: decoder memory state */
- int16_t *prm_hm,
- const int16_t hm_size );
-
-void dec_prm_ivas(
- Decoder_State *st, /* i/o: decoder memory state */
- int16_t param[], /* o : decoded parameters */
- int16_t param_lpc[], /* i : LPC parameters */
- int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
- int16_t *bitsRead );
-void gaus_L2_dec_flt(
- float *code, /* o : decoded gaussian codevector */
- float tilt_code,
- const float *A,
- float formant_enh_num,
- int16_t *seed_acelp /* i/o: random seed */
-);
-
-/*! r: interpolated value */
-float interpolation(
- const float *x, /* i : input vector */
- const float *win, /* i : interpolation window */
- const int16_t frac, /* i : fraction */
- const int16_t up_samp, /* i : upsampling factor */
- const int16_t nb_coef /* i : nb of filter coef */
-);
-
-void predict_signal_flt(
- const float excI[], /* i : input excitation buffer */
- float excO[], /* o : output excitation buffer */
- const int16_t T0, /* i : integer pitch lag */
- int16_t frac, /* i : fraction of lag */
- const int16_t frac_max, /* i : max fraction */
- const int16_t L_subfr /* i : subframe size */
-);
-
-void tcx_ltp_encode(
- Encoder_State *st,
- const int16_t tcxMode,
- const int16_t L_frame,
- const float *speech,
- float *speech_ltp,
- const float *wsp,
- const int16_t Top[],
- int16_t *ltp_param,
- int16_t *ltp_bits,
- float *A,
- const int16_t disable_ltp,
- const int16_t element_mode );
-
-void tcx_ltp_post_flt(
- Decoder_State *st,
- TCX_LTP_DEC_HANDLE hTcxLtpDec,
- const int16_t core,
- const int16_t output_frame,
- const int16_t L_frame,
- float sig[],
- const float tcx_buf[] );
-
-int16_t tcx_ltp_decode_params_flt(
- int16_t *ltp_param,
- int16_t *pitch_int,
- int16_t *pitch_fr,
- float *gain,
- const int16_t pitmin,
- const int16_t pitfr1,
- const int16_t pitfr2,
- const int16_t pitmax,
- const int16_t pitres );
-
-void create_IDCT_N_Matrix(
- float *inv_matrixFloatQ, /* i/o: RAM buffer */
- const int16_t N, /* i : DCT length, number of time samples */
- const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */
- const int16_t alloc_size /* i : RAM buffer size in elements */
-);
-
-void dctT2_N_apply_matrix(
- const float *input, /* i : input in fdcng or DCT(fdcng) domain */
- float *output, /* o : output in DCT(fdcng) or fdcng ordomain */
- const int16_t dct_dim, /* i : dct processing dim possibly truncated */
- const int16_t fdcngvq_dim, /* i : fdcng domain length */
- const float *matrix, /* i : IDCT matrix */
- const int16_t matrix_row_dim, /* i : */
- const DCTTYPE dcttype /* i : matrix operation type */
-);
-
-void extend_dctN_input(
- const float *input, /* i : input in fdcng domain */
- const float *dct_input, /* i : input in dctN(fdcng) domain */
- const int16_t in_dim, /* i : in_dim == N */
- float *ext_sig, /* o : extended output in fdcng domain */
- const int16_t out_dim, /* i : output total dim */
- float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */
- const int16_t n_cols, /* i : number of columns == DCT truncation length */
- const DCTTYPE dcttype /* i : matrix operation type */
-);
-
-
-void PulseResynchronization(
- const float *src_exc, /* i : Input excitation buffer */
- float *dst_exc, /* o : output excitation buffer */
- const int16_t nFrameLength, /* i : frame length */
- const int16_t nSubframes, /* i : Number of subframes */
- const float pitchStart, /* i : Pitch at the end of the last frame */
- const float pitchEnd /* i : Pitch at the end of the current frame */
-);
-
-void con_acelp(
- float A[], /* i : coefficients NxAz[M+1] */
- const int16_t coder_type, /* i : ACELP coder type */
- float synth[], /* i/o: synthesis */
- int16_t *pT, /* o : pitch for all subframe */
- float *pgainT, /* o : pitch gain for all subfr */
- float stab_fac, /* i : stability of isf */
- Decoder_State *st, /* i/o: coder memory state */
- float pitch_buffer[], /* i/o: floating pitch values for each subframe */
- float *voice_factors, /* o : voicing factors */
- float *bwe_exc /* o : excitation for SWB TBE */
-);
-
-void con_tcx(
- Decoder_State *st, /* i/o: coder memory state */
- float synth[], /* i/o: synth[] */
- const float coh, /* i : coherence of stereo signal */
- int16_t *noise_seed, /* i/o: noise seed for stereo */
- const int16_t only_left, /* i : TD-PLC only in left channel */
- const float A_cng[] /* i : CNG LP filter coefficients */
-);
-
-int16_t lsf_msvq_ma_decprm_ivas(
- Decoder_State *st,
- int16_t *param_lpc );
-
-int16_t dec_lsf_tcxlpc_ivas(
- Decoder_State *st, /* i : Decoder state */
- int16_t **indices, /* o : Ptr to VQ indices */
- const int16_t narrowband, /* i : narrowband flag */
- const int16_t cdk /* i : codebook selector */
-);
-
-int16_t D_lsf_tcxlpc_ivas(
- const int16_t indices[], /* i : VQ indices */
- float lsf_q[], /* o : quantized lsf */
- Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
- const int16_t narrowband, /* i : narrowband flag */
- const int16_t cdk, /* i : codebook selector */
- const float mem_MA[] /* i : MA memory */
-);
-
-int16_t Q_lsf_tcxlpc(
- /* const */ float lsf[], /* i : original lsf */
- float lsf_q[], /* o : quantized lsf */
- Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
- int16_t indices[], /* o : VQ indices */
- const int16_t narrowband, /* i : narrowband flag */
- const int16_t cdk, /* i : codebook selector */
- const float mem_MA[], /* i : MA memory */
- const int16_t coder_type, /* i : acelp extended mode */
- const float *Bin_Ener /* i : Spectrum energy */
-);
-
-void midlsf_enc(
- const float qlsf0[],
- const float qlsf1[],
- const float lsf[],
- int16_t *idx,
- const int16_t N,
- const float *Bin_Ener,
- const int16_t narrowBand,
- const int32_t sr_core,
- const int16_t coder_type );
-
-void lsf_end_enc(
- Encoder_State *st,
- const float *lsf,
- float *qlsf,
- const int16_t nBits,
- const int16_t coder_type_org,
- const int16_t force_sf,
- int16_t *lpc_param,
- int16_t *no_stages,
- int16_t *bits_param_lpc,
- const int16_t coder_type_raw,
- const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
-);
-
-void lsf_end_dec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t coder_type_org, /* i : coding type */
- const int16_t bwidth, /* i : input signal bandwidth */
- const int16_t nBits, /* i : number of bits used for ISF quantization*/
- float *qlsf, /* o : quantized LSFs in the cosine domain */
- int16_t *lpc_param, /* i : LPC parameters */
- int16_t *LSF_Q_prediction, /* o : LSF prediction mode */
- int16_t *nb_indices, /* o : number of indices */
- const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
-);
-
-void lpc_quantization(
- Encoder_State *st,
- const float lsp[],
- const float lspmid[],
- float lsp_q[],
- float lsf_q[],
- float lspmid_q[],
- const int16_t coder_type,
- const int16_t acelp_midLpc,
- int16_t param_lpc[],
- int16_t nbits_lpc[],
- int16_t *bits_param_lpc,
- int16_t *no_param_lpc );
-
-void lpc_unquantize(
- Decoder_State *st,
- float *lsf,
- float *lsp,
- int16_t *param_lpc,
- float *lspmid,
- float *lsfmid,
- const int16_t coder_type,
- int16_t *LSF_Q_prediction /* o : LSF prediction mode */
-);
-
-void dlpc_bfi_flt(
- const int16_t L_frame,
- float *lsf_q, /* o : quantized lsfs */
- const float *lsfold, /* i : past quantized lsf */
- const int16_t last_good, /* i : last good received frame */
- const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */
- float mem_MA[], /* i/o: quantizer memory for MA model */
- float mem_AR[], /* i/o: quantizer memory for MA model */
- float *stab_fac, /* i : lsf stability factor */
- float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */
- const int16_t numlpc, /* i : Number of division per superframe */
- float lsf_cng[],
- const int16_t plcBackgroundNoiseUpdated,
- float *lsf_q_cng, /* o : quantized lsfs of background noise */
- float *old_lsf_q_cng, /* o : old quantized lsfs for background noise */
- const float lsfBase[] /* i : base for differential lsf coding */
-);
-
-void Unified_weighting(
- const float Bin_Ener_128[], /* i : FFT Bin energy 128 bins in two sets */
- const float lsf[], /* i : LSF vector */
- float w[], /* o : LP weighting filter (numerator) */
- const int16_t narrowBand, /* i : flag for Narrowband */
- const int16_t unvoiced, /* i : flag for Unvoiced frame */
- const int32_t sr_core, /* i : sampling rate of core-coder */
- const int16_t order /* i : LP order */
-);
-
-int16_t vad_init(
- VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state */
-);
-
-int16_t vad_proc(
- float realValues[16][60], /* i : CLDFB real values */
- float imagValues[16][60], /* i : CLDFB imag values */
- float *sb_power, /* i/o: Energy of CLDFB data */
- const int16_t numBands, /* i : number of input bands */
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- int16_t *cldfb_addition,
- const int16_t vada_flag /* i : VAD flag */
-);
-
-
-int16_t update_decision(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const float snr, /* i : frequency domain SNR */
- const float tsnr, /* i : time domain SNR */
- const float frame_energy, /* i : current frame energy */
- const float high_eng, /* i : current frame high frequency energy */
- const int16_t vad_flag, /* i : VAD flag */
- const int16_t music_backgound_f /* i : background music flag */
-);
-
-void frame_spec_dif_cor_rate(
- float spec_amp[], /* i : spectral amplitude */
- float pre_spec_low_dif[], /* i/o: low spectrum different */
- float f_tonality_rate[] /* o : tonality rate */
-);
-
-
-void SNR_calc(
- const float frame_sb_energy[], /* i : energy of sub-band divided non-uniformly*/
- const float sb_bg_energy[], /* i : sub-band background energy */
- const float t_bg_energy, /* i : time background energy of several frames*/
- float *snr, /* o : frequency domain SNR */
- float *tsnr, /* o : time domain SNR */
- const float frame_energy, /* i : current frame energy */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-void background_update(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- float frame_energy, /* i : current frame energy 2 */
- const int16_t update_flag, /* i : current frame update flag */
- const int16_t music_backgound_f, /* i : background music flag */
- const float snr );
-
-void bg_music_decision(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- int16_t *music_backgound_f, /* i : background music flag */
- const float frame_energy /* i : current frame energy 1 */
-);
-
-void est_energy(
- float sb_power[], /* o : energy of sub-band divided uniformly */
- float frame_sb_energy[], /* o : energy of sub-band divided non-uniformly*/
- float *p_frame_energy, /* o : frame energy 1 */
- float *p_frame_energy2, /* o : frame energy 2 */
- float *p_high_energy, /* o : high frequency energy */
- const int16_t bw /* i : bandwidth */
-);
-
-
-int16_t comvad_decision(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const float snr, /* i : frequency domain SNR */
- const float tsnr, /* i : time domain SNR */
- const float snr_flux, /* i : average tsnr of several frames */
- const float lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/
- const float lt_snr_org, /* i : original long time SNR */
- const float lf_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
- const float frame_energy, /* i : current frame energy */
- const int16_t music_backgound_f, /* i : background music flag */
- int16_t *cldfb_addition,
- const int16_t vada_flag /* i : VAD flag */
-);
-
-void calc_snr_flux(
- float tsnr, /* i : time-domain SNR */
- float pre_snr[], /* i/o: time-domain SNR storage */
- float *snr_flux /* o : average tsnr */
-);
-
-void calc_lt_snr(
- float *lt_snr_org, /* o : original long time SNR */
- float *lt_snr, /* o : long time SNR calculated by fg_energy and bg_energy*/
- const float fg_energy, /* i : foreground energy sum */
- const int16_t fg_energy_count, /* i : number of the foreground energy frame */
- const float bg_energy, /* i : background energy sum */
- const int16_t bg_energy_count, /* i : number of the background energy frame */
- const int16_t bw_index, /* i : band width index */
- const float lt_noise_sp_center0 /* i : long time noise spectral center by 0 */
-);
-
-void calc_lf_snr(
- float *lf_snr_smooth, /* o : smoothed lf_snr */
- float *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
- const float l_speech_snr, /* i : sum of active frames snr */
- const int16_t l_speech_snr_count, /* i : number of the active frame */
- const float l_silence_snr, /* i : sum of the nonactive frames snr */
- const int16_t l_silence_snr_count, /* i : number of the nonactive frame */
- const int16_t fg_energy_count, /* i : number of the foreground energy frame */
- const int16_t bg_energy_count, /* i : number of the background energy frame */
- const int16_t bw_index /* i : band width index */
-);
-
-float construct_snr_thresh(
- const float sp_center[], /* i : spectral center */
- const float snr_flux, /* i : snr flux */
- const float lt_snr, /* i : long time time domain snr */
- const float lf_snr, /* i : long time frequency domain snr */
- const int16_t continuous_speech_num, /* i : continuous speech number */
- const int16_t continuous_noise_num, /* i : continuous noise number */
- const int16_t fg_energy_est_start, /* i : whether if estimated energy */
- const int16_t bw_index /* i : band width index */
-);
-
-void minimum_statistics_flt(
- const int16_t len, /* i : Vector length */
- const int16_t lenFFT, /* i : Length of the FFT part of the vectors */
- float *psize_flt,
- float *msPeriodog, /* i : Periodograms */
- float *msNoiseFloor,
- float *msNoiseEst, /* o : Noise estimates */
- float *msAlpha,
- float *msPsd,
- float *msPsdFirstMoment,
- float *msPsdSecondMoment,
- float *msMinBuf,
- float *msBminWin,
- float *msBminSubWin,
- float *msCurrentMin,
- float *msCurrentMinOut,
- float *msCurrentMinSubWindow,
- int16_t *msLocalMinFlag,
- int16_t *msNewMinFlag,
- float *msPeriodogBuf,
- int16_t *msPeriodogBufPtr,
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const int16_t enc_dec, /* i : encoder/decoder indicator */
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-void generate_comfort_noise_enc(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void generate_comfort_noise_dec(
- float **bufferReal, /* o : Real part of input bands */
- float **bufferImag, /* o : Imaginary part of input bands */
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-void generate_comfort_noise_dec_hf(
- float **bufferReal, /* o : Real part of input bands */
- float **bufferImag, /* o : Imaginary part of input bands */
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const int16_t cng_flag /* i : CNG Flag */
-);
-
-void generate_masking_noise(
- float *timeDomainBuffer, /* i/o: time-domain signal */
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const int16_t length, /* i : frame size */
- const int16_t core, /* i : core */
- const int16_t return_noise, /* i : noise is returned instead of added */
- const int16_t secondary, /* i : indicator for secondary channel */
- const int16_t element_mode, /* i : element mode */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-void generate_masking_noise_update_seed(
- HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
-);
-
-void generate_masking_noise_mdct(
- float *mdctBuffer, /* i/o: time-domain signal */
- HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
-);
-
-void SynthesisSTFT_dirac_flt(
- float *fftBuffer, /* i : FFT bins */
- float *timeDomainOutput,
- float *olapBuffer,
- const float *olapWin,
- const int16_t samples_out,
- HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
-);
-
-void generate_masking_noise_dirac(
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
- float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */
- float *Cldfb_RealBuffer, /* o : CLDFD real buffer */
- float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */
- const int16_t slot_index, /* i : CLDFB slot index */
- const int16_t cna_flag, /* i : CNA flag for LB and HB */
- const int16_t fd_cng_flag /* i : FD-CNG flag for HB */
-);
-
-void generate_stereo_masking_noise(
- float *syn, /* i/o: time-domain signal */
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t fadeOut, /* i : only fade out of previous state */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-void apply_scale_flt(
- float *scale, /* i : scale factor */
- const int16_t bwidth, /* i : audio bandwidth */
- const int32_t brate, /* i : Bit rate */
- const SCALE_SETUP *scaleTable, /* i : Scale table */
- const int16_t scaleTableSize /* i : Size of scale table */
-);
-
-void compress_range_flt(
- float *in,
- float *out,
- const int16_t len );
-
-void expand_range_flt(
- float *in,
- float *out,
- const int16_t len );
-
-void bandcombinepow_flt(
- const float *bandpow, /* i : Power for each band */
- const int16_t nband, /* i : Number of bands */
- int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */
- const int16_t npart, /* i : Number of partitions */
- const float *psize_inv_flt, /* i : Inverse partition sizes */
- float *partpow /* o : Power for each partition */
-);
-
-void scalebands_flt(
- const float *partpow, /* i : Power for each partition */
- int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */
- const int16_t npart, /* i : Number of partitions */
- int16_t *midband, /* i : Central band of each partition */
- const int16_t nFFTpart, /* i : Number of FFT partitions */
- const int16_t nband, /* i : Number of bands */
- float *bandpow, /* o : Power for each band */
- const int16_t flag_fft_en );
-
-void AnalysisSTFT_flt(
- const float *timeDomainInput,
- float *fftBuffer, /* o : FFT bins */
- HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
-);
-
-void SynthesisSTFT_flt(
- float *fftBuffer,
- float *timeDomainOutput,
- float *olapBuffer,
- const float *olapWin,
- const int16_t tcx_transition,
- HANDLE_FD_CNG_COM hFdCngCom,
- const int16_t element_mode, /* i : element mode */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-void lpc_from_spectrum_flt(
- HANDLE_FD_CNG_COM hFdCngCom,
- const int16_t start,
- const int16_t stop,
- const float preemph_fac );
-
-ivas_error createFdCngDec(
- HANDLE_FD_CNG_DEC *hFdCngDec );
-
-void deleteFdCngDec(
- HANDLE_FD_CNG_DEC *hFdCngDec );
-
-void initFdCngDec(
- DEC_CORE_HANDLE st /* i/o: decoder state structure */
-);
-
-void configureFdCngDec(
- HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
- const int16_t bwidth,
- const int32_t total_brate,
- const int16_t L_frame,
- const int16_t last_L_frame,
- const int16_t element_mode );
-
-void ApplyFdCng(
- float *timeDomainInput,
- float *powerSpectrum,
- float **realBuffer, /* i/o: Real part of the buffer */
- float **imagBuffer, /* i/o: Imaginary part of the buffer */
- Decoder_State *st,
- const int16_t concealWholeFrame, /* i : binary flag indicating frame loss */
- const int16_t is_music );
-
-void generate_comfort_noise_dec(
- float **bufferReal, /* o : Real part of input bands */
- float **bufferImag, /* o : Imaginary part of input bands */
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t nchan_out /* i : number of output channels */
-);
-
-/*! r: CNG energy */
-float cng_energy(
- const int16_t element_mode, /* i : element mode */
- const int16_t bwidth, /* i : audio bandwidh */
- const int16_t CNG_mode, /* i : mode for DTX configuration */
- const float CNG_att, /* i : attenuation factor for CNG */
- const float *inputBuffer, /* i : input signal */
- const int16_t len /* i : vector length */
-);
-
-void FdCng_decodeSID(
- Decoder_State *st /* i/o: decoder state structure */
-);
-
-void FdCng_exc_flt(
- HANDLE_FD_CNG_COM hFdCngCom,
- int16_t *CNG_mode,
- const int16_t L_frame,
- const float *lsp_old,
- const int16_t first_CNG,
- float *lsp_CNG,
- float *Aq, /* o : LPC coeffs */
- float *lsp_new, /* o : lsp */
- float *lsf_new, /* o : lsf */
- float *exc, /* o : LP excitation */
- float *exc2, /* o : LP excitation */
- float *bwe_exc /* o : LP excitation for BWE */
-);
-
-void noisy_speech_detection(
- HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */
- const int16_t vad, /* i : VAD flag */
- const float syn[] /* i : input time-domain frame */
-);
-
-void deleteFdCngEnc(
- HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */
-);
-
-
-void resetFdCngEnc(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void perform_noise_estimation_enc(
- float *band_energies, /* i : energy in critical bands without minimum noise floor E_MIN */
- float *enerBuffer, /* i : energy buffer */
- HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
- const int32_t input_Fs, /* i : input sampling rate */
- CPE_ENC_HANDLE hCPE );
-
-void AdjustFirstSID(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void FdCng_encodeSID(
- Encoder_State *st /* i/o: encoder state structure */
-);
-
-void GetParameters(
- ParamsBitMap const *paramsBitMap,
- const int16_t nParams,
- void const *pParameter,
- int16_t **pStream,
- int16_t *pnSize,
- int16_t *pnBits );
-
-void SetParameters(
- ParamsBitMap const *paramsBitMap,
- const int16_t nParams,
- void *pParameter,
- const int16_t **pStream,
- int16_t *pnSize );
-
-void WriteToBitstream(
- ParamsBitMap const *paramsBitMap,
- const int16_t nParams,
- const int16_t **pStream,
- int16_t *pnSize,
- BSTR_ENC_HANDLE hBstr,
- int16_t *pnBits );
-
-void ReadFromBitstream(
- ParamsBitMap const *paramsBitMap,
- const int16_t nArrayLength,
- Decoder_State *st,
- int16_t **pStream,
- int16_t *pnSize );
-
-void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
-void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
-void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue );
-void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value );
-
-int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-
-int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-
-int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-
-int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index );
-
-int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index );
-int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-
-void ResetTnsData_flt(
- STnsData *pTnsData );
-
-void ClearTnsFilterCoefficients_flt(
- STnsFilter *pTnsFilter );
-
-
-int16_t DetectTnsFilt(
- const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
- const float pSpectrum[], /* i : MDCT spectrum */
- TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */
- const int16_t isTCX10, /* i : TCX10 or TCX20? */
- const float ltp_gain, /* i : LTP gain */
- STnsData *pTnsData, /* o : TNS data struct */
- float *predictionGain /* o : TNS prediction gain */
-);
-
-void EncodeTnsData(
- STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
- STnsData const *pTnsData, /* i : TNS data struct (quantized param) */
- int16_t *stream, /* o : internal data stream */
- int16_t *pnSize, /* o : number of written parameters */
- int16_t *pnBits /* o : number of written bits */
-);
-
-int16_t DecodeTnsData_ivas(
- STnsConfig const *pTnsConfig,
- const int16_t *stream,
- int16_t *pnSize,
- STnsData *pTnsData );
-
-void WriteTnsData(
- const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
- const int16_t *stream, /* i : internal data stream */
- int16_t *pnSize, /* o : number of written parameters */
- BSTR_ENC_HANDLE hBstr, /* o : bitstream */
- int16_t *pnBits /* o : number of written bits */
-);
-
-void ReadTnsData_ivas(
- STnsConfig const *pTnsConfig,
- Decoder_State *st,
- int16_t *pnBits,
- int16_t *stream,
- int16_t *pnSize );
-
-void cldfbAnalysis_ivas(
- const float *timeIn, /* i : time buffer */
- float **realBuffer, /* o : real value buffer */
- float **imagBuffer, /* o : imag value buffer */
- const int16_t samplesToProcess, /* i : number of input samples */
- HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
-);
-
-void cldfbAnalysis_ts_ivas(
- const float *timeIn, /* i : time buffer */
- float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */
- float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */
- const int16_t samplesToProcess, /* i : samples to process */
- HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
-);
-
-void cldfbSynthesis_ivas(
- float **realBuffer, /* i : real values */
- float **imagBuffer, /* i : imag values */
- float *timeOut, /* o : synthesized output */
- const int16_t samplesToProcess, /* i : number of samples */
- HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */
-);
-
-void configureCldfb_ivas(
- HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
- const int32_t sampling_rate /* i : sampling rate */
-);
-
-
-void analysisCldfbEncoder_ivas(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *timeIn,
- const int16_t samplesToProcess,
- float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
- float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
- float *ppBuf_Ener );
-
-void analysisCldfbEncoder_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- Word32 *timeIn, /*q11*/
- Word16 timeInq, /*q0*/
- Word16 samplesToProcess, /*q0*/
- Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
- Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
- Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
- Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
- Word32 *ppBuf_Ener,
- Word16 *enerBuffSum_exp,
- CLDFB_SCALE_FACTOR *scale );
-
-ivas_error openCldfb_ivas(
- HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
- CLDFB_TYPE type, /* i : analysis or synthesis */
- const int32_t sampling_rate, /* i : sampling rate */
- CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
-);
-
-ivas_error openCldfb_ivas_enc(
- HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
- CLDFB_TYPE type, /* i : analysis or synthesis */
- const Word32 sampling_rate, /* i : sampling rate */
- CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
-);
-
-void resampleCldfb_ivas(
- HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
- const int32_t newSamplerate /* i : new samplerate to operate */
-);
-
-ivas_error cldfb_save_memory_ivas(
- HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
-);
-
-void cldfb_restore_memory_ivas(
- HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
-);
-
-void cldfb_reset_memory_ivas(
- HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
-);
-
-void deleteCldfb_ivas(
- HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */
-);
-
-void fft_cldfb(
- float *data, /* i/o: input/output vector */
- const int16_t size /* i : size of fft operation */
-);
-
-void BITS_ALLOC_init_config_acelp_IVAS(
- const int32_t bit_rate,
- const int16_t narrowBand,
- const int16_t nb_subfr,
- ACELP_config *acelp_cfg /* o : configuration structure of ACELP */
-);
-
-int16_t BITS_ALLOC_config_acelp_IVAS(
- const int16_t bits_frame, /* i : remaining bit budget for the frame */
- const int16_t coder_type, /* i : acelp coder type */
- ACELP_config *acelp_cfg, /* i/o: configuration structure of ACELP */
- const int16_t narrowband, /* i : narrowband flag */
- const int16_t nb_subfr /* i : number of subframes */
-);
-
-
-void FEC_clas_estim(
- const float *syn,
- const float *pitch, /* i : pitch values for each subframe */
- const int16_t L_frame, /* i : length of the frame */
- const int16_t coder_type, /* i : coder type */
- const int16_t codec_mode, /* i : codec mode */
- float *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */
- int16_t *clas, /* i/o: frame classification */
- float *lp_speech, /* i/o: long term active speech energy average */
- const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- int16_t *decision_hyst, /* i/o: hysteresis of the music/speech decision */
- int16_t *locattack, /* i/o: detection of attack (mainly to localized speech burst) */
- int16_t *UV_cnt, /* i/o: number of consecutives frames classified as UV */
- float *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV */
- float *Last_ener, /* i/o: last_energy frame */
- int16_t *amr_io_class, /* i/o: classification for AMR-WB IO mode */
- float *lt_diff_etot, /* i/o: long-term total energy variation */
- float *class_para, /* o : classification para. fmerit1 */
- const float LTP_Gain, /* i : */
- const int16_t narrowBand, /* i : */
- const SIGNAL_CLASSIFIER_MODE mode, /* i : */
- const int16_t bfi, /* i : */
- const float preemph_fac, /* i : */
- const int16_t tcxonly, /* i : */
- const int32_t last_core_brate, /* i : last core bitrate */
- const int16_t FEC_mode /* i : ACELP FEC mode */
-);
-
-
-void SetTCXModeInfo(
- Encoder_State *st, /* i/o: encoder state structure */
- TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */
- int16_t *tcxModeOverlap /* o : window overlap of current frame */
-);
-
-void TCX_MDCT_flt(
- const float *x,
- float *y,
- const int16_t l,
- const int16_t m,
- const int16_t r,
- const int16_t element_mode );
-
-void TCX_MDST_flt(
- const float *x,
- float *y,
- const int16_t l,
- const int16_t m,
- const int16_t r,
- const int16_t element_mode );
-
-void TCX_MDCT_Inverse_flt(
- const float *x,
- float *y,
- const int16_t l,
- const int16_t m,
- const int16_t r,
- const int16_t element_mode );
-
-void TCX_MDST_Inverse_flt(
- const float *x,
- float *y,
- const int16_t l,
- const int16_t m,
- const int16_t r,
- const int16_t element_mode );
-
-void TCX_MDXT_Inverse_flt(
- const float *x,
- float *y,
- const int16_t l,
- const int16_t m,
- const int16_t r,
- const uint16_t kernel_type );
-
-void post_decoder_flt(
- Decoder_State *st,
- float synth_buf[],
- const float pit_gain[],
- const int16_t pitch[],
- float signal_out[],
- float bpf_noise_buf[] );
-void cldfb_synth_set_bandsToZero_flt(
- Decoder_State *st, /* i/o: decoder state structure */
- float **rAnalysis,
- float **iAnalysis,
- const int16_t nTimeSlots );
-
-void longadd(
- uint16_t a[], /* i/o: vector of the length lena */
- const uint16_t b[], /* i/o: vector of the length lenb */
- const int16_t lena, /* i/o: length of vector a[] */
- const int16_t lenb /* i/o: length of vector b[] */
-);
-
-void longshiftright(
- uint16_t a[], /* i : vector of the length lena */
- const int16_t b, /* i : number of bit positions to shift right */
- uint16_t d[], /* o : vector of the length lend */
- int16_t lena, /* i : length of vector a[] */
- const int16_t lend /* i : length of vector d[] */
-);
-
-void longshiftleft(
- const uint16_t a[], /* i : vector of the length len */
- const int16_t b, /* i : number of bit positions to shift left */
- uint16_t d[], /* o : vector of the length len */
- const int16_t len /* i : length of vector a[] and d[] */
-);
-
-void open_decoder_LPD(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t total_brate, /* i : total bitrate */
- const int32_t last_total_brate, /* i : last total bitrate */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int16_t last_element_mode, /* i : last element mode */
- const int16_t is_init /* i : indicate call during initialization */
-);
-
-void acelp_plc_mdct_transition(
- Decoder_State *st /* i/o: Decoder state */
-);
-
-void tcxltp_dec_init(
- TCX_LTP_DEC_HANDLE hTcxLtpDec,
- const int16_t ini_frame,
- const int16_t last_codec_mode,
- const int16_t element_mode,
- const int16_t pit_max,
- const int32_t sr_core );
-
-void reset_tcx_overl_buf(
- TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */
-);
-
-void update_decoder_LPD_cng_flt(
- Decoder_State *st, /* i/o: decoder state structure */
- float *timeDomainBuffer,
- float *A,
- float *bpf_noise_buf );
-
-void reconfig_decoder_LPD_ivas(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t bits_frame, /* i : bit budget */
- const int16_t bwidth, /* i : audio bandwidth */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t L_frame_old /* i : frame length */
-);
-
-void mode_switch_decoder_LPD(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t bwidth, /* i : audio bandwidth */
- const int32_t total_brate, /* i : total bitrate */
- const int32_t last_total_brate, /* i : last frame total bitrate */
- const int16_t frame_size_index, /* i : index determining the frame size */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
- const int16_t last_element_mode /* i : last element mode */
-);
-
-void dec_acelp_tcx_frame(
- Decoder_State *st, /* i/o: decoder state structure */
- int16_t *concealWholeFrame, /* i/o: concealment flag */
- float *output, /* o : synthesis */
- float *bpf_noise_buf, /* i/o: BPF noise buffer */
- float *pcmbufFB, /* o : synthesis @output_FS */
- float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- float *voice_factors, /* o : voicing factors */
- float pitch_buf[], /* o : floating pitch for each subframe */
- STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */
-);
-
-void decoder_LPD(
- Decoder_State *st, /* i/o: decoder memory state pointer */
- float signal_out[], /* o : signal with LPD delay (7 subfrs) */
- float signal_outFB[], /* o : synthesis @output_FS */
- int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
- float *bpf_noise_buf, /* i/o: BPF noise buffer */
- int16_t bfi, /* i : BFI flag */
- int16_t *bitsRead, /* o : number of read bits */
- int16_t param[], /* o : buffer of parameters */
- float *pitch_buf, /* i/o: floating pitch values for each subfr*/
- float *voice_factors, /* o : voicing factors */
- float *ptr_bwe_exc /* o : excitation for SWB TBE */
-);
-
-int16_t tcxGetNoiseFillingTilt_flt(
- const float A[],
- const int16_t L_frame,
- const int16_t mode,
- float *noiseTiltFactor );
-
-void tcxFormantEnhancement_flt(
- float xn_buf[],
- const float *gainlpc,
- float spectrum[],
- const int16_t L_frame );
-
-void tcxInvertWindowGrouping_flt(
- TCX_CONFIG_HANDLE hTcxCfg,
- float xn_buf[],
- float spectrum[],
- const int16_t L_frame,
- const int8_t fUseTns,
- const int16_t last_core,
- const int16_t index,
- const int16_t frame_cnt,
- const int16_t bfi );
-
-void tcx5SpectrumInterleaving(
- const int16_t tcx5Size,
- float *spectrum );
-
-void tcx5SpectrumDeinterleaving(
- const int16_t tcx5Size,
- float *spectrum );
-
-void tcx5TnsGrouping(
- const int16_t L_frame,
- const int16_t L_spec,
- float *spectrum );
-
-void tcx5TnsUngrouping(
- const int16_t L_frame,
- const int16_t L_spec,
- float *spectrum,
- const int16_t enc_dec );
-
-void lerp_flt(
- const float *f,
- float *f_out,
- const int16_t bufferNewSize,
- const int16_t bufferOldSize );
-
-void encoderSideLossSimulation(
- Encoder_State *st,
- PLC_ENC_EVS_HANDLE hPlc_Ext,
- float *isf_q,
- const float stab_fac,
- const int16_t calcOnlyISF,
- const int16_t L_frame );
-
-void enc_prm_side_Info(
- PLC_ENC_EVS_HANDLE hPlc_Ext,
- Encoder_State *st );
-
-void GplcTcxEncSetup(
- const int16_t tcxltp_pitch_int,
- PLC_ENC_EVS_HANDLE hPlc_Ext );
-
-int16_t encSideSpecPowDiffuseDetector(
- float *isf_ref,
- float *isf_con,
- const int32_t sr_core,
- float *prev_isf4_mean,
- const int16_t sw,
- const int16_t coder_type );
-
-void updateSpecPowDiffuseIdx(
- const float gain_pitch_buf[], /* i : gain pitch values */
- const float gain_code_buf[], /* i : gain pitch values */
- int16_t glr_idx[2], /* o : */
- float mean_gc[2] /* o : */
-);
-
-void getLookAheadResSig_flt(
- float *speechLookAhead,
- const float *A,
- float *res,
- const int16_t L_frame,
- const int16_t L_subfr,
- const int16_t m,
- const int16_t numSubFrame );
-
-void updatelsfForConcealment_flt(
- PLC_ENC_EVS_HANDLE decState,
- float *lsf );
-
-void getConcealedLP_flt(
- PLC_ENC_EVS_HANDLE memDecState,
- float *AqCon,
- const float xsfBase[],
- const int32_t sr_core,
- const int16_t last_good,
- const int16_t L_frame );
-
-void RecLpcSpecPowDiffuseLc_flt(
- float *ispq,
- float *isp_old,
- float *isfq,
- Decoder_State *st,
- const int16_t reset_q );
-
-void modify_lsf_flt(
- float *lsf,
- const int16_t n,
- const int32_t sr_core,
- const int16_t reset_q );
-
-void init_PLC_enc(
- PLC_ENC_EVS_HANDLE hPlcExt,
- const int32_t sr_core );
-
-void gPLC_encInfo(
- PLC_ENC_EVS_HANDLE hPlcExt,
- const int32_t total_brate,
- const int16_t bwidth,
- const int16_t last_clas,
- const int16_t coder_type );
-
-void resetTecDec(
- TEC_DEC_HANDLE hTecDec );
-
-void calcGainTemp_TBE(
- float **pCldfbRealSrc,
- float **pCldfbImagSrc,
- float *loBuffer,
- const int16_t startPos, /*!< Start position of the current envelope. */
- const int16_t stopPos, /*!< Stop position of the current envelope. */
- const int16_t lowSubband, /* lowSubband */
- float *pGainTemp,
- const int16_t code );
-
-void procTecTfa_TBE(
- float *hb_synth,
- float *gain,
- const int16_t flat_flag,
- const int16_t last_core,
- const int16_t L_subfr,
- const int16_t code );
-
-void resetTecEnc(
- TEC_ENC_HANDLE hTecEnc,
- const int16_t flag );
-
-void calcHiEnvLoBuff(
- const int16_t noCols,
- const int16_t *pFreqBandTable, /* i : freqbandTable */
- const int16_t nSfb, /* i : Number of scalefactors */
- float **pYBuf,
- float *loBuf,
- float *hiTempEnv );
-
-void calcLoEnvCheckCorrHiLo(
- const int16_t noCols,
- const int16_t *pFreqBandTable, /* i : freqbandTable */
- float *loBuf,
- float *loTempEnv,
- float *loTempEnv_ns,
- float *hiTempEnv,
- int16_t *corr_flag /* o : 0 for original, 1 for TEC */
-);
-
-
-void tecEnc_TBE(
- int16_t *corrFlag,
- const float *voicing,
- const int16_t coder_type );
-
-void set_TEC_TFA_code(
- const int16_t corrFlag,
- int16_t *tec_flag,
- int16_t *tfa_flag );
-
-float Damping_fact_flt(
- const int16_t coder_type, /* i : ACELP core coder type */
- const int16_t nbLostCmpt, /* i : compt for number of consecutive lost frame */
- int16_t last_good, /* i : class of last good received frame */
- float stab_fac, /* i : LSF stability factor */
- float *lp_gainp, /* i/o: low passed pitch gain used for concealment */
- const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */
-);
-
-float getLevelSynDeemph(
- const float h1Init[], /* i : input value or vector to be processed */
- const float A[], /* i : LPC coefficients */
- const int16_t lenLpcExc, /* i : length of the LPC excitation buffer */
- const float preemph_fac, /* i : preemphasis factor */
- const int16_t numLoops /* i : number of loops */
-);
-
-void genPlcFiltBWAdap(
- const int32_t sr_core, /* i : core sampling rate */
- float *lpFiltAdapt, /* o : filter coefficients for filtering codebooks in case of flc */
- const int16_t type, /* i : type of filter, either 0 : lowpass or 1 : highpass */
- const float alpha /* i : fade out factor [0 1) used decrease filter tilt */
-);
-
-void highPassFiltering(
- const int16_t last_good, /* i : last classification type */
- const int16_t L_buffer, /* i : buffer length */
- float exc2[], /* i/o: unvoiced excitation before the high pass filtering */
- const float hp_filt[], /* i : high pass filter coefficients */
- const int16_t l_fir_fer /* i : high pass filter length */
-);
-
-int16_t GetPLCModeDecision(
- Decoder_State *st /* i/o: decoder memory state pointer */
-);
-
-void addBassPostFilter(
- const float *harm_timeIn,
- const int16_t samplesToProcess,
- float **rAnalysis,
- float **iAnalysis,
- HANDLE_CLDFB_FILTER_BANK cldfb );
-
-ivas_error TonalMDCTConceal_Init_ivas(
- TonalMDCTConcealPtr hTonalMDCTConc,
- const uint16_t samplesPerBlock,
- const uint16_t nSamplesCore,
- const uint16_t nScaleFactors,
- TCX_CONFIG_HANDLE hTcxCfg );
-
-void TonalMDCTConceal_SaveFreqSignal_ivas(
- TonalMDCTConcealPtr hTonalMDCTConc,
- const float *mdctSpectrum,
- const uint16_t numSamples,
- const uint16_t nNewSamplesCore,
- const float *scaleFactors,
- const int16_t infoIGFStartLine );
-
-void TonalMDCTConceal_UpdateState_ivas(
- TonalMDCTConcealPtr hTonalMDCTConc,
- const int16_t numSamples,
- const float pitchLag,
- const int16_t badBlock,
- const int16_t tonalConcealmentActive );
-
-void TonalMDCTConceal_SaveTimeSignal_ivas(
- TonalMDCTConcealPtr hTonalMDCTConc,
- float *timeSignal,
- const int16_t numSamples );
-
-void TonalMDCTConceal_Detect_ivas(
- const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
- const float pitchLag, /*IN */
- int16_t *umIndices, /*OUT*/
- const PsychoacousticParameters *psychParamsCurrent /*IN*/
-);
-
-void TonalMDCTConceal_Apply_ivas(
- TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
- float *mdctSpectrum, /*OUT*/
- const PsychoacousticParameters *psychParamsCurrent /*IN*/
-);
-
-void TonalMDCTConceal_InsertNoise_ivas(
- const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
- float *mdctSpectrum, /*OUT*/
- const int16_t tonalConcealmentActive,
- int16_t *pSeed, /*IN/OUT*/
- const float tiltCompFactor,
- const float crossfadeGain,
- const float concealment_noise[L_FRAME48k],
- const float cngLevelBackgroundTrace_bfi,
- const int16_t crossOverFreq );
-
-void DetectTonalComponents_flt(
- uint16_t indexOfTonalPeak[],
- uint16_t lowerIndex[],
- uint16_t upperIndex[],
- uint16_t *pNumIndexes,
- const float lastPitchLag,
- const float currentPitchLag,
- const float lastMDCTSpectrum[],
- const float scaleFactors[],
- const float secondLastPowerSpectrum[],
- const uint16_t nSamples,
- const uint16_t nSamplesCore,
- float floorPowerSpectrum,
- const PsychoacousticParameters *psychParamsCurrent );
-
-void RefineTonalComponents_flt(
- uint16_t indexOfTonalPeak[],
- uint16_t lowerIndex[],
- uint16_t upperIndex[],
- float phaseDiff[],
- float phases[],
- uint16_t *pNumIndexes,
- const float lastPitchLag,
- const float currentPitchLag,
- const float lastMDCTSpectrum[],
- const float scaleFactors[],
- const float secondLastPowerSpectrum[],
- const uint16_t nSamples,
- const uint16_t nSamplesCore,
- float floorPowerSpectrum,
- const PsychoacousticParameters *psychParamsCurrent );
-
-ivas_error PsychoacousticParameters_Init(
- const int32_t sr_core, /* i : sampling rate of core-coder */
- const int16_t nBins, /* i : Number of bins (spectral lines) */
- const int8_t nBands, /* i : Number of spectrum subbands */
- const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */
- const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */
- PsychoacousticParameters *pPsychParams );
-
-void concealment_init(
- const int16_t L_frameTCX,
- T_PLCInfo_HANDLE hPlcInfo );
-
-void concealment_decode(
- const int16_t core,
- float *invkoef,
- T_PLCInfo_HANDLE hPlcInfo );
-
-void concealment_update(
- const int16_t bfi,
- const int16_t core,
- const int16_t harmonic,
- float *invkoef,
- T_PLCInfo_HANDLE hPlcInfo );
-
-void concealment_update2(
- const float *outx_new,
- T_PLCInfo_HANDLE hPlcInfo,
- const int16_t L_frameTCX );
-
-void concealment_signal_tuning(
- Decoder_State *st,
- const int16_t bfi,
- float *outx_new,
- const int16_t past_core_mode );
-
-void waveform_adj2(
- T_PLCInfo_HANDLE hPlcInfo,
- float *overlapbuf,
- float *outx_new,
- const int16_t delay,
- const int16_t bfi_cnt,
- const int16_t bfi );
-
-float SFM_Cal(
- const float fcoef[],
- const int16_t n );
-
-void set_state_ivas(
- int16_t *state,
- const int16_t num,
- const int16_t N );
-
-int16_t RFFTN(
- float *afftData,
- const float *trigPtr,
- const int16_t len,
- const int16_t isign );
-
-void DoFFT(
- float *re2,
- float *im2,
- const int16_t length );
-
-/*! r: flag indicating a valid bitrate */
-int16_t is_EVS_bitrate(
- const int32_t ivas_total_brate, /* i : EVS total bitrate */
- int16_t *Opt_AMR_WB /* i : AMR-WB IO flag */
-);
-
-int16_t getTcxonly_ivas(
- const int16_t element_mode, /* i : IVAS element mode */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
- const int16_t is_ism_format /* i : flag indicating ISM format */
-);
-
-int16_t getTnsAllowed(
- const int32_t total_brate, /* i : total bitrate */
- const int16_t igf, /* i : flag indicating IGF activity*/
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-int16_t getCtxHm(
- const int16_t element_mode, /* i : IVAS element mode */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t rf_flag /* i : flag to signal the RF mode */
-);
-
-int16_t getResq(
- const int32_t total_brate /* i : total bitrate */
-);
-
-int16_t getMdctWindowLength(
- const int16_t fscale );
-
-int16_t sr2fscale(
- const int32_t sr_core /* i : internal sampling rate */
-);
-
-int32_t getCoreSamplerateMode2_flt(
- const int16_t element_mode, /* i : IVAS element mode */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
- const int16_t rf_mode, /* i : flag to signal the RF mode */
- const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */
-);
-
-float getTcxBandwidth_flt(
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-
-int16_t getCnaPresent(
- const int16_t element_mode, /* i : element mode */
- const int32_t element_brate, /* i : element bitrate */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-int16_t getTcxLtp(
- const int32_t sr_core /* i : internal sampling rate */
-);
-
-int16_t initPitchLagParameters(
- const int32_t sr_core, /* i : internal sampling rate */
- int16_t *pit_min,
- int16_t *pit_fr1,
- int16_t *pit_fr1b,
- int16_t *pit_fr2,
- int16_t *pit_max );
-
-void attenuateNbSpectrum(
- const int16_t L_frame,
- float *spectrum );
-
-void SetModeIndex(
- Encoder_State *st, /* i : Encoder state */
- const int32_t last_total_brate, /* i : last total bitrate */
- const int16_t last_element_mode, /* i : last IVAS element mode */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-int16_t getNumTcxCodedLines(
- const int16_t bwidth /* i : audio bandwidth */
-);
-
-int16_t getTcxLpcShapedAri(
- const int32_t total_brate, /* i : total bitrate */
- const int16_t rf_mode, /* i : flag to signal the RF mode */
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-void IGFEncApplyMono(
- Encoder_State *st, /* i : Encoder state */
- const int16_t igfGridIdx, /* i : IGF grid index */
- float *pMDCTSpectrum, /* i/o: MDCT spectrum */
- float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
- const int16_t isTNSActive, /* i : flag indicating if the TNS is active */
- const int16_t sp_aud_decision0, /* i : first stage switching decision */
- const int16_t vad_hover_flag /* i : VAD hangover flag */
-);
-
-void IGFEncApplyStereo(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
- int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
- const int16_t igfGridIdx, /* i : IGF grid index */
- Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
- float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
- float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
- const int16_t frameno, /* i : flag indicating index of current subframe */
- const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
- const int32_t element_brate, /* i : element bitrate */
- const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
-);
-
-
-void IGFEncResetTCX10BitCounter_ivas_fx(
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */
-);
-
-ivas_error IGF_Reconfig(
- IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */
- const int16_t igf, /* i : IGF on/off */
- const int16_t reset, /* i : reset flag */
- const int32_t brate, /* i : bitrate for configuration */
- const int16_t bwidth, /* i : signal bandwidth */
- const int16_t element_mode, /* i : IVAS element mode */
- const int16_t rf_mode /* i : flag to signal the RF mode */
-);
-
-void IGFEncSetMode(
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
- const int32_t total_brate, /* i : encoder total bitrate */
- const int16_t bwidth, /* i : encoder audio bandwidth */
- const int16_t element_mode, /* i : IVAS element mode */
- const int16_t rf_mode /* i : flag to signal the RF mode */
-);
-
-/*! r: number of bits written per frame */
-int16_t IGFEncWriteBitstream(
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- int16_t *pBitOffset, /* i : ptr to bitOffset counter */
- const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
- const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
-);
-
-/*! r: total number of bits written */
-int16_t IGFEncWriteConcatenatedBitstream(
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
- BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
-);
-
-void IGFDecApplyMono_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */
- float *spectrum, /* i/o: MDCT spectrum */
- const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
- const int16_t bfi, /* i : frame loss == 1, frame good == 0 */
- const int16_t element_mode /* i : IVAS element mode */
-);
-
-void IGFDecCopyLPCFlatSpectrum_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
- const float *pSpectrumFlat, /* i : LPC flattend spectrum from TCX dec */
- const int16_t igfGridIdx /* i : IGF grid index */
-);
-
-void IGFDecReadData_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
- Decoder_State *st, /* i : decoder state */
- const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
- const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
-);
-
-/*! r: return igfAllZero flag indicating if no envelope is transmitted */
-int16_t IGFDecReadLevel_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
- Decoder_State *st, /* i : decoder state */
- const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
- const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
-);
-
-void IGFDecRestoreTCX10SubFrameData_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
- const int16_t subFrameIdx /* i : index of subframe */
-);
-
-void init_igf_dec_flt(
- IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */
-);
-
-void IGFDecSetMode_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
- const int32_t total_brate, /* i : bitrate */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t element_mode, /* i : IVAS element mode */
- const int16_t defaultStartLine, /* i : default start subband index */
- const int16_t defaultStopLine, /* i : default stop subband index */
- const int16_t rf_mode /* i : flag to signal the RF mode */
-);
-
-void IGFDecStoreTCX10SubFrameData_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
- const int16_t subFrameIdx /* i : index of subframe */
-);
-
-void IGFDecUpdateInfo_flt(
- const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
- const int16_t subFrameIdx, /* i : subframe index */
- const int16_t igfGridIdx /* i : IGF grid index */
-);
-
-/*! r: error value: 0 -> error, 1 -> ok */
-int16_t IGFCommonFuncsIGFConfiguration_flt(
- const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t element_mode, /* i : IVAS element mode */
- H_IGF_INFO hIGFInfo, /* o : IGF info handle */
- const int16_t rf_mode /* i : flag to signal the RF mode */
-);
-
-/*! r: error value: 0 -> error, 1 -> ok */
-int16_t IGFCommonFuncsIGFGetCFTables_flt(
- const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t element_mode, /* i : element mode */
- const int16_t rf_mode, /* i : flag to signal the RF mode */
- const uint16_t **cf_se00, /* i : CF table for t == 0 and f == 0 */
- const uint16_t **cf_se01, /* i : CF table for t == 0 and f == 1 */
- int16_t *cf_off_se01, /* o : offset for CF table above */
- const uint16_t **cf_se02, /* i : CF tables for t == 0 and f >= 2 */
- const int16_t **cf_off_se02, /* o : offsets for CF tables above */
- const uint16_t **cf_se10, /* i : CF table for t == 1 and f == 0 */
- int16_t *cf_off_se10, /* o : offset for CF table above */
- const uint16_t **cf_se11, /* i : CF tables for t == 1 and f >= 1 */
- const int16_t **cf_off_se11 /* o : offsets for CF tables above */
-);
-
-/*! r: multiplication factor */
-int16_t IGF_ApplyTransFac_flt(
- const int16_t val, /* i : input value for multiplication, Q15 */
- const float transFac /* i : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */
-);
-
-/*! r: return bitrate index */
-int16_t IGF_MapBitRateToIndex_flt(
- const int32_t brate, /* i : bitrate */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t element_mode, /* i : element mode */
- const int16_t rf_mode /* i : flag to signal the RF mode */
-);
-
-
-void IGFSCFDecoderOpen_ivas(
- IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */
- H_IGF_INFO hIgfInfo, /* i : IGF info handle */
- const int32_t total_brate,
- const int16_t bwidth,
- const int16_t element_mode,
- const int16_t rf_mode );
-
-void IGFSCFDecoderReset_ivas(
- IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */
-);
-
-void IGFSCFDecoderDecode_ivas(
- IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
- Decoder_State *st, /* i/o: pointer to decoder state */
- int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */
- const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
- const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset,
- if 0 on input the decoder will be forced to encode without a reset */
-);
-
-/*! r: offset value */
-int16_t tbe_celp_exc_offset_flt(
- const int16_t T0, /* i : Integer pitch */
- const int16_t T0_frac /* i : Fractional part of the pitch */
-);
-
-void blend_subfr2_flt(
- float *sigIn1, /* i : input signal for fade-out */
- float *sigIn2, /* i : input signal for fade-in */
- float *sigOut /* o : output signal */
-);
-
-void init_tcx_window_cfg(
- TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */
- const int32_t sr_core, /* i : SR core */
- const int32_t input_Fs, /* i : input/output SR */
- const int16_t L_frame, /* i : L_frame at sr_core */
- const int16_t L_frameTCX, /* i : L_frame at i/o SR */
- const int16_t encoderLookahead_enc, /* i : encoder LA at sr_core */
- const int16_t encoderLookahead_FB, /* i : encoder LA at i/o SR */
- const int16_t mdctWindowLength, /* i : window length at sr_core */
- const int16_t mdctWindowLengthFB, /* i : window length at i/o SR */
- const int16_t element_mode /* i : mode of CPE/SCE */
-);
-
-void init_tcx_cfg(
- TCX_CONFIG_HANDLE hTcxCfg,
- const int32_t total_brate,
- const int32_t sr_core,
- const int32_t input_Fs,
- const int16_t L_frame,
- const int16_t bwidth,
- const int16_t L_frameTCX,
- const int16_t fscale,
- const int16_t encoderLookahead_enc,
- const int16_t encoderLookahead_FB,
- const float preemph_fac,
- const int16_t tcxonly,
- const int16_t rf_mode,
- const int16_t igf,
- const int16_t infoIGFStopFreq,
- const int16_t element_mode,
- const int16_t ini_frame,
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-);
-
-#endif
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index c67e2da28b28bf40623485b9a7fed21f1a508438..ffd1d603231e5ab9f4bfa2653e684c4b288a13ee 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -49,14 +49,59 @@
#include "ivas_cnst.h"
#include "stat_enc.h"
#include "stat_dec.h"
+#include "stat_com.h"
#include "ivas_stat_enc.h"
#include "ivas_stat_dec.h"
+#include "ivas_stat_com.h"
#include "ivas_error.h"
#include "ivas_error_utils.h"
#include "complex_basop.h"
#define TCX_IMDCT_SCALE 15
#define TCX_IMDCT_HEADROOM 1
+
+/*----------------------------------------------------------------------------------*
+ * Prototypes of global macros
+ *----------------------------------------------------------------------------------*/
+
+#ifndef min
+#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
+#endif
+
+#ifndef max
+#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
+#endif
+
+#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f )
+#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) )
+
+#ifndef ABSVAL
+#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) )
+#endif
+
+#ifndef SQR
+#define SQR( a ) ( ( a ) * ( a ) )
+#endif
+
+#ifndef SWAP
+#define SWAP( a, b ) \
+ { \
+ tempr = ( a ); \
+ ( a ) = ( b ); \
+ ( b ) = tempr; \
+ }
+#endif
+
+#ifndef swap
+#define swap( x, y, type ) \
+ { \
+ type u__p; \
+ u__p = x; \
+ x = y; \
+ y = u__p; \
+ }
+#endif
+
/*================================================================================*/
/* conversion functions: */
/*================================================================================*/
@@ -836,13 +881,11 @@ Word16 lpc2lsp_fx(
Word16 *old_freq,
Word16 order );
-#ifdef FIX_ISSUE_1165
Word16 lpc2lsp_ivas_fx(
Word32 *a,
Word16 *freq,
Word16 *old_freq,
Word16 order );
-#endif
void lsp2lpc_fx(
Word16 *a,
@@ -1198,6 +1241,7 @@ Word16 E_LPC_lsp_unweight(
);
Word32 E_LPC_schur( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, Word32 epsP[] /*Qr*/, const Word16 m );
+Word32 E_LPC_schur_ivas( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, const Word16 m );
void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/, const Word16 *old_lsf /*15Q16*/, Word16 lpcOrder, Word8 lpcRep /*Q0*/ );
@@ -1277,7 +1321,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */
);
void reset_indices_enc_fx(
- BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
+ const Word16 max_num_indices /* i : max number of indices */
);
void reset_indices_dec_fx(
@@ -1321,18 +1366,6 @@ Word16 BRATE2IDX16k_fx( Word32 brate );
Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc );
Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc );
-Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- FILE *file, /* i : bitstream file */
- Word16 rew_flag /* i : rewind flag (rewind file after reading) */
-);
-
-Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */
- Decoder_State *st, /* i/o: decoder state structure */
- FILE *file, /* i : bitstream file */
- Word16 rew_flag /* i : rewind flag (rewind file after reading)*/
-);
-
void getPartialCopyInfo(
Decoder_State *st, /* i : decoder state structure */
Word16 *coder_type,
@@ -1364,19 +1397,6 @@ void get_NextCoderType_fx(
Word16 *next_coder_type /* o : next coder type */
);
-void read_indices_from_djb_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- UWord8 *pt_stream, /* i : bitstream file */
- Word16 nbits /* i : number of bits */
- ,
- Word16 isAMRWB_IOmode,
- Word16 core_mode,
- Word16 qbit,
- Word16 partialframe /* i : partial frame information */
- ,
- Word16 next_coder_type /* i : next coder type information */
-);
-
void evs_dec_previewFrame(
UWord8 *bitstream, /* i : bitstream pointer */
Word16 bitstreamSize, /* i : bitstream size */
@@ -1631,7 +1651,6 @@ void deemph_fx(
void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, Word16 *mem );
void deemph_fx_32(
- Word16 shift, /* i : scaled output */
Word32 *signal, /* i/o: signal */
const Word16 mu, /* i : deemphasis factor */
const Word16 L, /* i : vector size */
@@ -2570,14 +2589,12 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q
// modif_fs_fx.c
Word16 modify_Fs_fx( /* o : length of output Q0 */
const Word16 sigIn_fx[], /* i : signal to decimate Q0 */
- Word16 lg, /* i : length of input Q0 */
- const Word32 fin, /* i : frequency of input Q0 */
+ Word16 lg, /* i : length of i Q0 */
+ const Word32 fin, /* i : frequency of i Q0 */
Word16 sigOut_fx[], /* o : decimated signal Q0 */
const Word32 fout, /* i : frequency of output Q0 */
Word16 mem_fx[], /* i/o: filter memory Q0 */
- const Word16 nblp, /* i : flag indicating if NB low-pass is applied */
- Word16 *Q_new_inp, // TO be removed
- Word16 *mem_decim_size // TO be removed
+ const Word16 nblp /* i : flag indicating if NB low-pass is applied */
);
Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */
@@ -2591,49 +2608,70 @@ Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output
void Decimate_allpass_steep_fx(
const Word16 *in_fx,
- Word16 mem[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
- Word16 N, /* number of input samples */
- Word16 out_fx[] );
+ Word16 mem[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
+ Word16 N, /* number of input samples */
+ Word16 out_fx[] /* o : output array of size N/2 */
+);
+
+void Decimate_allpass_steep_fx32(
+ const Word32 *in, /* i : input array of size N */
+ Word32 *mem, /* i/o: memory */
+ const Word16 N, /* i : number of input samples */
+ Word32 *out /* o : output array of size N/2 */
+);
void Interpolate_allpass_steep_fx(
const Word16 *in_fx,
- Word16 mem[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
- Word16 N, /* number of input samples */
- Word16 out_fx[] );
+ Word16 mem[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
+ Word16 N, /* number of input samples */
+ Word16 out_fx[] /* o : output array of size 2*N */
+);
+
+void Interpolate_allpass_steep_fx32(
+ const Word32 *in_fx, /* i : input array of size N */
+ Word32 *mem_fx, /* i/o: memory */
+ const int16_t N, /* i : number of input samples */
+ Word32 *out_fx /* o : output array of size 2*N */
+);
void interpolate_3_over_2_allpass_fx(
- const Word16 *input_fx,
- /* i : input signal */ /* Q_input */
- const Word16 len, /* i : number of input samples */
- Word16 *out_fx,
- /* o : output signal */ /* Q_input */
- Word16 *mem_fx,
- /* i/o: memory */ /* Q_input */
- const Word16 *filt_coeff_fx /* i : filter coefficients */ /* Q15*/
+ const Word16 *input_fx, /* i : input signal Q_input */
+ const Word16 len, /* i : number of input samples */
+ Word16 *out_fx, /* o : output signal Q_input */
+ Word16 *mem_fx, /* i/o: memory Q_input */
+ const Word16 *filt_coeff_fx /* i : filter coefficients Q15*/
+);
+
+void interpolate_3_over_2_allpass_fx32(
+ const Word32 *input, /* i : input signal Qx */
+ const int16_t len, /* i : number of input samples */
+ Word32 *out, /* o : output signal */
+ Word32 *mem /* i/o: memory */
);
void interpolate_3_over_1_allpass_fx(
- const Word16 *input_fx,
- /* i : input signal */ /* Q_input */
- const Word16 len, /* i : number of input samples */
- Word16 *out_fx,
- /* o : output signal */ /* Q_input */
- Word16 *mem_fx /* i/o: memory */ /* Q_input */
+ const Word16 *input_fx, /* i : input signal Q_input */
+ const Word16 len, /* i : number of input samples */
+ Word16 *out_fx, /* o : output signal Q_input */
+ Word16 *mem_fx /* i/o: memory Q_input */
+);
+
+void interpolate_3_over_1_allpass_fx32(
+ const Word32 *input, /* i : input signal Qx */
+ const Word16 len, /* i : number of input samples */
+ Word32 *out, /* o : output signal */
+ Word32 *mem /* i/o: memory */
);
void decimate_2_over_3_allpass_fx(
- const Word16 *input,
- /* i : input signal */ /* Q_input */
- const Word16 len, /* i : number of input samples */
- Word16 *out_fx,
- /* o : output signal */ /* Q_input */
- Word16 *mem_fx,
- /* i/o: memory */ /* Q_input */
- const Word16 *filt_coeff_fx,
- /* i : filter coefficients */ /* Q15*/
- const Word16 *lp_num_fx, /* i : Num Coefficients : Q15 */
- const Word16 *lp_den_fx, /* o : Den Coefficients : Q15 */
- Word16 *lp_mem_fx /* o : Filter memories : Q_input */
+ const Word16 *input, /* i : input signal Q_input */
+ const Word16 len, /* i : number of input samples */
+ Word16 *out_fx, /* o : output signal Q_input */
+ Word16 *mem_fx, /* i/o: memory Q_input */
+ const Word16 *filt_coeff_fx, /* i : filter coefficients Q15 */
+ const Word16 *lp_num_fx, /* i : Num Coefficients : Q15 */
+ const Word16 *lp_den_fx, /* o : Den Coefficients : Q15 */
+ Word16 *lp_mem_fx /* o : Filter memories : Q_input */
);
void retro_interp4_5_fx(
@@ -2866,7 +2904,8 @@ void swb_tbe_reset_fx(
void swb_tbe_reset_synth_fx(
Word32 genSHBsynth_Hilbert_Mem[],
- Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[] );
+ Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[],
+ Word32 genSHBsynth_state_lsyn_filt_shb_local_fx_32[] );
void fb_tbe_reset_synth_fx(
Word32 fbbwe_hpf_mem_fx[][4],
@@ -3130,7 +3169,7 @@ void GenSHBSynth_fx(
const Word16 L_frame, /* i : ACELP Frame length */
Word16 *syn_dm_phase );
-void GenSHBSynth_fx_32(
+void GenSHBSynth_fx32(
const Word32 *input_synspeech, /* i : input synthesized speech */
Word32 *shb_syn_speech_32k, /* o : output highband component */
Word32 Hilbert_Mem[], /* i/o: memory */
@@ -3151,7 +3190,7 @@ void ScaleShapedSHB_fx(
Word16 n_mem3,
Word16 prev_Q_bwe_syn2 );
-void ScaleShapedSHB_32(
+void ScaleShapedSHB_fx32(
const Word16 length, /* i : SHB overlap length */
Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */
Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */
@@ -4437,14 +4476,15 @@ void calcGainTemp_TBE_Fx(
Word16 *pGainTemp_e,
const Word16 code );
-Word16 procTecTfa_TBE_Fx( Word16 *hb_synth_Fx,
- Word16 hb_synth_fx_exp,
- Word16 *gain_m,
- Word16 *gain_e,
- Word16 flat_flag,
- Word16 last_core,
- Word16 l_subfr,
- Word16 code );
+Word16 procTecTfa_TBE_Fx(
+ Word16 *hb_synth_Fx,
+ Word16 hb_synth_fx_exp,
+ Word16 *gain_m,
+ Word16 *gain_e,
+ Word16 flat_flag,
+ Word16 last_core,
+ Word16 l_subfr,
+ Word16 code );
void calcHiEnvLoBuff_Fix(
const Word16 noCols,
@@ -4655,6 +4695,7 @@ Word16 find_guarded_bits_fx( Word32 n );
Word16 L_norm_arr( const Word32 *arr, Word16 size );
Word16 norm_arr( Word16 *arr, Word16 size );
+Word16 W_norm_arr( Word64 *arr, Word16 size );
Word16 get_min_scalefactor( Word32 x, Word32 y );
@@ -4714,24 +4755,26 @@ void r_fft_fx_lc(
);
// cldfb_evs
-void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */
- Word32 **cldfbReal, /*!< Pointer to real subband slots */
- Word32 **cldfbImag, /*!< Pointer to imag subband slots */
- CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */
- const Word16 *timeIn, /*!< Time signal */
- const Word16 timeIn_e, /*!< Time signal */
- const Word16 nTimeSlots, /*!< Time slots to be processed */
- Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
-);
-
-void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */
- Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */
- Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */
- const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */
- Word16 *timeOut, /*!< Time signal */
- const Word16 timeOut_e, /*!< Target exponent for output signal */
- const Word16 nTimeSlots, /*!< number of time slots to be processed */
- Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
+void cldfbAnalysis_fx(
+ HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */
+ Word32 **cldfbReal, /*!< Pointer to real subband slots */
+ Word32 **cldfbImag, /*!< Pointer to imag subband slots */
+ CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */
+ const Word16 *timeIn, /*!< Time signal */
+ const Word16 timeIn_e, /*!< Time signal */
+ const Word16 nTimeSlots, /*!< Time slots to be processed */
+ Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
+);
+
+void cldfbSynthesis_fx(
+ HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */
+ Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */
+ Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */
+ const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */
+ Word16 *timeOut, /*!< Time signal */
+ const Word16 timeOut_e, /*!< Target exponent for output signal */
+ const Word16 nTimeSlots, /*!< number of time slots to be processed */
+ Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
);
void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< CLDFB Handle */
@@ -4807,33 +4850,31 @@ Word16 BITS_ALLOC_config_acelp(
const Word16 nb_subfr );
ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
-#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signalling_bits, /* i : number of signalling bits */
+ const Word16 coder_type, /* i : coder type */
const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
-#endif
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
+ const Word16 tc_subfr, /* i : TC subfr ID */
+ const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
+ Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
+ Word16 *unbits, /* o : number of unused bits */
+ const Word16 element_mode, /* i : element mode */
+ Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
+ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 idchan, /* i : stereo channel ID */
+ const Word16 active_cnt, /* i : Active frame counter */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
Word16 set_ACELP_flag(
@@ -4865,24 +4906,18 @@ Word16 est_tilt_fx( /* o : tilt of the code
const Word32 gain_code, /* i : algebraic code gain Q16 */
Word16 *voice_fac, /* o : voicing factor Q15 */
const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
-#ifdef ADD_LRTD
- ,
- const Word16 L_subfr /* i : Sub frame lenght */
-#endif
);
-Word16 est_tilt_ivas_fx( /* o : tilt of the code Q15 */
- const Word16 *exc, /* i : adaptive excitation vector Qx */
- const Word16 gain_pit, /* i : adaptive gain Q14 */
- const Word16 *code, /* i : algebraic excitation vector Q9 */
- const Word32 gain_code, /* i : algebraic code gain Q16 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
-#if 1 // def ADD_LRTD
- ,
- const Word16 L_subfr, /* i : Sub frame length */
- const Word16 flag_tilt /* i : flag for special tilt */
-#endif
+/* o : tilt of the code Q15 */
+Word16 est_tilt_ivas_fx(
+ const Word16 *exc, /* i : adaptive excitation vector Qx */
+ const Word16 gain_pit, /* i : adaptive gain Q14 */
+ const Word16 *code, /* i : algebraic excitation vector Q9 */
+ const Word32 gain_code, /* i : algebraic code gain Q16 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */
+ const Word16 L_subfr, /* i : Sub frame length */
+ const Word16 flag_tilt /* i : flag for special tilt */
);
Word16 Est_tilt2( /* o : tilt of the code */
@@ -5775,7 +5810,7 @@ Word16 tcx_ltp_decode_params(
const Word16 pitres /* Q0 */
);
-void tcx_ltp_post(
+void tcx_ltp_post_fx(
Decoder_State *st,
TCX_LTP_DEC_HANDLE hTcxLtpDec,
Word16 core, /* Q0 */
@@ -5785,7 +5820,7 @@ void tcx_ltp_post(
Word16 *tcx_buf /* Qx */
);
-void tcx_ltp_post32(
+void tcx_ltp_post_fx32(
Decoder_State *st,
TCX_LTP_DEC_HANDLE hTcxLtpDec,
Word16 core, /* Q0 */
@@ -5810,23 +5845,18 @@ void Inac_swtch_ematch_fx(
);
void Inac_switch_ematch_ivas_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
-#ifdef NONBE_FIX_GSC_BSTR
+ Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
+ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
+ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
+ const Word16 coder_type, /* i : Coding mode */
const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
-#endif
- const Word16 L_frame, /* i : Frame lenght */
-#ifndef NONBE_FIX_GSC_BSTR
- const Word32 core_brate, /* i : Core bit rate */
-#endif
- const Word16 Q_exc, /* i : input and output format of exc2 */
- const Word16 bfi, /* i : frame lost indicator */
- const Word16 last_core, /* i : Last core used */
- const Word16 last_codec_mode, /* i : Last codec mode */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const Word16 element_mode /* i : element mode */
+ const Word16 L_frame, /* i : Frame lenght */
+ const Word16 Q_exc, /* i : input and output format of exc2 */
+ const Word16 bfi, /* i : frame lost indicator */
+ const Word16 last_core, /* i : Last core used */
+ const Word16 last_codec_mode, /* i : Last codec mode */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
+ const Word16 element_mode /* i : element mode */
);
// igf_base_fx.c
@@ -5962,13 +5992,9 @@ Word32 calc_gain_inov( /* returns innovation gain
/* Lib_dec */
//////////////////////////////////
// swb_tbe_dec.c
-
-void InitSWBdecBuffer_fx(
- Decoder_State *swb_dnc_fx /* i/o: SHB decoder structure */
-);
-
void ResetSHBbuffer_Dec_fx(
- Decoder_State *st_fx /* i/o: decoder state structure */
+ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
+ const Word16 extl /* i : BWE extension layer */
);
void wb_tbe_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
@@ -6027,45 +6053,40 @@ void tbe_read_bitstream_fx(
);
void GenTransition_fx(
- const Word16 *i, /* i : gain shape overlap buffer */
- const Word16 *old_hb_synth, /* i : synthesized HB from previous frame */
- Word16 length, /* i : targeted length of transition signal */
- Word16 *output, /* o : synthesized transitions signal */
- Word32 Hilbert_Mem[], /* i/o: memory */
- Word16 state_lsyn_filt_shb_local[], /* i/o: memory */
- Word16 mem_resamp_HB_32k[], /* i/o: memory */
- Word16 *syn_dm_phase,
- Word32 output_Fs,
- Word16 *up_mem,
- Word16 rf_flag,
- Word32 bitrate );
+ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
+ Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */
+ const Word32 output_Fs, /* i : output sampling rate */
+ Word16 rf_flag, /* i : RF flag */
+ Word32 total_bitrate /* i : total bitrate */
+);
+
+void GenTransition_fx32(
+ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
+ Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */
+ const Word32 output_Fs, /* i : output sampling rate : Q0 */
+ const Word16 L_frame, /* i : ACELP frame length : Q0 */
+ const Word16 prev_Qx );
void GenTransition_WB_fx(
- const Word16 *i, /* i : gain shape overlap buffer */
- const Word16 *old_hb_synth, /* i : synthesized HB from previous frame */
- const Word16 prev_Qx, /* i : scaling of old_hb_synth */
- Word16 length, /* i : targeted length of transition signal */
- Word16 *output, /* o : synthesized transitions signal */
- Word16 state_lsyn_filt_shb1[],
- Word16 state_lsyn_filt_shb2[],
- Word32 output_Fs,
- Word16 *up_mem );
-void TBEreset_dec_ivas_fx(
- Decoder_State *st /* i/o: decoder state structure */
+ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
+ Word16 *output, /* o : synthesized transitions signal */
+ const Word32 output_Fs /* i : output sampling rate */
+);
+
+void GenTransition_WB_fx32(
+ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
+ Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */
+ const Word32 output_Fs /* i : output sampling rate */
);
void TBEreset_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 bandwidth /* i : bandwidth mode */
+ Decoder_State *st_fx /* i/o: decoder state structure */
);
void td_bwe_dec_init_fx(
- Decoder_State *st_fx, /* i/o: SHB decoder structure */
TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
-#ifdef ADD_IVAS_BWE
- const Word16 extl, /* i : BWE extension layer */
-#endif
- const Word32 output_Fs /* i : output sampling rate */
+ const Word16 extl, /* i : BWE extension layer */
+ const Word32 output_Fs /* i : output sampling rate */
);
// lsf_dec_fx.c
@@ -6278,82 +6299,136 @@ void td_cng_dec_init_fx(
DEC_CORE_HANDLE st /* i/o: decoder state structure */
);
-void td_cng_dec_init_ivas_fx(
- DEC_CORE_HANDLE st /* i/o: decoder state structure */
-);
-
// wavadjust_fec_dec_fx.c
-void set_state( Word16 *state, Word16 num, Word16 N );
-void concealment_init_x( Word16 N, void *_plcInfo );
-void concealment_init_ivas_fx(
+void set_state(
+ Word16 *state,
+ Word16 num,
+ Word16 N );
+
+void concealment_init_x(
const Word16 L_frameTCX,
T_PLCInfo_HANDLE hPlcInfo );
-void concealment_update_x( Word16 bfi, Word16 curr_mode, Word16 harmonic, Word32 *invkoef, Word16 *invkoef_scale, void *_plcInfo );
-Word16 Sqrt_x_fast( Word32 value );
-
-Word32 dot_w32_accuracy_x( Word16 *s1, Word16 *s2, Word16 nbits, Word16 N );
-Word16 int_div_s_x( Word16 a, Word16 b );
-
-Word16 GetW32Norm_x( Word32 *s, Word16 N );
-
-Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch );
-
-void LpFilter2_x( Word16 *x, Word16 *y, Word16 N );
-
-void sig_tilt_x( Word16 *s, Word16 FrameSize, Word32 *enr1, Word32 *enr2 );
-
-void get_maxConv_and_pitch_x( Word16 *s_LP, Word16 s, Word16 e, Word16 N, Word32 *maxConv, Word16 *maxConv_bits, Word16 *pitch );
+void concealment_init_ivas_fx(
+ const Word16 L_frameTCX,
+ T_PLCInfo_HANDLE hPlcInfo );
-Word16 get_voicing_x( Word16 *s_LP, Word16 pitch, Word32 covMax, Word16 maxConv_bits, Word16 Framesize );
+void concealment_update_x(
+ const Word16 bfi,
+ const Word16 core,
+ const Word16 tonality,
+ Word32 *invkoef /*Qinvkoef_scale*/,
+ Word16 *invkoef_scale,
+ T_PLCInfo_HANDLE hPlcInfo );
-void pitch_modify_x( Word16 *s_LP, Word16 *voicing, Word16 *pitch, Word16 FrameSize );
+Word16 Sqrt_x_fast(
+ Word32 value );
-Word16 Is_Periodic_x( Word32 *mdct_data, Word16 cov_max, Word16 zp, Word32 ener, Word32 ener_mean, Word16 pitch, Word16 Framesize );
+Word32 dot_w32_accuracy_x(
+ Word16 *s1,
+ Word16 *s2,
+ Word16 nbits,
+ Word16 N );
-Word16 get_conv_relation_x( Word16 *s_LP, Word16 shift, Word16 N );
+Word16 int_div_s_x(
+ Word16 a,
+ Word16 b );
-void concealment_decode_fix( Word16 curr_mode, Word32 *invkoef, Word16 *invkoef_scale, void *_plcInfo );
+Word16 GetW32Norm_x(
+ Word32 *s,
+ Word16 N );
+
+Word16 harmo_x(
+ Word32 *X,
+ Word16 Framesize,
+ Word16 pitch );
+
+void LpFilter2_x(
+ Word16 *x,
+ Word16 *y,
+ Word16 N );
+
+void sig_tilt_x(
+ Word16 *s,
+ Word16 FrameSize,
+ Word32 *enr1,
+ Word32 *enr2 );
+
+void get_maxConv_and_pitch_x(
+ Word16 *s_LP,
+ Word16 s,
+ Word16 e,
+ Word16 N,
+ Word32 *maxConv,
+ Word16 *maxConv_bits,
+ Word16 *pitch );
+
+Word16 get_voicing_x(
+ Word16 *s_LP,
+ Word16 pitch,
+ Word32 covMax,
+ Word16 maxConv_bits,
+ Word16 Framesize );
+
+void pitch_modify_x(
+ Word16 *s_LP,
+ Word16 *voicing,
+ Word16 *pitch,
+ Word16 FrameSize );
+
+Word16 Is_Periodic_x(
+ Word32 *mdct_data,
+ Word16 cov_max,
+ Word16 zp,
+ Word32 ener,
+ Word32 ener_mean,
+ Word16 pitch,
+ Word16 Framesize );
+
+Word16 get_conv_relation_x(
+ Word16 *s_LP,
+ Word16 shift,
+ Word16 N );
+
+void concealment_decode_fix(
+ Word16 curr_mode,
+ Word32 *invkoef,
+ Word16 *invkoef_scale,
+ T_PLCInfo_HANDLE hPlcInfo );
-Word32 Spl_Energy_x( const Word16 *vector, const Word16 vector_length, Word16 *scale_factor );
+Word32 Spl_Energy_x(
+ const Word16 *vector,
+ const Word16 vector_length,
+ Word16 *scale_factor );
-void Log10OfEnergy_x( const Word16 *s, Word32 *enerlogval, const Word16 len );
+void Log10OfEnergy_x(
+ const Word16 *s,
+ Word32 *enerlogval,
+ const Word16 len );
-void concealment_update2_x( const Word16 *outx_new, void *_plcInfo, const Word16 FrameSize );
+void concealment_update2_x(
+ const Word16 *outx_new,
+ T_PLCInfo_HANDLE hPlcInfo,
+ const Word16 FrameSize );
-Word16 ffr_getSfWord16( Word16 *vector, /*!< Pointer to i vector */
- Word16 len );
+Word16 ffr_getSfWord16(
+ Word16 *vector, /*!< Pointer to i vector */
+ Word16 len );
-void waveform_adj2_fix( Word16 *overlapbuf,
- Word16 *outx_new,
- Word16 *data_noise,
- Word16 *outx_new_n1,
- Word16 *nsapp_gain,
- Word16 *nsapp_gain_n,
- Word16 *recovery_gain,
- Word16 step_concealgain,
- Word16 pitch,
- Word16 Framesize,
- Word16 delay,
- Word16 bfi_cnt,
- Word16 bfi );
+void waveform_adj2_fix(
+ T_PLCInfo_HANDLE hPlcInfo,
+ Word16 *overlapbuf,
+ Word16 *outx_new,
+ const Word16 delay,
+ const Word16 bfi_cnt,
+ const Word16 bfi );
-void concealment_signal_tuning_fx( Word16 bfi,
- Word16 curr_mode,
- Word16 *outx_new_fx,
- void *_plcInfo,
- Word16 nbLostCmpt,
- Word16 pre_bfi,
- Word16 *OverlapBuf_fx,
- Word16 past_core_mode,
- Word16 *outdata2_fx,
- Decoder_State *st );
+void concealment_signal_tuning_fx(
+ Decoder_State *st,
+ const Word16 bfi,
+ Word16 *outx_new_fx /*Qoutx_new_fx*/,
+ const Word16 past_core );
-// TonalComponentDetect.c
-/* Detect tonal components in the lastMDCTSpectrum, use
- * secondLastPowerSpectrum for the precise location of the peaks and
- * store them in indexOfTonalPeak. Updates lowerIndex, upperIndex,
- * pNumIndexes accordingly. */
void DetectTonalComponents(
Word16 indexOfTonalPeak[],
Word16 lowerIndex[],
@@ -6377,12 +6452,6 @@ void DetectTonalComponents(
#endif
);
-/* When called, the tonal components are already stored in
- * indexOfTonalPeak. Detect tonal components in the lastMDCTSpectrum,
- * use secondLastPowerSpectrum for the precise location of the peaks and
- * then keep in indexOfTonalPeak only the tonal components that are
- * again detected Updates indexOfTonalPeak, lowerIndex, upperIndex,
- * phaseDiff, phases, pNumIndexes accordingly. */
void RefineTonalComponents(
Word16 indexOfTonalPeak[],
Word16 lowerIndex[],
@@ -6423,6 +6492,7 @@ void ivas_RefineTonalComponents_fx(
const Word16 scaleFactors_exp[],
const Word16 scaleFactors_max_e,
const Word32 secondLastPowerSpectrum[],
+ const Word16 secondLastPowerSpectrum_e,
const Word16 nSamples,
const Word16 nSamplesCore,
const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */
@@ -6480,26 +6550,13 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx(
const Word16 gain_tcx_exp,
const Word16 infoIGFStartLine );
-/* The call to TonalMDCTConceal_UpdateState() should be called after TonalMDCTConceal_Apply. */
-TONALMDCTCONCEAL_ERROR TonalMDCTConceal_UpdateState( TonalMDCTConcealPtr self,
- Word16 nNewSamples,
- Word32 pitchLag,
- Word16 badBlock,
- Word8 tonalConcealmentActive );
-
-/* The call to TonalMDCTConceal_SaveTimeSignal() should be at the
- * place where the TD signal corresponds to the FD signal stored with TonalMDCTConceal_SaveFreqSignal. */
-void TonalMDCTConceal_SaveTimeSignal(
- TonalMDCTConcealPtr hTonalMDCTConc,
- Word16 *timeSignal,
- Word16 nNewSamples );
+void TonalMDCTConceal_UpdateState(
+ TonalMDCTConcealPtr self,
+ Word16 nNewSamples,
+ Word32 pitchLag,
+ Word16 badBlock,
+ Word8 tonalConcealmentActive );
-/* Calculates MDST, power spectrum and performs peak detection.
- * Uses the TD signal in pastTimeSignal; if pastTimeSignal is NULL, uses the
- * TD signal stored using TonalMDCTConceal_SaveTimeSignal. If the
- * second last frame was also lost, it is expected that pastTimeSignal
- * could hold a signal somewhat different from the one stored in
- * TonalMDCTConceal_SaveTimeSignal (e.g. including fade-out).*/
void TonalMDCTConceal_Detect(
const TonalMDCTConcealPtr self, /*IN */
const Word32 pitchLag, /*IN */
@@ -6511,9 +6568,6 @@ void TonalMDCTConceal_Detect(
#endif
);
-/* Conceals the lost frame using the FD signal previously stored using
- * TonalMDCTConceal_SaveFreqSignal. Stores the concealed harmonic part of
- * the signal in mdctSpectrum, the rest of the spectrum is unchanged. */
void TonalMDCTConceal_Apply(
const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
Word32* mdctSpectrum, /*IN/OUT*/
@@ -6529,9 +6583,6 @@ void TonalMDCTConceal_Apply_ivas_fx(
Word16 mdctSpectrum_exp[L_FRAME48k], /*IN */
const PsychoacousticParameters *psychParamsCurrent );
-/* Conceals the lost frame using the FD signal previously stored using
- * TonalMDCTConceal_SaveFreqSignal. Stores the concealed noise part of
- * the signal in mdctSpectrum, the rest of the spectrum is unchanged. */
void TonalMDCTConceal_InsertNoise_ivas_fx(
const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
Word32 *mdctSpectrum,
@@ -6546,10 +6597,6 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
const Word16 cngLevelBackgroundTrace_e,
const Word16 crossOverFreq );
-
-/* Conceals the lost frame using the FD signal previously stored using
- * TonalMDCTConceal_SaveFreqSignal. Stores the concealed noise part of
- * the signal in mdctSpectrum, the rest of the spectrum is unchanged. */
void TonalMDCTConceal_InsertNoise(
const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
Word32 *mdctSpectrum, /*OUT*/
@@ -6562,24 +6609,12 @@ void TonalMDCTConceal_InsertNoise(
const Word16concealment_noise[L_FRAME48k],
#endif
const Word16 crossOverFreq );
-/* Conceals the lost frame using the FD signal previously stored using
- * TonalMDCTConceal_SaveFreqSignal. Stores the concealed harmonic part of
- * the signal in mdctSpectrum, the rest of the spectrum is unchanged. */
-void TonalMDCTConceal_Apply(
- const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
- Word32* mdctSpectrum, /*IN/OUT*/
- Word16* mdctSpectrum_exp /*IN */
-#ifdef IVAS_CODE_MDCT_GSHAPE
- , const PsychoacousticParameters* psychParamsCurrent)
-#endif
- );
-/* The call to TonalMDCTConceal_SaveTimeSignal() should be at the
- * place where the TD signal corresponds to the FD signal stored with TonalMDCTConceal_SaveFreqSignal. */
void TonalMDCTConceal_SaveTimeSignal(
TonalMDCTConcealPtr hTonalMDCTConc,
Word16 *timeSignal,
Word16 nNewSamples );
+
void TonalMDCTConceal_SaveTimeSignal_ivas_fx(
TonalMDCTConcealPtr hTonalMDCTConc,
Word16 *timeSignal,
@@ -6611,12 +6646,7 @@ void hf_synth_fx(
Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
const Word16 Q_exc, /* i : excitation scaling */
- const Word16 Q_syn2, /* i : synthesis scaling */
- Word16 *delay_syn_hf, /*i/o: HF synthesis memory Q_syn2*/
- Word16 *memExp1, /* o : HF excitation exponent */
- Word16 *mem_hp_interp, /* i/o: interpol. memory Qx*/
- const Word16 extl, /* i : flag indicating BWE Q0*/
- const Word16 CNG_mode /* i : CNG_mode Q0*/
+ const Word16 Q_syn2 /* i : synthesis scaling */
);
void hf_synth_amr_wb_init_fx(
@@ -7126,30 +7156,21 @@ void dec_pit_exc_fx(
const Word16 nb_subfr_fx /* i : Number of subframe considered */
,
Word16 *gain_buf /*Q14*/
-#ifdef ADD_LRTD
- ,
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-#endif
);
void dec_pit_exc_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 coder_type, /* i : coding type */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *code_fx, /* o : innovation */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- const Word16 nb_subfr_fx /* i : Number of subframe considered */
- ,
- Word16 *gain_buf /*Q14*/
-#if 1 // def ADD_LRTD
- ,
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *code_fx, /* o : innovation */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 nb_subfr_fx, /* i : Number of subframe considered */
+ Word16 *gain_buf, /*Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-#endif
);
// pit_dec_fx.c
@@ -7204,28 +7225,24 @@ Word16 pit_decode_fx( /* o : floating pitch value
Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
const Word16 L_subfr /* i : subframe length */
-#ifdef ADD_LRTD
- ,
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-#endif
);
-Word16 pit_decode_ivas_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr, /* i : subframe length */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
+/* o : floating pitch value */
+Word16 pit_decode_ivas_fx(
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 i_subfr, /* i : subframe index */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
+ Word16 *T0, /* o : close loop integer pitch */
+ Word16 *T0_frac, /* o : close loop fractional part of the pitch */
+ Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
+ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
);
void pit_Q_dec_fx(
@@ -7606,15 +7623,6 @@ void perform_noise_estimation_dec_fx(
float *power_spectrum,
#endif
HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */
-#ifdef IVAS_CODE_CNG
- ,
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidth */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */
- const Word32 last_core_brate, /* i : previous frame core bitrate */
- const Word16 VAD /* i : VAD flag in the decoder */
-#endif
);
void perform_noise_estimation_dec_ivas_fx(
@@ -7727,19 +7735,12 @@ Word16 WB_BWE_gain_deq_fx(
);
Word16 wb_bwe_dec_fx(
-#ifdef ADD_IVAS_BWE
- const Word16 output[], /* i : suntehsis @ internal Fs */
-#endif
- Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */
- Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */
-#ifdef ADD_IVAS_BWE
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
-#endif
+ Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */
+ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */
const Word16 output_frame, /* i : frame length */
Word16 *voice_factors_fx, /* i : voicing factors Q15 */
const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */
- Decoder_State *st_fx /* i/o: decoder state structure */
- ,
+ Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 *Qpost );
Word16 swb_bwe_gain_deq_fx( /* o : BWE class */
@@ -7751,18 +7752,11 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class
const Word16 hqswb_clas /* i : HQ BWE class */
);
-Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/
-#ifdef ADD_IVAS_BWE
- const Word16 output[], /* i : suntehsis @ internal Fs */
-#endif
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */
- Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */
-#ifdef ADD_IVAS_BWE
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
-#endif
- const Word16 output_frame /* i : frame length */
- ,
+Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */
+ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */
+ const Word16 output_frame, /* i : frame length */
Word16 *Qpost );
void fd_bwe_dec_init(
@@ -8038,22 +8032,12 @@ ivas_error core_switching_pre_dec_fx(
);
ivas_error core_switching_post_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/
-#ifdef IVAS_CODE_SWITCHING
- float *output, /* i/o: LB synth/upsampled LB synth */
- float output_mem[], /* i : OLA memory from last TCX/HQ frame */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
-#endif
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/
const Word16 output_frame, /* i : frame length Q0*/
const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/
-#ifdef IVAS_CODE_SWITCHING
- const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */
- const Word16 nchan_out, /* i : number of output channels */
-#endif
- const Word16 last_element_mode, /* i : element mode of previous frame Q0*/
- Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
+ const Word16 last_element_mode, /* i : element mode of previous frame Q0*/
+ Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
);
ivas_error core_switching_post_dec_ivas_fx(
@@ -8061,7 +8045,6 @@ ivas_error core_switching_post_dec_ivas_fx(
Word16 *synth, /* i/o: output synthesis Qsynth*/
Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/
Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/
const Word16 output_frame, /* i : frame length Q0*/
const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/
@@ -8743,10 +8726,6 @@ Word16 dec_acelp_tcx_frame_fx(
Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
Word16 *voice_factors, /* o : voicing factors */
Word16 pitch_buf[] /* o : floating pitch for each subframe */
-#ifdef IVAS_CODE_CNG
- ,
- STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */
-#endif
);
// dec_LPD_fx.c
@@ -9609,9 +9588,9 @@ ivas_error acelp_core_dec_fx(
// evs_dec_fx.c
ivas_error evs_dec_fx(
- Decoder_State *st_fx, /* i/o : Decoder state structure */
- Word16 output_sp[], /* o : output synthesis signal */
- frameMode_fx frameMode /* i : Decoder frame mode */
+ Decoder_State *st_fx, /* i/o : Decoder state structure */
+ Word16 output_sp[], /* o : output synthesis signal */
+ FRAME_MODE frameMode /* i : Decoder frame mode */
);
void fft_cldfb_fx(
@@ -9638,13 +9617,6 @@ void set32_fx(
const Word16 N /* i : Lenght of the vector */
);
-void delay_signal_fx(
- Word32 x[], /* i/o: signal to be delayed */
- const Word16 len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const Word16 delay /* i : delay in samples */
-);
-
void delay_signal_q_adj_fx(
Word32 x[], /* i/o: signal to be delayed */
const Word16 len, /* i : length of the input signal */
@@ -9767,10 +9739,14 @@ void cldfbAnalysis_ivas_fx(
);
void cldfbSynthesis_ivas_fx(
- Word32 **realBuffer_fx, /* i : real values Qx*/
- Word32 **imagBuffer_fx, /* i : imag values Qx*/
- Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/
- const Word16 samplesToProcess, /* i : number of processed samples */
+ Word32 **realBuffer_fx, /* i : real values Qx*/
+ Word32 **imagBuffer_fx, /* i : imag values Qx*/
+ Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/
+ const Word16 samplesToProcess, /* i : number of processed samples */
+ const Word16 shift, /* i : scale for state buffer */
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ const Word16 out_shift, /* i : scale for output buffer */
+#endif
HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */
);
@@ -9782,20 +9758,24 @@ void addBassPostFilter_ivas_fx(
Word32 **iAnalysis_fx,
HANDLE_CLDFB_FILTER_BANK cldfb );
-Word32 ism_dequant_meta_fx( /* o : Q22*/
- const Word16 idx, /* i : quantizer index */
- const Word32 borders_fx[], /* i : level borders Q22*/
- const Word32 q_step_fx, /* i : quantization step Q22 */
- const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/
- const Word16 cbsize /* i : codebook size */
+/* o : Q22*/
+Word32 ism_dequant_meta_fx(
+ const Word16 idx, /* i : quantizer index */
+ const Word32 borders_fx[], /* i : level borders Q22*/
+ const Word32 q_step_fx, /* i : quantization step Q22 */
+ const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/
+ const Word16 cbsize /* i : codebook size */
);
void save_synthesis_hq_fec_fx(
Decoder_State *st, /* i/o: decoder state structure */
+ const Word16 synth_fx[], /* i : decoded synthesis (EVS) */
const Word32 output_fx[], /* i : decoded synthesis */
const Word16 output_frame, /* i : decoded synthesis */
+ const Word16 Qpostd, /* i : Q value of delayed signal */
CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
);
+
void calculate_nbits_meta_fx(
const Word16 nchan_ism,
Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30
@@ -9815,8 +9795,8 @@ ivas_error openCldfb_ivas_fx(
HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
CLDFB_TYPE type, /* i : analysis or synthesis */
const Word32 sampling_rate, /* i : sampling rate */
- CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
-);
+ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */
+ const Word16 enc_dec ); /* i : encoder/decoder flag */
Word32 rand_gauss_fx(
Word32 *x,
@@ -9840,33 +9820,6 @@ void generate_masking_noise_dirac_ivas_fx(
Word16 *q_cldfb );
// modif_fs/c
-void interpolate_3_over_2_allpass_32(
- const Word32 *input, /* i : input signal Qx */
- const int16_t len, /* i : number of input samples */
- Word32 *out, /* o : output signal */
- Word32 *mem /* i/o: memory */
-);
-
-void interpolate_3_over_1_allpass_32(
- const Word32 *input, /* i : input signal */
- const int16_t len, /* i : number of input samples */
- Word32 *out, /* o : output signal */
- Word32 *mem /* i/o: memory */
-);
-void Decimate_allpass_steep_fx32(
- const Word32 *in, /* i : input array of size N */
- Word32 *mem, /* i/o: memory */
- const Word16 N, /* i : number of input samples */
- Word32 *out /* o : output array of size N/2 */
-);
-
-void Interpolate_allpass_steep_32(
- const Word32 *in_fx, /* i : input array of size N */
- Word32 *mem_fx, /* i/o: memory */
- const int16_t N, /* i : number of input samples */
- Word32 *out_fx /* o : output array of size 2*N */
-);
-
void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_TDAC, Word16 *xn_buf, const Word16 *tcx_aldo_window_1, const PWord16 *tcx_aldo_window_1_trunc, const PWord16 *tcx_aldo_window_2, const PWord16 *tcx_mdct_window_half, const PWord16 *tcx_mdct_window_minimum, const PWord16 *tcx_mdct_window_trans, Word16 tcx_mdct_window_half_length, Word16 tcx_mdct_window_min_length, Word16 index, Word16 left_rect, Word16 tcx_offset, Word16 overlap, Word16 L_frame, Word16 L_frameTCX, Word16 L_spec_TCX5, Word16 L_frame_glob, Word16 frame_cnt, Word16 bfi, Word16 *old_out, Word16 *Q_old_wtda, Decoder_State *st, Word16 fullbandScale, Word16 *acelp_zir );
void IMDCT_ivas_fx(
@@ -10560,15 +10513,15 @@ void floating_point_add(
const Word32 my, /* i: mantissa of the adder Q31 */
const Word16 ey /* i: exponent of the adder Q0 */
);
-/*delay_signal_fx is also present*/
-void delay_signal(
+
+void delay_signal_fx(
Word16 x[], /* i/o: signal to be delayed */
const Word16 len, /* i : length of the input signal */
Word16 mem[], /* i/o: synchronization memory */
const Word16 delay /* i : delay in samples */
);
-void delay_signal32(
+void delay_signal32_fx(
Word32 x[], /* i/o: signal to be delayed */
const Word16 len, /* i : length of the input signal */
Word32 mem[], /* i/o: synchronization memory */
@@ -10978,7 +10931,6 @@ void IGFEncConcatenateBitstream(
BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
);
-#endif
void hq_generic_hf_encoding_fx(
const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */
@@ -11023,33 +10975,31 @@ void lsf_syn_mem_backup_ivas_fx(
Word16 *pstreaklen );
ivas_error config_acelp1_IVAS(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signaling_bits, /* i : number of signaling bits */
- const Word16 coder_type, /* i : coder type */
-#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signaling_bits, /* i : number of signaling bits */
+ const Word16 coder_type, /* i : coder type */
const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
-#endif
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
+ const Word16 tc_subfr, /* i : TC subfr ID */
+ const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
+ Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
+ Word16 *unbits, /* o : number of unused bits */
+ const Word16 element_mode, /* i : element mode */
+ Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
+ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 idchan, /* i : stereo channel ID */
+ const Word16 active_cnt, /* i : Active frame counter */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
ivas_error push_next_indice(
@@ -11103,15 +11053,13 @@ void calculate_hangover_attenuation_gain_ivas_fx(
void init_coder_ace_plus_ivas_fx(
Encoder_State *st, /* i : Encoder state */
const Word32 last_total_brate, /* i : last total bitrate */
-#ifdef FIX_920_IGF_INIT_ERROR
- const Word32 igf_brate, /* i : IGF configuration bitrate */
-#endif
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+ const Word32 igf_brate, /* i : IGF configuration bitrate */
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void core_coder_reconfig_ivas_fx(
Encoder_State *st,
- const int32_t last_total_brate );
+ const Word32 last_total_brate );
void core_coder_mode_switch_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
@@ -11263,3 +11211,714 @@ void WriteToBitstream_ivas_fx(
Word16 *pnSize,
BSTR_ENC_HANDLE hBstr,
Word16 *pnBits );
+
+
+/*===========================================================================================*/
+/*----------------------------------------------------------------------------------*
+ * MODE1 prototypes
+ *----------------------------------------------------------------------------------*/
+
+/*! r: inverse square root of input value */
+float inv_sqrt(
+ const float x /* i : input value */
+);
+
+/*! r: output random value */
+int16_t own_random(
+ int16_t *seed /* i/o: random seed */
+);
+
+/*! r: sign of x (+1/-1) */
+float sign(
+ const float x /* i : input value of x */
+);
+
+/*! r: logarithm2 of x */
+float log2_f(
+ const float x /* i : input value of x */
+);
+
+int16_t norm_ul_float(
+ uint32_t UL_var1 );
+
+/*! r: sum of all vector elements */
+int16_t sum_s(
+ const int16_t *vec, /* i : input vector */
+ const int16_t lvec /* i : length of input vector */
+);
+
+/*! r: sum of all vector elements */
+int32_t sum_l(
+ const int32_t *vec, /* i : input vector */
+ const int16_t lvec /* i : length of input vector */
+);
+
+/*! r: sum of all squared vector elements */
+float sum2_f(
+ const float *vec, /* i : input vector */
+ const int16_t lvec /* i : length of input vector */
+);
+
+void set_c(
+ int8_t y[], /* i/o: Vector to set */
+ const int8_t a, /* i : Value to set the vector to */
+ const int32_t N /* i : Length of the vector */
+);
+
+void set_s(
+ int16_t y[], /* i/o: Vector to set */
+ const int16_t a, /* i : Value to set the vector to */
+ const int16_t N /* i : Lenght of the vector */
+);
+
+void set_l(
+ int32_t y[], /* i/o: Vector to set */
+ const int32_t a, /* i : Value to set the vector to */
+ const int16_t N /* i : Length of the vector */
+);
+
+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 */
+);
+
+void set_zero_fx(
+ Word32 *vec, /* o : input vector */
+ const Word16 lvec /* i : length of the vector */
+);
+void set_zero2_fx(
+ Word32 *vec, /* o : input vector */
+ const Word32 lvec /* i : length of the vector */
+);
+void set16_zero_fx(
+ Word16 *vec, /* o : input vector */
+ const Word16 lvec /* i : length of the vector */
+);
+
+void set_zero(
+ float *vec, /* o : input vector */
+ const int16_t lvec /* i : length of the vector */
+);
+
+void mvr2r(
+ const float x[], /* i : input vector */
+ float y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+);
+
+void mvs2s(
+ const int16_t x[], /* i : input vector */
+ int16_t y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+);
+
+uint32_t mvr2s(
+ const float x[], /* i : input vector */
+ int16_t y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+);
+
+void mvs2r(
+ const int16_t x[], /* i : input vector */
+ float y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+);
+
+void mvl2l(
+ const int32_t x[], /* i : input vector */
+ int32_t y[], /* o : output vector */
+ const int16_t n /* i : vector size */
+);
+
+
+/*! r: index of the maximum value in the input vector */
+int16_t maximum(
+ const float *vec, /* i : input vector */
+ const int16_t lvec, /* i : length of input vector */
+ float *max_val /* o : maximum value in the input vector */
+);
+/*! r: index of the maximum value in the input vector */
+int16_t maximumAbs(
+ const float *vec, /* i : input vector */
+ const int16_t lvec, /* i : length of input vector */
+ float *max_val /* o : maximum value in the input vector */
+);
+
+Word16 maximumAbs_l(
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word32 *max_val /* o : maximum value in the input vector */
+);
+
+/*! r: index of the minimum value in the input vector */
+int16_t minimum(
+ const float *vec, /* i : input vector */
+ const int16_t lvec, /* i : length of input vector */
+ float *min_val /* o : minimum value in the input vector */
+);
+
+/*! r: index of the minimum value in the input vector */
+int16_t minimum_s(
+ const int16_t *vec, /* i : Input vector */
+ const int16_t lvec, /* i : Vector length */
+ int16_t *min_val /* o : minimum value in the input vector */
+);
+
+/*! r: return index with max energy value in vector */
+int16_t emaximum(
+ const float *vec, /* i : input vector */
+ const int16_t lvec, /* i : length of input vector */
+ float *ener_max /* o : maximum energy value */
+);
+
+/*! r: vector mean */
+float mean(
+ const float *vec, /* i : input vector */
+ const int16_t lvec /* i : length of input vector */
+);
+
+/*! r: dot product of x[] and y[] */
+float dotp(
+ const float x[], /* i : vector x[] */
+ const float y[], /* i : vector y[] */
+ const int16_t n /* i : vector length */
+);
+
+void v_add(
+ const float x1[], /* i : Input vector 1 */
+ const float x2[], /* i : Input vector 2 */
+ float y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const int16_t N /* i : Vector length */
+);
+
+void v_sub(
+ const float x1[], /* i : Input vector 1 */
+ const float x2[], /* i : Input vector 2 */
+ float y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const int16_t N /* i : Vector length */
+);
+
+/*! r: dequanzited gain */
+float usdequant(
+ const int16_t idx, /* i : quantizer index */
+ const float qlow, /* i : lowest codebook entry (index 0) */
+ const float delta /* i : quantization step */
+);
+
+void sort(
+ uint16_t *x, /* i/o: Vector to be sorted */
+ uint16_t len /* i/o: vector length */
+);
+
+void sort_l(
+ Word32 *x, /* i/o: Vector to be sorted */
+ Word16 len /* i/o: vector length */
+);
+
+
+ivas_error push_indice(
+ 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 */
+);
+
+ivas_error push_next_indice(
+ BSTR_ENC_HANDLE hBstr,
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+);
+
+ivas_error push_next_bits(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */
+ const Word16 nb_bits /* i : number of bits to pack */
+);
+
+/*! r: maximum number of indices */
+Word16 get_ivas_max_num_indices_fx(
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate */
+);
+
+/*! r: maximum number of indices */
+int16_t get_BWE_max_num_indices(
+ const int32_t extl_brate /* i : extensiona layer bitrate */
+);
+
+/*! r: maximum number of indices */
+Word16 get_ivas_max_num_indices_metadata_fx(
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate */
+);
+ivas_error ind_list_realloc(
+ INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
+ const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */
+ Encoder_Struct *st_ivas /* i : IVAS encoder structure */
+);
+
+ivas_error check_ind_list_limits(
+ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
+);
+
+void move_indices(
+ INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
+ INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
+ const int16_t nb_indices /* i : number of moved indices */
+);
+
+/*! r: index of the indice in the list, -1 if not found */
+int16_t find_indice(
+ BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */
+ const int16_t id, /* i : ID of the indice */
+ uint16_t *value, /* o : value of the quantized indice */
+ int16_t *nb_bits /* o : number of bits used to quantize the indice */
+);
+
+/*! r: number of deleted indices */
+uint16_t delete_indice(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const int16_t id /* i : ID of the indice */
+);
+
+/*! r: value of the indice */
+uint16_t get_next_indice(
+ Decoder_State *st, /* i/o: decoder state structure */
+ int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+);
+
+/*! r: value of the indice */
+uint16_t get_next_indice_1(
+ Decoder_State *st /* i/o: decoder state structure */
+);
+
+void get_next_indice_tmp(
+ Decoder_State *st, /* o : decoder state structure */
+ int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+);
+
+/*! r: value of the indice */
+uint16_t get_indice(
+ 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 */
+);
+
+void reset_indices_dec(
+ Decoder_State *st /* i/o: decoder state structure */
+);
+
+Word16 rate2EVSmode_float(
+ const Word32 brate, /* i : bitrate */
+ int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
+);
+
+
+/*! r: 1 = OK, 0 = something wrong */
+ivas_error read_indices_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ UWord16 bit_stream[], /* i : bitstream buffer */
+ UWord16 num_bits, /* i : number of bits in bitstream */
+ Word16 *prev_ft_speech,
+ Word16 *CNG,
+ Word16 bfi /* i : bad frame indicator */
+);
+
+
+void ivas_set_bitstream_pointers(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+Decoder_State **reset_elements(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+void mdct_switching_dec_fx(
+ Decoder_State *st /* i/o: decoder state structure */
+);
+
+int16_t print_disclaimer(
+ FILE *fPtr );
+
+void fft_rel(
+ float x[], /* i/o: input/output vector */
+ const int16_t n, /* i : vector length */
+ const int16_t m /* i : log2 of vector length */
+);
+
+void preemph_ivas_fx(
+ Word32 *signal, /* i/o: signal Qx*/
+ const Word16 mu, /* i : preemphasis factor Q15*/
+ const Word16 L, /* i : vector size Q0*/
+ Word32 *mem /* i/o: memory (x[-1]) Qx*/
+);
+
+void create_offset(
+ UWord32 *offset_scale1,
+ UWord32 *offset_scale2,
+ const int16_t mode,
+ const int16_t prediction_flag );
+
+void BASOP_cfft_ivas(
+ Word32 *re, /* i/o: real part */
+ Word32 *im, /* i/o: imag part */
+ Word16 s, /* i : stride real and imag part */
+ Word16 *scale /* i : scalefactor */
+);
+
+Word32 ar_div_ivas(
+ Word32 num,
+ Word32 denum );
+
+Word32 Mult_32_16(
+ Word32 a,
+ Word16 b );
+
+Word32 Mult_32_32(
+ Word32 a,
+ Word32 b );
+
+
+void bit_allocation_second_fx2(
+ Word32 *Rk,
+ Word32 *Rk_sort,
+ Word16 BANDS,
+ const Word16 *band_width,
+ Word16 *k_sort,
+ Word16 *k_num,
+ const Word16 *p2a_flags,
+ const Word16 p2a_bands,
+ const Word16 *last_bitalloc,
+ const Word16 input_frame );
+
+void bit_allocation_second_fx2(
+ Word32 *Rk,
+ Word32 *Rk_sort,
+ Word16 BANDS,
+ const Word16 *band_width,
+ Word16 *k_sort,
+ Word16 *k_num,
+ const Word16 *p2a_flags,
+ const Word16 p2a_bands,
+ const Word16 *last_bitalloc,
+ const Word16 input_frame );
+
+#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_ivas_fx(
+ Encoder_State *st, /* i/o: state structure */
+ Encoder_Struct *st_ivas, /* i/o: encoder state structure */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */
+ const Word16 interval_SID, /* i : interval for SID update */
+ const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */
+ const ISM_MODE ism_mode, /* i : ISM mode */
+ const Word32 element_brate /* i : element bitrate */
+);
+
+ivas_error acelp_core_enc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 inp[], /* i : input signal of the current frame Q_new*/
+ Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/
+ Word16 *q_old_syn_12k8_16,
+ Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits Q0*/
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
+ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
+ Word16 Q_new );
+
+void flip_and_downmix_generic_fx32(
+ Word32 input[], /* i : input spectrum Qx*/
+ Word32 output[], /* o : output spectrum Qx*/
+ const Word16 length, /* i : length of spectra */
+ Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/
+ Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
+ Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
+ Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
+);
+
+Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */
+ const Word16 pos1, /* i: position of the pulse 1 */
+ const Word16 pos2, /* i: position of the pulse 2 */
+ const Word16 N /* i: number of bits FOR position */
+);
+
+void bands_and_bit_alloc_ivas_fx(
+ const Word16 cor_strong_limit, /* i : HF correlation */
+ const Word16 noise_lev, /* i : dwn scaling factor */
+ const Word32 core_brate, /* i : core bit rate */
+ const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
+ const Word16 bits_used, /* i : Number of bit used before frequency Q */
+ Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
+ const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */
+ Word16 *max_ener_band, /* o : Sorted order */
+ Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */
+ Word16 *nb_subbands, /* o : Number of subband allowed */
+ const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */
+ Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
+ Word16 *pvq_len, /* o : Number of bin covered with the PVQ */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */
+ const Word16 L_frame, /* i : frame length */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
+);
+
+void ivas_find_wsp_fx(
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ const Word16 nb_subfr, /* i : number of subframes Q0*/
+ const Word16 *A_fx,
+ /* i : A(z) filter coefficients */ // Q12
+ Word16 *Aw_fx,
+ /* o : weighted A(z) filter coefficients */ // Q12
+ const Word16 *speech_fx,
+ /* i : pointer to the denoised speech frame */ // Q_new
+ const Word16 tilt_fact,
+ /* i : tilt factor */ // Q15
+ Word16 *wsp_fx,
+ /* o : poitnter to the weighted speech frame */ // Q_new
+ Word16 *mem_wsp_fx,
+ /* i/o: W(Z) denominator memory */ // Q_new
+ const Word16 gamma,
+ /* i : weighting factor */ // Q15
+ const Word16 L_look /* i : look-ahead Q0*/
+);
+
+Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ const Word16 target, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem );
+
+Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
+ Word16 *x, /* Q0 */
+ const Word16 start_line, /* Q0 */
+ const Word16 end_line, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */
+);
+
+
+/*! r: Q15 */
+Word16 expfp_evs_fx(
+ const Word16 x, /* i : mantissa Q15-e */
+ const Word16 x_e /* i : exponent Q0 */
+);
+
+
+void tcx_arith_render_envelope_ivas_fx(
+ const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/
+ const Word16 L_frame, /* i : number of spectral lines Q0*/
+ const Word16 L_spec, /* i : length of the coded spectrum Q0*/
+ const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/
+ const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/
+ const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/
+ Word32 env[] /* o : shaped signal envelope Q16*/
+);
+
+void tcx_arith_decode_envelope_ivas_fx(
+ Decoder_State *st, /* i/o: coder state */
+ Word32 q_spectrum[], /* o : quantised MDCT coefficients */
+ Word16 *q_spectrum_e, /* o : MDCT exponent */
+ const Word16 L_frame, /* i : frame or MDCT length */
+ Word16 L_spec, /* i : length w/o BW limitation */
+ const Word16 A_ind[], /* i : quantised LPC coefficients */
+ const Word16 target_bits, /* i : number of available bits */
+ Word16 prm[], /* i : bitstream parameters */
+ const Word16 use_hm, /* i : use HM in current frame? */
+ const Word16 prm_hm[], /* i : HM parameter area */
+ Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
+ Word16 *arith_bits, /* o : bits used for ari. coding */
+ Word16 *signaling_bits, /* o : bits used for signaling */
+ const Word16 low_complexity /* i : low-complexity flag */
+);
+
+
+void UnmapIndex_fx(
+ const Word16 PeriodicityIndex, /* Q0 */
+ const Word16 Bandwidth, /* Q0 */
+ const Word16 LtpPitchLag, /* Q0 */
+ const Word8 SmallerLags, /* Q0 */
+ Word16 *FractionalResolution, /* Q0 */
+ Word32 *Lag /* Q0 */
+);
+
+#define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution )
+#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
+
+
+Word32 tcx_hm_render_fx(
+ const Word32 lag, /* i: pitch lag Q0 */
+ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */
+ Word16 p[] /* o: harmonic model Q13 */
+);
+
+
+void tcx_hm_modify_envelope_fx(
+ const Word16 gain, /* i: HM gain Q11 */
+ const Word32 lag, /* i: pitch lag Q0 */
+ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */
+ const Word16 p[], /* i: harmonic model Q13 */
+ Word32 env[], /* i/o: envelope Q16 */
+ const Word16 L_frame /* i: number of spectral lines Q0 */
+);
+
+void tcx_hm_decode(
+ const Word16 L_frame, /* i : number of spectral lines */
+ Word32 env[], /* i/o: envelope shape (Q16) */
+ const Word16 targetBits, /* i : target bit budget */
+ const Word16 coder_type, /* i : GC/VC coder type */
+ const Word16 prm_hm[], /* i : HM parameters */
+ const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */
+ Word16 *hm_bits /* o : bit consumption */
+);
+
+void writeTCXMode_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ Word16 *nbits_start /* o : nbits start Q0*/
+);
+
+void writeTCXWindowing_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 overlap_mode /* i : overlap mode Q0*/
+);
+
+void writeLPCparam(
+ Encoder_State *st, /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const int16_t param_lpc[], /* i : LPC parameters to write */
+ const int16_t bits_param_lpc[], /* i : bits per LPC parameter */
+ const int16_t no_param_lpc, /* i : number of LPC parameters */
+ int16_t *nbits_lpc /* o : LPC bits written */
+);
+
+void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
+void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
+void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue );
+void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value );
+
+int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+
+int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+
+int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+
+int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index );
+
+int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index );
+int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+
+void ResetTnsData_flt(
+ STnsData *pTnsData );
+
+void ClearTnsFilterCoefficients_flt(
+ STnsFilter *pTnsFilter );
+
+void EncodeTnsData(
+ STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
+ STnsData const *pTnsData, /* i : TNS data struct (quantized param) */
+ Word16 *stream, /* o : internal data stream */
+ Word16 *pnSize, /* o : number of written parameters */
+ Word16 *pnBits /* o : number of written bits */
+);
+
+Word16 DecodeTnsData_ivas(
+ STnsConfig const *pTnsConfig,
+ const Word16 *stream,
+ Word16 *pnSize,
+ STnsData *pTnsData );
+
+void WriteTnsData(
+ const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
+ const Word16 *stream, /* i : internal data stream */
+ Word16 *pnSize, /* o : number of written parameters */
+ BSTR_ENC_HANDLE hBstr, /* o : bitstream */
+ Word16 *pnBits /* o : number of written bits */
+);
+
+void ReadTnsData_ivas(
+ STnsConfig const *pTnsConfig,
+ Decoder_State *st,
+ Word16 *pnBits,
+ Word16 *stream,
+ Word16 *pnSize );
+
+void analysisCldfbEncoder_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word32 *timeIn, /*q11*/
+ Word16 timeInq, /*q0*/
+ Word16 samplesToProcess, /*q0*/
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 *ppBuf_Ener,
+ Word16 *enerBuffSum_exp,
+ CLDFB_SCALE_FACTOR *scale );
+
+ivas_error openCldfb_ivas(
+ HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
+ CLDFB_TYPE type, /* i : analysis or synthesis */
+ const int32_t sampling_rate, /* i : sampling rate */
+ CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
+);
+
+void resampleCldfb_ivas(
+ HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
+ const Word32 newSamplerate /* i : new samplerate to operate */
+);
+
+ivas_error cldfb_save_memory_ivas(
+ HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
+);
+
+/*! r: flag indicating a valid bitrate */
+Word16 is_EVS_bitrate(
+ const Word32 ivas_total_brate, /* i : EVS total bitrate */
+ Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */
+);
+
+void IGFEncResetTCX10BitCounter_ivas_fx(
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */
+);
+
+ivas_error IGF_Reconfig(
+ IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */
+ const Word16 igf, /* i : IGF on/off */
+ const Word16 reset, /* i : reset flag */
+ const Word32 brate, /* i : bitrate for configuration */
+ const Word16 bwidth, /* i : signal bandwidth */
+ const Word16 element_mode, /* i : IVAS element mode */
+ const Word16 rf_mode /* i : flag to signal the RF mode */
+);
+
+void ordr_esti(
+ const Word16 k, /* i : sub-vector index */
+ Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */
+ Word16 svOrder[], /* i/o: AVQ sub-vector order */
+ const Word16 Nsv /* i : total sub-vectors in a sub-frames */
+);
+
+/*===========================================================================================*/
+#endif
diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c
index ed914f2a159085a0359e1951557f5ff2ffb59e4b..479bc04d9c357ca0101de7e154b903b3e4d75924 100644
--- a/lib_com/pvq_com_fx.c
+++ b/lib_com/pvq_com_fx.c
@@ -4,7 +4,6 @@
#include
#include "options.h" /* Compilation switches */
#include "prot_fx.h" /* Function prototypes */
-#include "prot.h" /* Function prototypes */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c
index 665dbfae622164864d8dd41dce80d9254ed1c263..32d18d1feb543401666d751fb554240dce4e8e6f 100644
--- a/lib_com/residu_fx.c
+++ b/lib_com/residu_fx.c
@@ -7,7 +7,6 @@
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h"
-#include "prot.h"
/*--------------------------------------------------------------------*
* residu_ivas_fx()
diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c
index c3bfc6eeffc8ee1ce4bb05c6256255ed8659bdb8..eb79cc02648c67df6dbd075f3da2a9704142e2f8 100644
--- a/lib_com/rom_basop_util.c
+++ b/lib_com/rom_basop_util.c
@@ -1449,7 +1449,7 @@ void BASOP_getTables( const PWord16 **ptwiddle /*Q15*/, const PWord16 **sin_twid
ld2_length = sub( 16 - 1 - 1, norm_s( length ) );
/* Extract sort of "eigenvalue" (the 5 left most bits) of length. */
- SWITCH( (unsigned short) L_shl( length, sub( 15, ld2_length ) ) )
+ SWITCH( (UWord16) L_shl( length, sub( 15, ld2_length ) ) )
{
case 0xa000: /* 640 */
move16();
diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c
index bad47f0659a392b758428ff3284aad3228dee9d8..a5c8a3b7c65d8747e20b83f4afa8205438fe54ac 100644
--- a/lib_com/rom_com.c
+++ b/lib_com/rom_com.c
@@ -38,10 +38,9 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
/* clang-format off */
@@ -1770,35 +1769,35 @@ static const Word16 filter_LP30_300K_fx[LFE_PLC_FDEL + 1] =
const Resampling_cfg resampling_cfg_tbl[] =
{
/* fin fout up.fact. den.fac. len.out filter coefs. filter length/2 filter mem./2 flags */
- { 8000, 8000, 12800, 12800, 8, 8, 5, 256, /*filter5_39s320_120,*/ filter5_39s320_120_fx, 15, 15, RS_INV_FAC, RS_INV_FAC },
- { 12800, 12800, 8000, 8000, 5, 5, 8, 160, /*filter5_39s320_120,*/ filter5_39s320_120_fx, L_FILT_UP8k, L_FILT_UP8k, RS_INV_FAC, RS_INV_FAC },
- { 16000, 16000, 8000, 8000, 6, 6, 12, 160, /*filter_LP12_180H,*/ filter_LP12_180H_fx, 180 / 6, 180 / 6, 0, 0 },
- { 12800, 12800, 16000, 16000, 15, 15, 12, 320, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP16k, L_FILT_UP16k, 0, 0 },
- { 12800, 12800, 32000, 32000, 15, 15, 6, 640, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP32k, L_FILT_UP32k, 0, 0 },
- { 12800, 12800, 48000, 48000, 15, 15, 4, 960, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP48k, L_FILT_UP48k, 0, 0 },
+ { 8000, 12800, 8, 5, 256, /*filter5_39s320_120,*/ filter5_39s320_120_fx, 15, RS_INV_FAC },
+ { 12800, 8000, 5, 8, 160, /*filter5_39s320_120,*/ filter5_39s320_120_fx, L_FILT_UP8k, RS_INV_FAC },
+ { 16000, 8000, 6, 12, 160, /*filter_LP12_180H,*/ filter_LP12_180H_fx, 180 / 6, 0 },
+ { 12800, 16000, 15, 12, 320, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP16k, 0 },
+ { 12800, 32000, 15, 6, 640, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP32k, 0 },
+ { 12800, 48000, 15, 4, 960, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP48k, 0 },
- { 16000, 16000, 12800, 12800, 12, 12, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT16k, L_FILT16k, 0, 0 },
- { 16000, 16000, 32000, 32000, 12, 12, 6, 640, /*filter_LP12_180H, */ filter_LP12_180H_fx, L_FILT16k, L_FILT16k, 0, 0 },
- { 16000, 16000, 48000, 48000, 12, 12, 4, 960, /*filter_LP12_180H,*/ filter_LP12_180H_fx, L_FILT16k, L_FILT16k, 0, 0 },
-
- { 32000, 32000, 12800, 12800, 6, 6, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 },
- { 32000, 32000, 16000, 16000, 6, 6, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 },
- { 32000, 32000, 25600, 25600, 12, 12, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 },
- { 32000, 32000, 48000, 48000, 3, 3, 2, 960, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT32k, L_FILT32k, 0, 0 },
-
- { 48000, 48000, 12800, 12800, 4, 4, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 },
- { 48000, 48000, 16000, 16000, 4, 4, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 },
- { 48000, 48000, 25600, 25600, 8, 8, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 },
- { 48000, 48000, 32000, 32000, 2, 2, 3, 640, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT48k, L_FILT48k, 0, 0 },
+ { 16000, 12800, 12, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT16k, 0, },
+ { 16000, 32000, 12, 6, 640, /*filter_LP12_180H, */ filter_LP12_180H_fx, L_FILT16k, 0, },
+ { 16000, 48000, 12, 4, 960, /*filter_LP12_180H,*/ filter_LP12_180H_fx, L_FILT16k, 0, },
+
+ { 32000, 12800, 6, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT32k, 0, },
+ { 32000, 16000, 6, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT32k, 0, },
+ { 32000, 25600, 12, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT32k, 0, },
+ { 32000, 48000, 3, 2, 960, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT32k, 0, },
+
+ { 48000, 12800, 4, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT48k, 0, },
+ { 48000, 16000, 4, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT48k, 0, },
+ { 48000, 25600, 8, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT48k, 0, },
+ { 48000, 32000, 2, 3, 640, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT48k, 0, },
/* configs with NB 4kHz low-pass */
- { 16000, 16000, 12800, 12800, 12, 12, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_fx, L_FILT16k, L_FILT16k, 0, 0 },
- { 32000, 32000, 12800, 12800, 6, 6, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 },
- { 48000, 48000, 12800, 12800, 4, 4, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 },
+ { 16000, 12800, 12, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_fx, L_FILT16k, 0, },
+ { 32000, 12800, 6, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT32k, 0, },
+ { 48000, 12800, 4, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT48k, 0, },
/* entry for LFE PLC */
- { 1600, 1600, 48000, 48000, 30, 30, 1, 960, /*filter_LP30_300K,*/ filter_LP30_300K_fx, LFE_PLC_FDEL/30,LFE_PLC_FDEL / 30, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, /* 0, */ 0, 0, 0, 0, 0 } /* trailing entry (just to calculate the length of this table) */
+ { 1600, 48000, 30, 1, 960, /*filter_LP30_300K,*/ filter_LP30_300K_fx, LFE_PLC_FDEL / 30, 0, },
+ { 0, 0, 0, 0, 0, /* 0, */ 0, 0, 0, } /* trailing entry (just to calculate the length of this table) */
};
//den fac value for last entry is calculated as den.fac = (num.fac*fin)/fout
@@ -16791,7 +16790,6 @@ const Word16 GSC_freq_bits[] =
26, 96, 0, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_22k60*/
26, 96, 0, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4 /* ACELP_24k40*/
}; // Q0
-#ifdef MOD_BIT_ALLOC_ROM_TABLE
const Word32 GSC_freq_bits_fx[] =/*Q18*/
{
5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_5k00*/
@@ -16824,17 +16822,6 @@ const Word32 GSC_freq_bits_fx_Q18[] =/*Q18*/
6815744, 25165824, 0, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576,
6815744, 25165824, 0, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576,
};
-#else
-const Word32 GSC_freq_bits_fx[] =
-{
- 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_7k20*/
- 5505024, 19660800, -1048576, 6815744, 4194304, 3145728, 2883584, 2359296, 0, 0, 1048576, 1048576, 262144, 262144, 786432, 0, 0, /* ACELP_8k00*/
- 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_11k60*/
- 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k15*/
- 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k85*/
- 8126464, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_13k20*/
-};
-#endif
const Word16 Compl_GSC_freq_bits[] =
{
5, 10, 10, 10 /* bitrate > ACELP_16k40 && FS = 16kHz */
@@ -22051,27 +22038,8 @@ const Word32 sigma_BWE_fx[] = {//Q31
40792208 }; /* for 3 bits first stage */
-const Word16 inv_modified_sigma_BWE_fx[] = {//Q1
- 259,
-254,
-267,
-266,
-293,
-315,
-598,
-622,
-288,
-288,
-297,
-297,
-319,
-346,
-598,
-622
-};
-
-const Word16 modified_sigma_BWE_fx[] =//Q(log2(2.56)
-{ 323,
+const Word16 inv_modified_sigma_BWE_fx[] = {//x2.56
+323,
329,
313,
314,
@@ -22086,8 +22054,27 @@ const Word16 modified_sigma_BWE_fx[] =//Q(log2(2.56)
262,
242,
140,
-134 };
+134
+};
+const Word16 modified_sigma_BWE_fx[] =//Q15
+{ 259,
+254,
+267,
+266,
+293,
+315,
+598,
+622,
+288,
+288,
+297,
+297,
+319,
+346,
+598,
+622 };
+
const Word16 SHB_LSF_mean_fx[10] = {//Q15
1353, 2646, 4046,
@@ -25352,6 +25339,21 @@ const Word16 lsp_shb_prev_tbl_fx[LPC_SHB_ORDER] = {
13107,
14746
};
+
+const Word16 lsp_shb_prev_tbl_swb_tbe_enc_fx[LPC_SHB_ORDER] = {
+ // Q15
+ 32767,
+ 31165,
+ 26509,
+ 19262,
+ 10123,
+ 0,
+ -10124,
+ -19261,
+ -26509,
+ -31166,
+};
+
const Word16 ivas_lsp_shb_prev_tbl_fx[LPC_SHB_ORDER] = {
/* Q15 */
1489,
diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h
index 274a33a18488656590d251aa30ca64854eba9a31..73156b9892df5be8df2ea273d450acaf492e1fdc 100644
--- a/lib_com/rom_com.h
+++ b/lib_com/rom_com.h
@@ -49,13 +49,8 @@
#define INTERP_EXP 0
typedef struct
{
- Word32 fin; /* input frequency */
- Word32 fin_fx; /* input frequency Q0 */
-
- Word32 fout; /* output frequency */
- Word32 fout_fx; /* output frequency Q0 */
-
- Word16 fac_num; /* numerator of resampling factor */
+ Word32 fin_fx; /* input frequency Q0 */
+ Word32 fout_fx; /* output frequency Q0 */
Word16 fac_num_fx; /* numerator of resampling factor Q0 */
Word16 fac_den_fx; /* denominator of resampling factor Q0 */
@@ -63,12 +58,9 @@ typedef struct
const Word16 *filter_fx; /* resampling filter coefficients Q14 */
- Word16 filt_len; /* number of filter coeff. */
Word16 filt_len_fx; /* number of filter coeff. Q0 */
-
- uint16_t flags; /* flags from config. table */
- UWord16 flags_fx; /* flags from config. table Q0 */
- // UNS_Word16 flags_fx; /* flags from config. table Q0 */
+ UWord16 flags_fx; /* flags from config. table Q0 */
+ // UNS_Word16 flags_fx; /* flags from config. table Q0 */
} Resampling_cfg;
@@ -1512,15 +1504,16 @@ extern const Word16 tab_hup_l_fx[]; // Q15
extern const Word16 mfreq_loc_Q2fx[]; // Q0
extern const Word16 mfreq_loc_div_25[]; // Q0
-extern const Word16 band_len_idx[]; // Q0
-extern const Word16 band_len_ener_shift[]; // Q0
-extern const Word16 fine_gain_pred_sqrt_bw[]; // Q11
-extern const Word16 ivas_band_len_idx[]; // Q0
-extern const Word16 ivas_band_len_ener_shift[]; // Q0
-extern const Word16 ivas_fine_gain_pred_sqrt_bw[]; // Q11
-extern const Word16 Mean_isf_wb[]; // Q2.56
-extern const Word16 lsp_shb_prev_tbl_fx[]; // Q15
-extern const Word16 ivas_lsp_shb_prev_tbl_fx[]; // Q15
+extern const Word16 band_len_idx[]; // Q0
+extern const Word16 band_len_ener_shift[]; // Q0
+extern const Word16 fine_gain_pred_sqrt_bw[]; // Q11
+extern const Word16 ivas_band_len_idx[]; // Q0
+extern const Word16 ivas_band_len_ener_shift[]; // Q0
+extern const Word16 ivas_fine_gain_pred_sqrt_bw[]; // Q11
+extern const Word16 Mean_isf_wb[]; // Q2.56
+extern const Word16 lsp_shb_prev_tbl_fx[]; // Q15
+extern const Word16 lsp_shb_prev_tbl_swb_tbe_enc_fx[]; // Q15
+extern const Word16 ivas_lsp_shb_prev_tbl_fx[]; // Q15
extern const Word16 tab_ari_qnew[4][4];
// enhancer.c
diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c
index 6116588846bb66eca53cc1f41ed7ef8870094cd3..49f50e1622ba4a26b851bc236695c6e4b472078d 100644
--- a/lib_com/rom_com_fx.c
+++ b/lib_com/rom_com_fx.c
@@ -38,7 +38,7 @@
EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
====================================================================================*/
-#include "prot.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "wmc_auto.h"
#include "rom_com_fx.h"
diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c
index 0028210502634f7a8a5c8d0acfa27686bcc81435..2ce2ffd12b8aad3cf41c48a53bfb7c253b1ee80b 100644
--- a/lib_com/scale_mem_fx.c
+++ b/lib_com/scale_mem_fx.c
@@ -307,8 +307,15 @@ void scale_sig32(
/* saturation can occur here */
x[i] = L_shl( x[i], exp0 );
move32();
+#ifdef OPT_STEREO_32KBPS_V1
+ if ( 0 == exp0 )
+ {
+ i = lg;
+ }
+#endif /* OPT_STEREO_32KBPS_V1 */
}
}
+
void scale_sig32_r(
Word32 x[], /* i/o: signal to scale Qx */
const Word16 lg, /* i : size of x[] Q0 */
@@ -322,6 +329,12 @@ void scale_sig32_r(
/* saturation can occur here */
x[i] = L_shl_r( x[i], exp0 );
move32();
+#ifdef OPT_STEREO_32KBPS_V1
+ if ( 0 == exp0 )
+ {
+ i = lg;
+ }
+#endif /* OPT_STEREO_32KBPS_V1 */
}
}
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index 2340c7a75f4797a0507d17ad5177e5f8c12c1f39..f99d498027a98db71cfbed521e46712659506917 100644
--- a/lib_com/stat_com.h
+++ b/lib_com/stat_com.h
@@ -74,7 +74,7 @@ typedef struct
typedef struct
{
Word16 lead_sign_ind;
- uint32_t index, size;
+ UWord32 index, size;
Word16 dim, k_val;
} PvqEntry;
@@ -197,6 +197,8 @@ typedef struct TNS_filter_structure
Word16 order; /* Filter order. */
Word16 coefIndex[TNS_MAX_FILTER_ORDER]; /* Quantized filter coefficients. */
Word16 predictionGain; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q7 */
+ Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. predictionGain_e */
+ Word16 predictionGain_e; /*Exponent for predictionGain32 */
Word16 avgSqrCoef; /* Average squared filter coefficient. E(0), Q15 */
} STnsFilter;
@@ -311,7 +313,7 @@ typedef struct
{
Word32 low;
Word32 high;
- uint32_t value;
+ UWord32 value;
Word32 bits_to_follow;
} Tastat;
typedef struct
@@ -488,15 +490,6 @@ typedef Word16 ( *TEncodeValue )( Word16 value, Word16 index );
*/
typedef Word16 ( *TDecodeValue )( struct Decoder_State *st, Word16 index, Word16 *pValue );
-/** Linear prediction analysis/synthesis filter definition.
- * @param order filter order.
- * @param parCoeff filter (PARCOR) coefficients.
- * @param state state of the filter. Must be at least of 'order' size.
- * @param x the current input value.
- * @return the output of the filter.
- */
-typedef float ( *TLinearPredictionFilter_flt )( const int16_t order, const float parCoeff[], float *state, float x );
-
/** Structure that defines mapping between a parameter and a bitstream. */
typedef struct ParamBitMap
{
@@ -700,21 +693,6 @@ typedef enum
/*---------------------------------------------------------------*
* IGF *
*---------------------------------------------------------------*/
-/*----------------------------------------------------------------------------------*
- * NB postfilter / formant postfilter static variables
- *----------------------------------------------------------------------------------*/
-typedef struct pfstat_structure
-{
- Word16 on; /* On/off flag */
- Word16 reset; /* reset flag */
- Word16 mem_pf_in[L_SUBFR]; /* Input memory Qqmem_pf_in */
- Word16 mem_stp[L_SUBFR]; /* 1/A(gamma1) memory Qqmem_stp*/
- Word16 mem_res2[DECMEM_RES2]; /* A(gamma2) residual Q_syn*/
- Word16 mem_zero[M]; /* null memory to compute i.r. of A(gamma2)/A(gamma1) Q_qmem_zero*/
- Word16 gain_prec; /*Q14*/ /* for gain adjustment */
-
-} PFSTAT, *PFSTAT_HANDLE;
-
typedef struct
{
diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c
index eda099cd93a4d2bf25843d1e4db24e9c4b98ba47..11da78c46f06cf04a6895050c706e53824225711 100644
--- a/lib_com/swb_bwe_com_fx.c
+++ b/lib_com/swb_bwe_com_fx.c
@@ -2533,12 +2533,8 @@ void hq_generic_decoding_fx(
IF( L_tmp != 0 )
{
exp = norm_l( L_tmp );
-#ifdef EVS_FUNC_MODIFIED
frac = round_fx_sat( L_shl( L_tmp, exp ) ); /*cs+exp-16 */
-#else
- frac = round_fx( L_shl( L_tmp, exp ) ); /*cs+exp-16 */
-#endif
- tmp = div_s( 16384, frac ); /*15 + 14 - (cs+exp-16) */
+ tmp = div_s( 16384, frac ); /*15 + 14 - (cs+exp-16) */
exp = sub( add( cs, exp ), 30 );
L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /*Q31 - exp */
fenvL_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /*Q1 */
@@ -2868,11 +2864,7 @@ void hq_generic_decoding_fx(
tmp4_fx = mult_r( tmp3_fx, 1638 /* 0.05 in Q15 */ );
WHILE( tmp3_fx > 1024 /* 1 in Q10*/ )
{
-#ifdef EVS_FUNC_MODIFIED
L_tmp1 = L_shl( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */
-#else
- L_tmp1 = Mult_32_16( L_shl( *pit1_fx, 5 ), tmp3_fx ); /*15 + 5 + 10 -15 */
-#endif
*pit1_fx-- = L_tmp1;
move32();
tmp3_fx = sub( tmp3_fx, tmp4_fx );
@@ -3089,12 +3081,8 @@ void hq_generic_decoding_ivas_fx(
IF( L_tmp != 0 )
{
exp = norm_l( L_tmp );
-#ifdef EVS_FUNC_MODIFIED
frac = round_fx_sat( L_shl( L_tmp, exp ) ); /*cs+exp-16 */
-#else
- frac = round_fx( L_shl( L_tmp, exp ) ); /*cs+exp-16 */
-#endif
- tmp = div_s( 16384, frac ); /*15 + 14 - (cs+exp-16) */
+ tmp = div_s( 16384, frac ); /*15 + 14 - (cs+exp-16) */
exp = sub( add( cs, exp ), 30 );
L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /*Q31 - exp */
fenvL_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /*Q1 */
@@ -3424,11 +3412,7 @@ void hq_generic_decoding_ivas_fx(
tmp4_fx = mult_r( tmp3_fx, 1638 /* 0.05 in Q15 */ );
WHILE( tmp3_fx > 1024 /* 1 in Q10*/ )
{
-#ifdef EVS_FUNC_MODIFIED
L_tmp1 = L_shl( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */
-#else
- L_tmp1 = Mult_32_16( L_shl( *pit1_fx, 5 ), tmp3_fx ); /*15 + 5 + 10 -15 */
-#endif
*pit1_fx-- = L_tmp1;
move32();
tmp3_fx = sub( tmp3_fx, tmp4_fx );
diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c
index d0b8d010022f45d3a388d47b8e799c5d288b7983..8fd876f1cb9d6dd008231fd5bc074ec58e0612da 100644
--- a/lib_com/swb_bwe_com_lr_fx.c
+++ b/lib_com/swb_bwe_com_lr_fx.c
@@ -2366,11 +2366,7 @@ void ton_ene_est_fx(
exp_normn = norm_s( peak_fx[k] );
fac_fx = div_s( shl( temp2_fx, exp_normd ), shl( peak_fx[k], exp_normn ) );
-#ifdef FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX
fac_fx = shl_sat( fac_fx, sub( add( Qss, exp_normn ), add( Qtemp2, exp_normd ) ) ); /* Qtemp2+exp_normd-(Qss+exp_normn)+15 -> 15*/
-#else
- fac_fx = shl( fac_fx, sub( add( Qss, exp_normn ), add( Qtemp2, exp_normd ) ) ); /* Qtemp2+exp_normd-(Qss+exp_normn)+15 -> 15*/
-#endif
}
ni_gain_fx[k] = mult_r( avg_pe_fx[k], fac_fx ); /* Qavg_pe[k] */
diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c
deleted file mode 100644
index 2aa781a43d661d9fe53b5f244aaf56229a056078..0000000000000000000000000000000000000000
--- a/lib_com/swb_tbe_com.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "prot_fx.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h"
-#include
-
-
-/*-----------------------------------------------------------------*
- * Local function prototypes
- *-----------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------*
- * flip_spectrum_and_decimby4()
- *
- *
- *-------------------------------------------------------------------*/
-
-
-void GenSHBSynth_fx_32(
- const Word32 *input_synspeech, /* i : input synthesized speech Qx*/
- Word32 *shb_syn_speech_32k, /* o : output highband component Qx*/
- Word32 Hilbert_Mem[], /* i/o: memory Qx*/
- Word32 state_lsyn_filt_shb_local[], /* i/o: memory Qx*/
- const Word16 L_frame, /* i : ACELP frame length */
- Word16 *syn_dm_phase )
-{
- Word32 speech_buf_32k[L_FRAME32k];
- Word16 i;
-
-#ifdef FIX_881_HILBERT_FILTER
- Word16 shift = 0;
- Word32 maxm32, input_synspeech_temp[L_FRAME16k];
- move16();
-
- /* find the maximum value and derive the shift to improve precision of the Hilber filter */
- maxm32 = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME16k; i++ )
- {
- maxm32 = L_max( maxm32, L_abs( input_synspeech[i] ) );
- }
-
- FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
- {
- maxm32 = L_max( maxm32, L_abs( state_lsyn_filt_shb_local[i] ) );
- }
-
- FOR( i = 0; i < HILBERT_MEM_SIZE; i++ )
- {
- maxm32 = L_max( maxm32, L_abs( Hilbert_Mem[i] ) );
- }
-
- IF( maxm32 != 0 )
- {
- shift = sub( norm_l( maxm32 ), 3 );
-
- Copy_Scale_sig32( input_synspeech, input_synspeech_temp, L_FRAME16k, shift );
- Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, shift );
- Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, shift );
- }
- ELSE
- {
- Copy32( input_synspeech, input_synspeech_temp, L_FRAME16k );
- }
-
- Interpolate_allpass_steep_32( input_synspeech_temp, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k );
-#else
- Interpolate_allpass_steep_32( input_synspeech, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k );
-#endif
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- flip_and_downmix_generic_fx_32( speech_buf_32k, shb_syn_speech_32k, L_FRAME32k, Hilbert_Mem, Hilbert_Mem + HILBERT_ORDER1, Hilbert_Mem + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), syn_dm_phase );
- }
- ELSE
- {
- FOR( i = 0; i < L_FRAME32k; i++ )
- {
- // shb_syn_speech_32k[i] = ( ( i % 2 ) == 0 ) ? ( -speech_buf_32k[i] ) : ( speech_buf_32k[i] );
- IF( i % 2 == 0 )
- {
- shb_syn_speech_32k[i] = L_negate( speech_buf_32k[i] ); // Qx
- }
- ELSE
- {
- shb_syn_speech_32k[i] = speech_buf_32k[i]; // Qx
- }
- move32();
- }
- }
-
-#ifdef FIX_881_HILBERT_FILTER
- IF( maxm32 != 0 )
- {
- Scale_sig32( shb_syn_speech_32k, L_FRAME32k, negate( shift ) );
- Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, negate( shift ) );
- Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, negate( shift ) );
- }
-#endif
-
- return;
-}
-void ScaleShapedSHB_32(
- const Word16 length, /* i : SHB overlap length */
- Word32 *synSHB_fx, /* i/o: synthesized shb signal Q_inp/Q_new */
- Word32 *overlap_fx, /* i/o: buffer for overlap-add Q_inp/Q_new */
- const Word16 *subgain_fx, /* i : subframe gain Q15 */
- const Word32 frame_gain_fx, /* i : frame gain Q18*/
- const Word16 *win_fx, /* i : window Q15 */
- const Word16 *subwin_fx, /* i : subframes window Q15 */
- Word16 *Q_inp,
- Word16 *Q_new )
-{
- const Word16 *skip;
- Word16 i, j, k, l_shb_lahead, l_frame;
- Word16 join_length, num_join;
- Word32 mod_syn_fx[L_FRAME16k + L_SHB_LAHEAD], L_tmp;
- Word16 sum_gain_fx;
-
- /* initilaization */
- l_frame = L_FRAME16k;
- l_shb_lahead = L_SHB_LAHEAD;
- move16();
- move16();
- skip = skip_bands_SWB_TBE;
-
- IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) )
- {
- skip = skip_bands_WB_TBE;
- l_frame = L_FRAME16k / 4;
- l_shb_lahead = L_SHB_LAHEAD / 4;
- move16();
- move16();
- }
-
- /* apply gain for each subframe, and store noise output signal using overlap-add */
- set32_fx( mod_syn_fx, 0, l_frame + l_shb_lahead );
-
- IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) )
- {
- sum_gain_fx = 0;
- move16();
- FOR( k = 0; k < shr( length, 1 ); k++ )
- {
- sum_gain_fx = mult_r( subwin_fx[2 * k + 2], subgain_fx[0] );
- mod_syn_fx[skip[0] + k] = Mpy_32_16_1( synSHB_fx[skip[0] + k], sum_gain_fx );
- move32(); // Qx
- mod_syn_fx[skip[0] + k + length / 2] = Mpy_32_16_1( synSHB_fx[skip[0] + k + length / 2], subgain_fx[0] ); // Qx
- move32();
- }
- FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ )
- {
- FOR( k = 0; k < length; k++ )
- {
- L_tmp = L_mult0( subwin_fx[k + 1], subgain_fx[i] );
- sum_gain_fx = round_fx( L_mac0( L_tmp, subwin_fx[length - k - 1], subgain_fx[i - 1] ) );
- mod_syn_fx[skip[i] + k] = L_shl( Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ), 1 ); // Qx
- move32();
- }
- }
- FOR( k = 0; k < shr( length, 1 ); k++ )
- {
- sum_gain_fx = mult_r( subwin_fx[length - k * 2 - 2], subgain_fx[i - 1] );
- mod_syn_fx[skip[i] + k] = Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ); // Qx
- move32();
- }
- }
- ELSE
- {
- num_join = NUM_SHB_SUBFR / NUM_SHB_SUBGAINS;
- join_length = i_mult( num_join, length );
- j = 0;
- move16();
- move16();
- FOR( k = 0; k < length; k++ )
- {
- mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[k + 1], subgain_fx[0] ) ); // Qx
- move32();
- j = add( j, 1 );
- }
- FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ )
- {
- FOR( k = 0; k < join_length - length; k++ )
- {
- mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[i * num_join] ); // Qx
- move32();
- j = add( j, 1 );
- }
-
- FOR( k = 0; k < length; k++ )
- {
- L_tmp = L_mult0( subwin_fx[length - k - 1], subgain_fx[i * num_join] );
- mod_syn_fx[j] = L_shl( Mpy_32_16_1( synSHB_fx[j], round_fx( L_mac0( L_tmp, subwin_fx[k + 1], subgain_fx[( i + 1 ) * num_join] ) ) ), 1 ); // Qx
- move32();
- j = add( j, 1 );
- }
- }
- FOR( k = 0; k < join_length - length; k++ )
- {
- mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); // Qx
- move32();
- j = add( j, 1 );
- }
- FOR( k = 0; k < length; k++ )
- {
- mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[length - k - 1], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ) ); // Qx
- move32();
- j = add( j, 1 );
- }
- }
-
- Word16 norm_shift = norm_l( frame_gain_fx );
- if ( frame_gain_fx == 0 )
- {
- norm_shift = 31;
- move16();
- }
-
- norm_shift = s_min( norm_shift, 14 );
- norm_shift = sub( norm_shift, 1 );
-
- *Q_new = add( *Q_inp, sub( norm_shift, 13 ) ); // Q_new = Q_inp + min(norm_shift,14) - 14;
- move16();
- FOR( i = 0; i < L_SHB_LAHEAD; i++ )
- {
- overlap_fx[i] = L_shl( overlap_fx[i], sub( *Q_new, *Q_inp ) );
- move32();
- }
-
- FOR( i = 0; i < l_shb_lahead; i++ )
- {
- synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[i] ) ); // Q_new
- synSHB_fx[i] = L_add( synSHB_fx[i], overlap_fx[i] );
- synSHB_fx[i + l_shb_lahead] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new
- move32();
- move32();
- move32();
- }
-
- FOR( ; i < l_frame; i++ )
- {
- synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new
- move32();
- }
-
- FOR( ; i < l_frame + l_shb_lahead; i++ )
- {
- synSHB_fx[i] = L_shl( synSHB_fx[i], sub( *Q_new, *Q_inp ) );
- overlap_fx[i - l_frame] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[l_frame + l_shb_lahead - 1 - i] ) ); // Q_new
- move32();
- move32();
- }
-
- *Q_inp = *Q_new;
- move16();
- return;
-}
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index 6cdf1185ade75e8eeecc06865dbb904e990bcdbe..2a28419668d1d0eba33227b27b43af386fb9c2de 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -7,7 +7,6 @@
#include "options.h"
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot.h"
#include "prot_fx.h"
#include "basop_util.h"
#include "ivas_prot_fx.h"
@@ -73,7 +72,7 @@ void swb_tbe_reset_fx(
* Reset the extra parameters needed for synthesis of the SWB TBE output
*-------------------------------------------------------------------*/
-void swb_tbe_reset_synth_ivas_fx(
+void swb_tbe_reset_synth_fx(
Word32 genSHBsynth_Hilbert_Mem[],
Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[],
Word32 genSHBsynth_state_lsyn_filt_shb_local_fx_32[] )
@@ -81,17 +80,11 @@ void swb_tbe_reset_synth_ivas_fx(
set32_fx( genSHBsynth_Hilbert_Mem, 0, HILBERT_MEM_SIZE );
set16_fx( genSHBsynth_state_lsyn_filt_shb_local_fx, 0, 2 * ALLPASSSECTIONS_STEEP );
- set32_fx( genSHBsynth_state_lsyn_filt_shb_local_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP );
- return;
-}
-void swb_tbe_reset_synth_fx(
- Word32 genSHBsynth_Hilbert_Mem[],
- Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[] )
-{
-
- set32_fx( genSHBsynth_Hilbert_Mem, 0, HILBERT_MEM_SIZE );
- set16_fx( genSHBsynth_state_lsyn_filt_shb_local_fx, 0, 2 * ALLPASSSECTIONS_STEEP );
+ if ( genSHBsynth_state_lsyn_filt_shb_local_fx_32 != NULL )
+ {
+ set32_fx( genSHBsynth_state_lsyn_filt_shb_local_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP );
+ }
return;
}
@@ -487,10 +480,12 @@ void flip_and_downmix_generic_fx(
*phase_state = j;
move16();
+
return;
}
-void flip_and_downmix_generic_fx_32(
+
+void flip_and_downmix_generic_fx32(
Word32 input[], /* i : input spectrum Qx*/
Word32 output[], /* o : output spectrum Qx*/
const Word16 length, /* i : length of spectra */
@@ -1041,11 +1036,7 @@ static void filt_mu_fx(
FOR( n = 0; n < SubFrameLength; n++ )
{
temp = mult_r( mu, ( *ptrs++ ) );
-#ifdef FIX_ISSUE_1155
temp = add_sat( temp, *ptrs ); /*Q12 */
-#else
- temp = add( temp, *ptrs ); /*Q12 */
-#endif
sig_out[n] = shl_o( mult_r( ga, temp ), 1, &Overflow );
move16(); /*Q12 */
}
@@ -5080,6 +5071,86 @@ void GenSHBSynth_fx(
}
+/* IVAS 32-bit variant */
+void GenSHBSynth_fx32(
+ const Word32 *input_synspeech, /* i : input synthesized speech Qx*/
+ Word32 *shb_syn_speech_32k, /* o : output highband component Qx*/
+ Word32 Hilbert_Mem[], /* i/o: memory Qx*/
+ Word32 state_lsyn_filt_shb_local[], /* i/o: memory Qx*/
+ const Word16 L_frame, /* i : ACELP frame length */
+ Word16 *syn_dm_phase )
+{
+ Word32 speech_buf_32k[L_FRAME32k];
+ Word16 i;
+
+ Word16 shift = 0;
+ Word32 maxm32, input_synspeech_temp[L_FRAME16k];
+ move16();
+
+ /* find the maximum value and derive the shift to improve precision of the Hilber filter */
+ maxm32 = L_deposit_l( 0 );
+ FOR( i = 0; i < L_FRAME16k; i++ )
+ {
+ maxm32 = L_max( maxm32, L_abs( input_synspeech[i] ) );
+ }
+
+ FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
+ {
+ maxm32 = L_max( maxm32, L_abs( state_lsyn_filt_shb_local[i] ) );
+ }
+
+ FOR( i = 0; i < HILBERT_MEM_SIZE; i++ )
+ {
+ maxm32 = L_max( maxm32, L_abs( Hilbert_Mem[i] ) );
+ }
+
+ IF( maxm32 != 0 )
+ {
+ shift = sub( norm_l( maxm32 ), 3 );
+
+ Copy_Scale_sig32( input_synspeech, input_synspeech_temp, L_FRAME16k, shift );
+ Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, shift );
+ Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, shift );
+ }
+ ELSE
+ {
+ Copy32( input_synspeech, input_synspeech_temp, L_FRAME16k );
+ }
+
+ Interpolate_allpass_steep_fx32( input_synspeech_temp, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k );
+
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ flip_and_downmix_generic_fx32( speech_buf_32k, shb_syn_speech_32k, L_FRAME32k, Hilbert_Mem, Hilbert_Mem + HILBERT_ORDER1, Hilbert_Mem + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), syn_dm_phase );
+ }
+ ELSE
+ {
+ FOR( i = 0; i < L_FRAME32k; i++ )
+ {
+ // shb_syn_speech_32k[i] = ( ( i % 2 ) == 0 ) ? ( -speech_buf_32k[i] ) : ( speech_buf_32k[i] );
+ IF( i % 2 == 0 )
+ {
+ shb_syn_speech_32k[i] = L_negate( speech_buf_32k[i] ); // Qx
+ }
+ ELSE
+ {
+ shb_syn_speech_32k[i] = speech_buf_32k[i]; // Qx
+ }
+ move32();
+ }
+ }
+
+ IF( maxm32 != 0 )
+ {
+ Scale_sig32( shb_syn_speech_32k, L_FRAME32k, negate( shift ) );
+ Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, negate( shift ) );
+ Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, negate( shift ) );
+ }
+
+ return;
+}
+
+
/*==============================================================================*/
/* FUNCTION : void ScaleShapedSHB_fx() */
/*------------------------------------------------------------------------------*/
@@ -5301,6 +5372,165 @@ void ScaleShapedSHB_fx(
return;
}
+
+/* IVAS 32-bit variant */
+void ScaleShapedSHB_fx32(
+ const Word16 length, /* i : SHB overlap length */
+ Word32 *synSHB_fx, /* i/o: synthesized shb signal Q_inp/Q_new */
+ Word32 *overlap_fx, /* i/o: buffer for overlap-add Q_inp/Q_new */
+ const Word16 *subgain_fx, /* i : subframe gain Q15 */
+ const Word32 frame_gain_fx, /* i : frame gain Q18*/
+ const Word16 *win_fx, /* i : window Q15 */
+ const Word16 *subwin_fx, /* i : subframes window Q15 */
+ Word16 *Q_inp,
+ Word16 *Q_new )
+{
+ const Word16 *skip;
+ Word16 i, j, k, l_shb_lahead, l_frame;
+ Word16 join_length, num_join;
+ Word32 mod_syn_fx[L_FRAME16k + L_SHB_LAHEAD], L_tmp;
+ Word16 sum_gain_fx;
+
+ /* initilaization */
+ l_frame = L_FRAME16k;
+ l_shb_lahead = L_SHB_LAHEAD;
+ move16();
+ move16();
+ skip = skip_bands_SWB_TBE;
+
+ IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) )
+ {
+ skip = skip_bands_WB_TBE;
+ l_frame = L_FRAME16k / 4;
+ l_shb_lahead = L_SHB_LAHEAD / 4;
+ move16();
+ move16();
+ }
+
+ /* apply gain for each subframe, and store noise output signal using overlap-add */
+ set32_fx( mod_syn_fx, 0, l_frame + l_shb_lahead );
+
+ IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) )
+ {
+ sum_gain_fx = 0;
+ move16();
+ FOR( k = 0; k < shr( length, 1 ); k++ )
+ {
+ sum_gain_fx = mult_r( subwin_fx[2 * k + 2], subgain_fx[0] );
+ mod_syn_fx[skip[0] + k] = Mpy_32_16_1( synSHB_fx[skip[0] + k], sum_gain_fx );
+ move32(); // Qx
+ mod_syn_fx[skip[0] + k + length / 2] = Mpy_32_16_1( synSHB_fx[skip[0] + k + length / 2], subgain_fx[0] ); // Qx
+ move32();
+ }
+ FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ )
+ {
+ FOR( k = 0; k < length; k++ )
+ {
+ L_tmp = L_mult0( subwin_fx[k + 1], subgain_fx[i] );
+ sum_gain_fx = round_fx( L_mac0( L_tmp, subwin_fx[length - k - 1], subgain_fx[i - 1] ) );
+ mod_syn_fx[skip[i] + k] = L_shl( Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ), 1 ); // Qx
+ move32();
+ }
+ }
+ FOR( k = 0; k < shr( length, 1 ); k++ )
+ {
+ sum_gain_fx = mult_r( subwin_fx[length - k * 2 - 2], subgain_fx[i - 1] );
+ mod_syn_fx[skip[i] + k] = Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ); // Qx
+ move32();
+ }
+ }
+ ELSE
+ {
+ num_join = NUM_SHB_SUBFR / NUM_SHB_SUBGAINS;
+ join_length = i_mult( num_join, length );
+ j = 0;
+ move16();
+ move16();
+ FOR( k = 0; k < length; k++ )
+ {
+ mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[k + 1], subgain_fx[0] ) ); // Qx
+ move32();
+ j = add( j, 1 );
+ }
+ FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ )
+ {
+ FOR( k = 0; k < join_length - length; k++ )
+ {
+ mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[i * num_join] ); // Qx
+ move32();
+ j = add( j, 1 );
+ }
+
+ FOR( k = 0; k < length; k++ )
+ {
+ L_tmp = L_mult0( subwin_fx[length - k - 1], subgain_fx[i * num_join] );
+ mod_syn_fx[j] = L_shl( Mpy_32_16_1( synSHB_fx[j], round_fx( L_mac0( L_tmp, subwin_fx[k + 1], subgain_fx[( i + 1 ) * num_join] ) ) ), 1 ); // Qx
+ move32();
+ j = add( j, 1 );
+ }
+ }
+ FOR( k = 0; k < join_length - length; k++ )
+ {
+ mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); // Qx
+ move32();
+ j = add( j, 1 );
+ }
+ FOR( k = 0; k < length; k++ )
+ {
+ mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[length - k - 1], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ) ); // Qx
+ move32();
+ j = add( j, 1 );
+ }
+ }
+
+ Word16 norm_shift = norm_l( frame_gain_fx );
+ if ( frame_gain_fx == 0 )
+ {
+ norm_shift = 31;
+ move16();
+ }
+
+ norm_shift = s_min( norm_shift, 14 );
+ norm_shift = sub( norm_shift, 1 );
+
+ *Q_new = add( *Q_inp, sub( norm_shift, 13 ) ); // Q_new = Q_inp + min(norm_shift,14) - 14;
+ move16();
+ FOR( i = 0; i < L_SHB_LAHEAD; i++ )
+ {
+ overlap_fx[i] = L_shl( overlap_fx[i], sub( *Q_new, *Q_inp ) );
+ move32();
+ }
+
+ FOR( i = 0; i < l_shb_lahead; i++ )
+ {
+ synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[i] ) ); // Q_new
+ synSHB_fx[i] = L_add( synSHB_fx[i], overlap_fx[i] );
+ synSHB_fx[i + l_shb_lahead] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new
+ move32();
+ move32();
+ move32();
+ }
+
+ FOR( ; i < l_frame; i++ )
+ {
+ synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new
+ move32();
+ }
+
+ FOR( ; i < l_frame + l_shb_lahead; i++ )
+ {
+ synSHB_fx[i] = L_shl( synSHB_fx[i], sub( *Q_new, *Q_inp ) );
+ overlap_fx[i - l_frame] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[l_frame + l_shb_lahead - 1 - i] ) ); // Q_new
+ move32();
+ move32();
+ }
+
+ *Q_inp = *Q_new;
+ move16();
+ return;
+}
+
+
/*-------------------------------------------------------------------*
* ScaleShapedWB()
*
@@ -5316,15 +5546,11 @@ void ScaleShapedWB_fx(
const Word16 *win, /* i : window Q15*/
const Word16 *subwin, /* i : subframes window Q15*/
const Word16 Q_bwe_exc,
- Word16 L_frame /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
- ,
- Word16 dynQ /* i : indicate whether output is dynamic Q, or Q0 */
- ,
- Word16 *Qx /* o : newly computed Q factor for synSHB */
- ,
- Word16 prev_Qx /* i : prev_Qx for memory scaling */
- ,
- Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */
+ Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
+ Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */
+ Word16 *Qx, /* o : newly computed Q factor for synSHB */
+ Word16 prev_Qx, /* i : prev_Qx for memory scaling */
+ Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */
)
{
const Word16 *skip;
diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c
index 6e0f7e716fe0805021cb84d32f99f69cb7af69a0..ada0d243ea88b7c08fdb6ac8bd5d8720f9eb7f8f 100644
--- a/lib_com/syn_filt_fx.c
+++ b/lib_com/syn_filt_fx.c
@@ -213,14 +213,14 @@ void syn_filt_fx(
FOR( i = 0; i < l; i++ )
{
- s = L_mult( a0, x[i] );
+ s = L_mult( a0, x[i] ); // Qx + Qa - shift + 1
FOR( j = 1; j <= m; j++ )
{
- s = L_msu_sat( s, shr( a[j], shift ), yy[i - j] );
+ s = L_msu_sat( s, a[j], yy[i - j] ); // Qa + Qx - shift + 1
}
- s = L_shl_sat( s, q );
- yy[i] = extract_h( s );
+ s = L_shl_sat( s, q ); // Qx + (Qa + q)Q15 - shift + 1 = Qx - shift + Q16
+ yy[i] = extract_h( s ); // Qx - shift
move16();
y[i] = extract_h( s );
move16();
@@ -639,25 +639,7 @@ void synth_mem_updt2(
{
lerp( old_exc + L_EXC_MEM - last_L_frame, old_exc + L_EXC_MEM - L_frame, L_frame, last_L_frame );
}
-#ifdef ADD_LRTD
- IF( EQ_16( dec, DEC_IVAS ) )
- {
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- /* find scaling factor */
- PME()
- en1 = 1.25f * sum2_f( mem_syn2, M );
- en2 = sum2_f( mem_syn_r + L_SYN_MEM - M, M );
- loc_rat = sqrtf( en2 ) / ( sqrtf( en1 ) + 0.01f );
- /* scale synthesis filter memory */
- FOR( i = 0; i < M; i++ )
- {
- mem_syn_r[L_SYN_MEM - M + i] *= loc_rat;
- }
- }
- }
-#endif
/*Resamp memory*/
/*Size of LPC syn memory*/
/* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */
diff --git a/lib_com/tcq_position_arith_fx.c b/lib_com/tcq_position_arith_fx.c
index 0466dc133ffdcfacc31ed63696c9eda864027398..3abd527ca8bfa8b8690066da37fd978afd1aadb9 100644
--- a/lib_com/tcq_position_arith_fx.c
+++ b/lib_com/tcq_position_arith_fx.c
@@ -1983,11 +1983,7 @@ Word32 encode_magnitude_tcq_fx(
move16();
bits_fx = L_deposit_l( 0 );
-#ifdef IVAS_ISSUE_1188_EVS_CRASH
tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) );
-#else
- tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - nzpos - 1] ) );
-#endif
*est_frame_bits_fx = L_add( *est_frame_bits_fx, tcq_bits_fx );
move32();
@@ -2470,11 +2466,7 @@ void decode_mangitude_tcq_fx(
move16();
bits_fx = L_deposit_l( 0 );
-#ifdef IVAS_ISSUE_1188_EVS_CRASH
tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) );
-#else
- tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - nzpos - 1] ) );
-#endif
IF( EQ_16( nzpos, npulses ) )
{
diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c
index 55228e0b348b663d3d7c9eba8dd3408c9ef146b7..322549a6f0841e9d147075092d263ad85526b9da 100644
--- a/lib_com/tcx_ltp_fx.c
+++ b/lib_com/tcx_ltp_fx.c
@@ -1252,7 +1252,7 @@ Word16 tcx_ltp_decode_params(
return 0;
}
-void tcx_ltp_post(
+void tcx_ltp_post_fx(
Decoder_State *st,
TCX_LTP_DEC_HANDLE hTcxLtpDec,
Word16 core, /* Q0 */
@@ -1282,7 +1282,7 @@ void tcx_ltp_post(
filtIdx = 0; /* just to avoid comilation warnings */
move16();
- tcx_buf_len = NS2SA( st->output_Fs, TCXLTP_DELAY_NS ); /* Q0 */
+ tcx_buf_len = NS2SA_FX2( st->output_Fs, TCXLTP_DELAY_NS ); /* Q0 */
SideInfoOnly = 0;
move16();
if ( GE_32( total_brate, HQ_96k ) )
@@ -1616,7 +1616,8 @@ void tcx_ltp_post(
}
-void tcx_ltp_post32(
+/* IVAS 32-bit variant */
+void tcx_ltp_post_fx32(
Decoder_State *st,
TCX_LTP_DEC_HANDLE hTcxLtpDec,
Word16 core, /* Q0 */
diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c
index 1fc57871d4b4a6ab7096c28bc6dda728ee5cbd39..b2cee32e67e81bb3cd4b8af746959d3d014edd81 100644
--- a/lib_com/tcx_mdct_fx.c
+++ b/lib_com/tcx_mdct_fx.c
@@ -106,9 +106,7 @@ void TCX_MDCT(
Word16 i;
Word16 factor, neg_factor;
Word16 factor_e;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) element_mode;
-#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
@@ -164,9 +162,7 @@ void TCX_MDST(
Word16 i;
Word16 factor, neg_factor;
Word16 factor_e;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) element_mode;
-#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
@@ -226,9 +222,7 @@ void TCX_MDCT_Inverse(
Word16 L2 = l, R2 = r;
Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2];
Word16 fac_e;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) element_mode;
-#endif
L2 = shr( l, 1 );
R2 = shr( r, 1 );
diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c
index cececd8f5228da3cc6c000f11b8866edda7ae1dd..44ce806f73305390709b042c43728ab19ae3aab0 100644
--- a/lib_com/tcx_mdct_window.c
+++ b/lib_com/tcx_mdct_window.c
@@ -39,7 +39,6 @@
#include "options.h"
#include
#include "cnst.h"
-#include "prot.h"
#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c
index 4e40e4ab2d30843044c2c715bb0624e7984d2e37..c5ff95e04e68c7904a93ddc7444440333131cded 100644
--- a/lib_com/tcx_utils_fx.c
+++ b/lib_com/tcx_utils_fx.c
@@ -9,7 +9,6 @@
#include "rom_com.h"
#include "rom_basop_util.h"
#include "basop_util.h"
-#include "prot.h"
#define inv_int InvIntTable
diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c
index af4a87d34a66536ac2c68eeb5b76782e0e1ff259..101bc1df8b6552407c352786dc2e08dd79ec5ec0 100644
--- a/lib_com/tns_base.c
+++ b/lib_com/tns_base.c
@@ -12,7 +12,6 @@
#include "rom_com.h"
#include "prot_fx.h"
#include "basop_util.h"
-#include "prot.h"
/*----------------------------------------------------------------------------
* Local constants
@@ -1202,6 +1201,10 @@ void ResetTnsData( STnsData *pTnsData )
move16();
pTnsFilter->predictionGain = ONE_IN_Q7; /*Q7*/
move16();
+ pTnsFilter->predictionGain32 = ONE_IN_Q23; /*Q23*/
+ move32();
+ pTnsFilter->predictionGain_e = PRED_GAIN_E;
+ move16();
pTnsFilter->avgSqrCoef = 0;
move16();
pTnsFilter->filterType = TNS_FILTER_OFF; /*Q0*/
diff --git a/lib_com/tools.c b/lib_com/tools.c
index 4d9f5e956e17d513f53624c4a71769e7de8dd443..b1a9f4d13f29a8e3b9e0d7e53c8cd5b0b51bfb6f 100644
--- a/lib_com/tools.c
+++ b/lib_com/tools.c
@@ -37,7 +37,6 @@
#include
#include "options.h"
#include
-#include "prot.h"
#include "prot_fx.h"
#include "wmc_auto.h"
@@ -136,23 +135,6 @@ int16_t sum_s(
return tmp;
}
-/*! r: sum of all vector elements */
-int32_t sum_l(
- const int32_t *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-)
-{
- int16_t i;
- int32_t tmpL;
-
- tmpL = 0;
- for ( i = 0; i < lvec; i++ )
- {
- tmpL += vec[i];
- }
-
- return tmpL;
-}
/*! r: sum of all vector elements */
Word32 sum_l_fx(
const Word32 *vec, /* i : input vector */
@@ -171,23 +153,6 @@ Word32 sum_l_fx(
return tmpL;
}
-/*! r: sum of all vector elements */
-float sum_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];
- }
-
- return tmp;
-}
/*----------------------------------------------------------------------
* sum2_f()
@@ -228,22 +193,6 @@ Word32 sum2_f_16_gb_fx(
return tmp;
}
-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;
-}
Word32 sum2_16_exp_fx(
const Word16 *vec, /* i : input vector Q(15 - exp) */
@@ -532,101 +481,6 @@ void mvs2s(
return;
}
-uint32_t mvr2s(
- const float x[], /* i : input vector */
- int16_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-)
-{
- int16_t i;
- float temp;
- uint32_t noClipping = 0;
-
- if ( n <= 0 )
- {
- /* cannot transfer vectors with size 0 */
- return 0;
- }
-
- if ( (void *) y <= (const void *) x )
- {
- for ( i = 0; i < n; i++ )
- {
- temp = x[i];
- temp = (float) floor( temp + 0.5f );
-
- if ( temp > MAX16B_FLT )
- {
- temp = MAX16B_FLT;
- noClipping++;
- }
- else if ( temp < MIN16B_FLT )
- {
- temp = MIN16B_FLT;
- noClipping++;
- }
-
- y[i] = (int16_t) temp;
- }
- }
- else
- {
- for ( i = n - 1; i >= 0; i-- )
- {
- temp = x[i];
- temp = (float) floor( temp + 0.5f );
-
- if ( temp > MAX16B_FLT )
- {
- temp = MAX16B_FLT;
- noClipping++;
- }
- else if ( temp < MIN16B_FLT )
- {
- temp = MIN16B_FLT;
- noClipping++;
- }
-
- y[i] = (int16_t) temp;
- }
- }
-
- return noClipping;
-}
-
-void mvs2r(
- const int16_t 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 ( (void *) y < (const void *) x )
- {
- for ( i = 0; i < n; i++ )
- {
- y[i] = (float) x[i];
- }
- }
- else
- {
- for ( i = n - 1; i >= 0; i-- )
- {
- y[i] = (float) x[i];
- }
- }
-
- return;
-}
-
-
void mvl2l(
const int32_t x[], /* i : input vector */
int32_t y[], /* o : output vector */
@@ -659,44 +513,6 @@ void mvl2l(
return;
}
-
-/*---------------------------------------------------------------------*
- * maximum()
- *
- * Find index and value of the maximum in a vector
- *---------------------------------------------------------------------*/
-
-/*! r: index of the maximum value in the input vector */
-int16_t maximum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *max_val /* o : maximum value in the input vector */
-)
-{
- int16_t j, ind;
- float tmp;
-
- ind = 0;
- tmp = vec[0];
-
- for ( j = 1; j < lvec; j++ )
- {
- if ( vec[j] > tmp )
- {
- ind = j;
- tmp = vec[j];
- }
- }
-
- if ( max_val != NULL )
- {
- *max_val = tmp;
- }
-
- return ind;
-}
-
-
/*! r: index of the maximum value in the input vector */
Word16 maximum_s(
const Word16 *vec, /* i : input vector */
@@ -766,42 +582,6 @@ Word16 maximum_l(
return ind;
}
-/*---------------------------------------------------------------------*
- * maximumAbs()
- *
- * Find index and value of the maximum in a vector
- *---------------------------------------------------------------------*/
-
-/*! r: index of the maximum value in the input vector */
-int16_t maximumAbs(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *max_val /* o : maximum value in the input vector */
-)
-{
- int16_t j, ind;
- float tmp;
-
- ind = 0;
- tmp = (float) fabs( vec[0] );
-
- for ( j = 1; j < lvec; j++ )
- {
- if ( (float) fabs( vec[j] ) > tmp )
- {
- ind = j;
- tmp = (float) fabs( vec[j] );
- }
- }
-
- if ( max_val != NULL )
- {
- *max_val = tmp;
- }
-
- return ind;
-}
-
/*! r: index of the maximum value in the input vector */
Word16 maximumAbs_l(
const Word32 *vec, /* i : input vector */
@@ -835,42 +615,6 @@ Word16 maximumAbs_l(
return ind;
}
-/*---------------------------------------------------------------------*
- * minimum()
- *
- * Find index of a minimum in a vector
- *---------------------------------------------------------------------*/
-
-/*! r: index of the minimum value in the input vector */
-int16_t minimum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *min_val /* o : minimum value in the input vector */
-)
-{
- int16_t j, ind;
- float tmp;
-
- ind = 0;
- tmp = vec[0];
-
- for ( j = 1; j < lvec; j++ )
- {
- if ( vec[j] < tmp )
- {
- ind = j;
- tmp = vec[j];
- }
- }
-
- if ( min_val != NULL )
- {
- *min_val = tmp;
- }
-
- return ind;
-}
-
/*-------------------------------------------------------------------*
* minimum_s()
*
@@ -884,45 +628,23 @@ Word16 minimum_s(
Word16 *min_val /* o : minimum value in the input vector */
)
{
-#ifdef FIX_1105_OPT_MINIMUM_SL
Word16 i, ind;
-#else
- Word16 i, ind, tmp;
-#endif
ind = 0;
move16();
-#ifndef FIX_1105_OPT_MINIMUM_SL
- tmp = vec[0];
- move16();
-#endif
FOR( i = 1; i < lvec; i++ )
{
-#ifdef FIX_1105_OPT_MINIMUM_SL
if ( LT_16( vec[i], vec[ind] ) )
{
ind = i;
move16();
}
-#else
- IF( LT_16( vec[i], tmp ) )
- {
- ind = i;
- move16();
- tmp = vec[i];
- move16();
- }
-#endif
}
if ( min_val != NULL )
{
-#ifdef FIX_1105_OPT_MINIMUM_SL
*min_val = vec[ind];
-#else
- *min_val = tmp;
-#endif
move16();
}
@@ -943,104 +665,28 @@ Word16 minimum_l(
)
{
Word16 i, ind;
-#ifndef FIX_1105_OPT_MINIMUM_SL
- Word32 tmp;
-#endif
ind = 0;
-#ifndef FIX_1105_OPT_MINIMUM_SL
- tmp = vec[0];
-#endif
move16();
-#ifndef FIX_1105_OPT_MINIMUM_SL
- move32();
-#endif
FOR( i = 1; i < lvec; i++ )
{
-#ifdef FIX_1105_OPT_MINIMUM_SL
if ( LT_32( vec[i], vec[ind] ) )
{
ind = i;
move16();
}
-#else
- IF( LT_32( vec[i], tmp ) )
- {
- ind = i;
- tmp = vec[i];
- move16();
- move32();
- }
-#endif
}
if ( min_val != NULL )
{
-#ifdef FIX_1105_OPT_MINIMUM_SL
*min_val = vec[ind];
-#else
- *min_val = tmp;
-#endif
move32();
}
return ind;
}
-/*---------------------------------------------------------------------*
- * emaximum()
- *
- * Find index of a maximum energy in a vector
- *---------------------------------------------------------------------*/
-
-/*! r: return index with max energy value in vector */
-int16_t emaximum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *ener_max /* o : maximum energy value */
-)
-{
- int16_t j, ind;
- float temp;
-
- *ener_max = 0.0f;
- ind = 0;
-
- for ( j = 0; j < lvec; j++ )
- {
- temp = vec[j] * vec[j];
-
- if ( temp > *ener_max )
- {
- ind = j;
- *ener_max = temp;
- }
- }
-
- return ind;
-}
-
-
-/*---------------------------------------------------------------------*
- * mean()
- *
- * Find the mean of the vector
- *---------------------------------------------------------------------*/
-
-/*! r: mean of vector */
-float mean(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-)
-{
- float tmp;
-
- tmp = sum_f( vec, lvec ) / (float) lvec;
-
- return tmp;
-}
-
/*---------------------------------------------------------------------*
* dotp()
*
@@ -1168,175 +814,67 @@ float inv_sqrt(
return (float) ( 1.0 / sqrt( x ) );
}
-
/*-------------------------------------------------------------------*
- * conv()
+ * v_add_w64()
*
- * Convolution between vectors x[] and h[] written to y[]
- * All vectors are of length L. Only the first L samples of the
- * convolution are considered.
+ * Subtraction of two vectors sample by sample
*-------------------------------------------------------------------*/
-void conv(
- const float x[], /* i : input vector */
- const float h[], /* i : impulse response (or second input vector) */
- float y[], /* o : output vetor (result of convolution) */
- const int16_t L /* i : vector size */
+void v_add_w64(
+ const Word64 x1[], /* i : Input vector 1 */
+ const Word64 x2[], /* i : Input vector 2 */
+ Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N, /* i : Vector length */
+ const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
)
{
- float temp;
- int16_t i, n;
- for ( n = 0; n < L; n++ )
+ Word16 i;
+
+ FOR( i = 0; i < N; i++ )
{
- temp = x[0] * h[n];
- for ( i = 1; i <= n; i++ )
- {
- temp += x[i] * h[n - i];
- }
- y[n] = temp;
+ y[i] = W_add( W_shr( x1[i], hdrm ), W_shr( x2[i], hdrm ) );
+ move64();
}
return;
}
+
/*-------------------------------------------------------------------*
- * fir()
+ * v_sub()
*
- * FIR filtering of vector x[] with filter having impulse response h[]
- * written to y[]
- * The input vector has length L and the FIR filter has an order of K, i.e.
- * K+1 coefficients. The memory of the input signal is provided in the vector mem[]
- * which has K values
- * The maximum length of the input signal is L_FRAME32k and the maximum order
- * of the FIR filter is L_FILT_MAX
+ * Subtraction of two vectors sample by sample
*-------------------------------------------------------------------*/
-void fir(
- const float x[], /* i : input vector */
- const float h[], /* i : impulse response of the FIR filter */
- float y[], /* o : output vector (result of filtering) */
- float mem[], /* i/o: memory of the input signal (L samples) */
- const int16_t L, /* i : input vector size */
- const int16_t K, /* i : order of the FIR filter (K+1 coefs.) */
- const int16_t upd /* i : 1 = update the memory, 0 = not */
+void v_sub(
+ const float x1[], /* i : Input vector 1 */
+ const float x2[], /* i : Input vector 2 */
+ float y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const int16_t N /* i : Vector length */
)
{
- float buf_in[L_FRAME48k + 60], buf_out[L_FRAME48k], s;
- int16_t i, j;
-
- /* prepare the input buffer (copy and update memory) */
- mvr2r( mem, buf_in, K );
- mvr2r( x, buf_in + K, L );
-
- if ( upd )
- {
- mvr2r( buf_in + L, mem, K );
- }
+ int16_t i;
- /* do the filtering */
- for ( i = 0; i < L; i++ )
+ for ( i = 0; i < N; i++ )
{
- s = buf_in[K + i] * h[0];
-
- for ( j = 1; j <= K; j++ )
- {
- s += h[j] * buf_in[K + i - j];
- }
-
- buf_out[i] = s;
+ y[i] = x1[i] - x2[i];
}
- /* copy to the output buffer */
- mvr2r( buf_out, y, L );
-
return;
}
/*-------------------------------------------------------------------*
- * v_add()
+ * v_sub()
*
- * Addition of two vectors sample by sample
+ * Subtraction of two vectors sample by sample
*-------------------------------------------------------------------*/
-void v_add(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = x1[i] + x2[i];
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * v_add_w64()
- *
- * Subtraction of two vectors sample by sample
- *-------------------------------------------------------------------*/
-
-void v_add_w64(
- const Word64 x1[], /* i : Input vector 1 */
- const Word64 x2[], /* i : Input vector 2 */
- Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */
- const Word16 N, /* i : Vector length */
- const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
-)
-{
- Word16 i;
-
- FOR( i = 0; i < N; i++ )
- {
- y[i] = W_add( W_shr( x1[i], hdrm ), W_shr( x2[i], hdrm ) );
- move64();
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * v_sub()
- *
- * Subtraction of two vectors sample by sample
- *-------------------------------------------------------------------*/
-
-void v_sub(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 - vector 2 */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = x1[i] - x2[i];
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * v_sub()
- *
- * Subtraction of two vectors sample by sample
- *-------------------------------------------------------------------*/
-
-void v_sub_fixed(
- const Word32 x1[], /* i : Input vector 1 */
- const Word32 x2[], /* i : Input vector 2 */
- Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
- const Word16 N, /* i : Vector length */
- const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
+void v_sub_fixed(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N, /* i : Vector length */
+ const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
)
{
Word16 i;
@@ -1350,52 +888,6 @@ void v_sub_fixed(
return;
}
-/*-------------------------------------------------------------------*
- * v_mult()
- *
- * Multiplication of two vectors
- *-------------------------------------------------------------------*/
-
-void v_mult(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = x1[i] * x2[i];
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * v_multc()
- *
- * Multiplication of vector by constant
- *-------------------------------------------------------------------*/
-
-void v_multc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains c*x */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = c * x[i];
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
* v_multc_fixed()
*
@@ -1456,102 +948,6 @@ void v_multc_fixed_16_16(
return;
}
-/*-------------------------------------------------------------------*
- * squant()
- *
- * Scalar quantizer according to MMSE criterion (nearest neighbour in Euclidean space)
- *
- * Searches a given codebook to find the nearest neighbour in Euclidean space.
- * Index of the winning codeword and the winning codeword itself are returned.
- *-------------------------------------------------------------------*/
-
-/*! r: index of the winning codeword */
-int16_t squant(
- const float x, /* i : scalar value to quantize */
- float *xq, /* o : quantized value */
- const float cb[], /* i : codebook */
- const int16_t cbsize /* i : codebook size */
-)
-{
- float dist, mindist, tmp;
- int16_t c, idx;
-
- idx = 0;
- mindist = 1e16f;
-
- for ( c = 0; c < cbsize; c++ )
- {
- dist = 0.0f;
- tmp = x - cb[c];
- dist += tmp * tmp;
- if ( dist < mindist )
- {
- mindist = dist;
- idx = c;
- }
- }
-
- *xq = cb[idx];
-
- return idx;
-}
-
-/*! r: index of the winning codeword */
-int16_t squant_int(
- uint8_t x, /* i : scalar value to quantize */
- uint8_t *xq, /* o : quantized value */
- const uint8_t *cb, /* i : codebook */
- const int16_t cbsize /* i : codebook size */
-)
-{
- int16_t i, idx;
- float mindist, d;
-
- idx = 0;
- mindist = 10000000.0f;
- for ( i = 0; i < cbsize; i++ )
- {
- d = (float) ( x - cb[i] ) * ( x - cb[i] );
- if ( d < mindist )
- {
- mindist = d;
- idx = i;
- }
- }
- *xq = cb[idx];
-
- return idx;
-}
-
-
-/*-------------------------------------------------------------------*
- * usquant()
- *
- * Uniform scalar quantizer according to MMSE criterion
- * (nearest neighbour in Euclidean space)
- *
- * Applies quantization based on scale and round operations.
- * Index of the winning codeword and the winning codeword itself are returned.
- *-------------------------------------------------------------------*/
-
-/*! r: index of the winning codeword */
-int16_t usquant(
- const float x, /* i : scalar value to quantize */
- float *xq, /* o : quantized value */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta, /* i : quantization step */
- const int16_t cbsize /* i : codebook size */
-)
-{
- int16_t idx;
-
- idx = (int16_t) max( 0.f, min( cbsize - 1, ( ( x - qlow ) / delta + 0.5f ) ) );
- *xq = idx * delta + qlow;
-
- return idx;
-}
-
-
/*-------------------------------------------------------------------*
* usdequant()
*
@@ -1573,219 +969,6 @@ float usdequant(
return ( g );
}
-
-/*-------------------------------------------------------------------*
- * vquant()
- *
- * Vector quantizer according to MMSE criterion (nearest neighbour in Euclidean space)
- *
- * Searches a given codebook to find the nearest neighbour in Euclidean space.
- * Index of the winning codevector and the winning vector itself are returned.
- *-------------------------------------------------------------------*/
-
-/*! r: index of the winning codevector */
-int16_t vquant(
- float x[], /* i : vector to quantize */
- const float x_mean[], /* i : vector mean to subtract (0 if none) */
- float xq[], /* o : quantized vector */
- const float cb[], /* i : codebook */
- const int16_t dim, /* i : dimension of codebook vectors */
- const int16_t cbsize /* i : codebook size */
-)
-{
- float dist, mindist, tmp;
- int16_t c, d, idx, j;
-
- idx = 0;
- mindist = 1e16f;
-
- if ( x_mean != 0 )
- {
- for ( d = 0; d < dim; d++ )
- {
- x[d] -= x_mean[d];
- }
- }
-
- j = 0;
- for ( c = 0; c < cbsize; c++ )
- {
- dist = 0.0f;
- for ( d = 0; d < dim; d++ )
- {
- tmp = x[d] - cb[j++];
- dist += tmp * tmp;
- }
-
- if ( dist < mindist )
- {
- mindist = dist;
- idx = c;
- }
- }
-
- if ( xq == 0 )
- {
- return idx;
- }
-
- j = idx * dim;
- for ( d = 0; d < dim; d++ )
- {
- xq[d] = cb[j++];
- }
-
- if ( x_mean != 0 )
- {
- for ( d = 0; d < dim; d++ )
- {
- xq[d] += x_mean[d];
- }
- }
-
- return idx;
-}
-
-/*-------------------------------------------------------------------*
- * w_vquant()
- *
- * Vector quantizer according to MMSE criterion (nearest neighbour in Euclidean space)
- *
- * Searches a given codebook to find the nearest neighbour in Euclidean space.
- * Weights are put on the error for each vector element.
- * Index of the winning codevector and the winning vector itself are returned.
- *-------------------------------------------------------------------*/
-
-/*! r: index of the winning codevector */
-int16_t w_vquant(
- float x[], /* i : vector to quantize */
- const float x_mean[], /* i : vector mean to subtract (0 if none) */
- const int16_t weights[], /* i : error weights */
- float xq[], /* o : quantized vector */
- const float cb[], /* i : codebook */
- const int16_t dim, /* i : dimension of codebook vectors */
- const int16_t cbsize, /* i : codebook size */
- const int16_t rev_vect /* i : reverse codebook vectors */
-)
-{
- float dist, mindist, tmp;
- int16_t c, d, idx, j, k;
-
- idx = 0;
- mindist = 1e16f;
-
- if ( x_mean != 0 )
- {
- for ( d = 0; d < dim; d++ )
- {
- x[d] -= x_mean[d];
- }
- }
-
- j = 0;
- if ( rev_vect )
- {
- k = dim - 1;
- for ( c = 0; c < cbsize; c++ )
- {
- dist = 0.0f;
-
- for ( d = k; d >= 0; d-- )
- {
- tmp = x[d] - cb[j++];
- dist += weights[d] * ( tmp * tmp );
- }
-
- if ( dist < mindist )
- {
- mindist = dist;
- idx = c;
- }
- }
-
- if ( xq == 0 )
- {
- return idx;
- }
-
- j = idx * dim;
- for ( d = k; d >= 0; d-- )
- {
- xq[d] = cb[j++];
- }
- }
- else
- {
- for ( c = 0; c < cbsize; c++ )
- {
- dist = 0.0f;
-
- for ( d = 0; d < dim; d++ )
- {
- tmp = x[d] - cb[j++];
- dist += weights[d] * ( tmp * tmp );
- }
-
- if ( dist < mindist )
- {
- mindist = dist;
- idx = c;
- }
- }
-
- if ( xq == 0 )
- {
- return idx;
- }
-
- j = idx * dim;
- for ( d = 0; d < dim; d++ )
- {
- xq[d] = cb[j++];
- }
- }
-
- if ( x_mean != 0 )
- {
- for ( d = 0; d < dim; d++ )
- {
- xq[d] += x_mean[d];
- }
- }
-
- return idx;
-}
-
-
-/*----------------------------------------------------------------------------------*
- * v_sort()
- *
- * Sorting of vectors. This is very fast with almost ordered vectors.
- *----------------------------------------------------------------------------------*/
-
-void v_sort_float(
- float *r, /* i/o: Vector to be sorted in place */
- const int16_t lo, /* i : Low limit of sorting range */
- const int16_t up /* I : High limit of sorting range */
-)
-{
- int16_t i, j;
- float tempr;
-
- for ( i = up - 1; i >= lo; i-- )
- {
- tempr = r[i];
- for ( j = i + 1; j <= up && ( tempr > r[j] ); j++ )
- {
- r[j - 1] = r[j];
- }
-
- r[j - 1] = tempr;
- }
-
- return;
-}
-
void sort(
UWord16 *x, /* i/o: Vector to be sorted */
UWord16 len /* i/o: vector length */
@@ -1810,426 +993,3 @@ void sort(
return;
}
-
-/*---------------------------------------------------------------------*
- * var()
- *
- * Calculate the variance of a vector
- *---------------------------------------------------------------------*/
-
-/*! r: variance of vector */
-float var(
- const float *x, /* i : input vector */
- const int16_t len /* i : length of inputvector */
-)
-{
- float m;
- float v;
- int16_t i;
-
- m = mean( x, len );
-
- v = 0.0f;
- for ( i = 0; i < len; i++ )
- {
- v += ( x[i] - m ) * ( x[i] - m );
- }
- v /= len;
-
- return v;
-}
-
-
-/*---------------------------------------------------------------------*
- * std_dev()
- *
- * Calculate the standard deviation of a vector
- *---------------------------------------------------------------------*/
-
-/*! r: standard deviation */
-float std_dev(
- const float *x, /* i : input vector */
- const int16_t len /* i : length of the input vector */
-)
-{
- int16_t i;
- float std;
-
- std = 1e-16f;
- for ( i = 0; i < len; i++ )
- {
- std += x[i] * x[i];
- }
-
- std = (float) sqrt( std / len );
-
- return std;
-}
-
-
-/*---------------------------------------------------------------------*
- * dot_product_mat()
- *
- * Calculates dot product of type x'*A*x, where x is column vector of size m,
- * and A is square matrix of size m*m
- *---------------------------------------------------------------------*/
-
-/*! r: the dot product x'*A*x */
-float dot_product_mat(
- const float *x, /* i : vector x */
- const float *A, /* i : matrix A */
- const int16_t m /* i : vector & matrix size */
-)
-{
- int16_t i, j;
- float suma, tmp_sum;
- const float *pt_x, *pt_A;
-
- pt_A = A;
- suma = 0;
-
- for ( i = 0; i < m; i++ )
- {
- tmp_sum = 0;
- pt_x = x;
- for ( j = 0; j < m; j++ )
- {
- tmp_sum += *pt_x++ * *pt_A++;
- }
-
- suma += x[i] * tmp_sum;
- }
-
- return suma;
-}
-
-
-/*--------------------------------------------------------------------------------*
- * polezero_filter()
- *
- * Y(Z)=X(Z)(b[0]+b[1]z^(-1)+..+b[L]z^(-L))/(a[0]+a[1]z^(-1)+..+a[M]z^(-M))
- * mem[n]=x[n]+cp[0]mem[n-1]+..+cp[M-1]mem[n-M], where cp[i]=-a[i+1]/a[0]
- * y[n]=cz[0]mem[n]+cz[1]mem[n-1]+..+cz[L]mem[n-L], where cz[i]=b[i]/a[0]
- * mem={mem[n-K] mem[n-K+1] . . . . mem[n-2] mem[n-1]}, where K=max(L,M)
- *
- * a[0] must be equal to 1.0f!
- *---------------------------------------------------------------------------------*/
-
-void polezero_filter(
- const float *in, /* i : input vector */
- float *out, /* o : output vector */
- const int16_t N, /* i : input vector size */
- const float *b, /* i : numerator coefficients */
- const float *a, /* i : denominator coefficients */
- const int16_t order, /* i : filter order */
- float *mem /* i/o: filter memory */
-)
-{
- int16_t i, j, k;
-
-
- for ( i = 0; i < order; i++ )
- {
- out[i] = in[i] * b[0];
- for ( j = 0; j < i; j++ )
- {
- out[i] += in[i - 1 - j] * b[j + 1] - out[i - 1 - j] * a[j + 1];
- }
-
- for ( k = order - 1; j < order; j++, k-- )
- {
- out[i] += mem[k] * b[j + 1] - mem[k + order] * a[j + 1];
- }
- }
-
- for ( ; i < N; i++ )
- {
- out[i] = in[i] * b[0];
- for ( j = 0; j < order; j++ )
- {
- out[i] += in[i - 1 - j] * b[j + 1] - out[i - 1 - j] * a[j + 1];
- }
- }
-
- for ( i = 0; i < order; i++ )
- {
- mem[i] = in[N - order + i];
- mem[i + order] = out[N - order + i];
- }
-
- return;
-}
-
-#define WMC_TOOL_SKIP
-static float fleft_shift( float input, const int16_t shift )
-{
- return ( input * (float) pow( 2.0, (double) shift ) );
-}
-
-static float fright_shift( float input, const int16_t shift )
-{
- return ( input * (float) pow( 0.5, (double) shift ) );
-}
-#undef WMC_TOOL_SKIP
-
-
-/*--------------------------------------------------------------------------------*
- * root_a()
- *
- * Implements a quadratic approximation to sqrt(a)
- * Firstly, a is normalized to lie between 0.25 & 1.0
- * by shifting the input left or right by an even number of
- * shifts. Even shifts represent powers of 4 which, after
- * the sqrt, can easily be converted to powers of 2 and are
- * easily dealt with.
- * At the heart of the algorithm is a quadratic
- * approximation of the curve sqrt(a) for 0.25 <= a <= 1.0.
- * Sqrt(a) approx = 0.27 + 1.0127 * a - 0.2864 * a^2
- *
- *---------------------------------------------------------------------------------*/
-
-float root_a(
- float a )
-{
- int16_t shift_a;
- float mod_a;
- float approx;
-
- if ( a <= 0.0f )
- {
- return 0.0;
- }
-
-#define WMC_TOOL_SKIP
- /* This next piece of code implements a "norm" function */
- /* and returns the shift needed to scale "a" to have a */
- /* 1 in the (MSB-1) position. This is equivalent to */
- /* giving a value between 0.5 & 1.0. */
- mod_a = a;
-
- shift_a = 0;
- while ( mod_a > 1.0 )
- {
- mod_a /= 2.0;
- shift_a--;
- }
-
- while ( mod_a < 0.5 )
- {
- mod_a *= 2.0;
- shift_a++;
- }
-#undef WMC_TOOL_SKIP
-
- shift_a &= 0xfffe;
- mod_a = fleft_shift( a, shift_a );
-
- approx = 0.27f + 1.0127f * mod_a - 0.2864f * mod_a * mod_a;
-
- approx = fright_shift( approx, ( shift_a >> 1 ) );
-
- return ( approx );
-}
-
-/*--------------------------------------------------------------------------------*
- * root_a_over_b()
- *
- * Implements an approximation to sqrt(a/b)
- * Firstly a & b are normalized to lie between 0.25 & 1.0
- * by shifting the inputs left or right by an even number
- * of shifts.
- * Even shifts represent powers of 4 which, after the sqrt,
- * become powers of 2 and are easily dealt with.
- * At the heart of the algorithm is an approximation of the
- * curve sqrt(a/b) for 0.25 <= a <= 1.0 & 0.25 <= b <= 1.0.
- * Given the value of b, the 2nd order coefficients p0, p1
- * & p2 can be determined so that...
- * Sqrt(a/b) approx = p0 + p1 * a + p2 * a^2
- * where p0 approx = 0.7176 - 0.8815 * b + 0.4429 * b^2
- * p1 approx = 2.6908 - 3.3056 * b + 1.6608 * b^2
- * p2 approx = -0.7609 + 0.9346 * b - 0.4695 * b^2
- *
- *---------------------------------------------------------------------------------*/
-
-float root_a_over_b(
- float a,
- float b )
-{
- int16_t shift_a, shift_b, shift;
- float mod_a, mod_b;
- float p2 = -0.7609f;
- float p1 = 2.6908f;
- float p0 = 0.7176f;
- float b_sqr;
- float approx;
-
- if ( ( a <= 0.0f ) || ( b <= 0.0f ) )
- {
- return 0.0;
- }
-#define WMC_TOOL_SKIP
- if ( isinf( a ) )
-#undef WMC_TOOL_SKIP
- {
- return FLT_MAX;
- }
-#define WMC_TOOL_SKIP
- if ( isinf( b ) )
-#undef WMC_TOOL_SKIP
- {
- return 0.f;
- }
-
- a += 0x00000001;
- b += 0x00000001;
-
-#define WMC_TOOL_SKIP
- /* This next piece of code implements a "norm" function */
- /* and returns the shift needed to scale "a" to have a */
- /* 1 in the (MSB-1) position. This is equivalent to */
- /* giving a value between 0.5 & 1.0. */
- mod_a = a;
-
- shift_a = 0;
- while ( mod_a > 1.0 )
- {
- mod_a /= 2.0;
- shift_a--;
- }
-
- while ( mod_a < 0.5 )
- {
- mod_a *= 2.0;
- shift_a++;
- }
-#undef WMC_TOOL_SKIP
-
- shift_a &= 0xfffe;
- mod_a = fleft_shift( a, shift_a );
-
-#define WMC_TOOL_SKIP
- /* This next piece of code implements a "norm" function */
- /* and returns the shift needed to scale "b" to have a */
- /* 1 in the (MSB-1) position. This is equivalent to */
- /* giving a value between 0.5 & 1.0. */
- mod_b = b;
-
- shift_b = 0;
- while ( mod_b > 1.0 )
- {
- mod_b /= 2.0;
- shift_b--;
- }
-
- while ( mod_b < 0.5 )
- {
- mod_b *= 2.0;
- shift_b++;
- }
-#undef WMC_TOOL_SKIP
-
- shift_b &= 0xfffe;
- mod_b = fleft_shift( b, shift_b );
-
- shift = ( shift_b - shift_a ) >> 1;
-
- b_sqr = mod_b * mod_b;
-
- p2 += 0.9346f * mod_b + -0.4695f * b_sqr;
- p1 += -3.3056f * mod_b + 1.6608f * b_sqr;
- p0 += -0.8815f * mod_b + 0.4429f * b_sqr;
-
- approx = p0 + p1 * mod_a + p2 * mod_a * mod_a;
-
- approx = fleft_shift( approx, shift );
-
- return ( approx );
-}
-
-/*--------------------------------------------------------------------------------*
- * rint_new()
- *
- * Round to the nearest integer with mid-point exception
- *---------------------------------------------------------------------------------*/
-
-double rint_new(
- double x )
-{
- int16_t a;
-
- /* middle value point test */
- if ( ceil( x + 0.5 ) == floor( x + 0.5 ) )
- {
- a = (int16_t) ceil( x );
-
- if ( a % 2 == 0 )
- {
- return ceil( x );
- }
- else
- {
- return floor( x );
- }
- }
- else
- {
- return floor( x + 0.5 );
- }
-}
-
-
-/*-------------------------------------------------------------------*
- * anint()
- *
- * Round to the nearest integer.
- *-------------------------------------------------------------------*/
-
-double anint(
- double x )
-{
- return ( x ) >= 0 ? (int32_t) ( ( x ) + 0.5 ) : (int32_t) ( (x) -0.5 );
-}
-
-/*-------------------------------------------------------------------*
- * is_numeric_float()
- *
- * Returns 0 for all NaN and Inf values defined according to IEEE 754
- * floating point number's definition. Returns 1 for numeric values.
- *-------------------------------------------------------------------*/
-
-int16_t is_numeric_float(
- float x )
-{
- union float_int
- {
- float float_val;
- int32_t int_val;
- } float_int;
-
- float_int.float_val = x;
-
- return ( ( float_int.int_val & 0x7f800000 ) != 0x7f800000 );
-}
-
-/*-------------------------------------------------------------------*
- * delay_signal_float()
- *
- * Delay buffer by defined number of samples
- *-------------------------------------------------------------------*/
-
-void delay_signal_float(
- float x[], /* i/o: signal to be delayed */
- const int16_t len, /* i : length of the input signal */
- float mem[], /* i/o: synchronization memory */
- const int16_t delay /* i : delay in samples */
-)
-{
- float tmp_buffer[L_FRAME48k];
-
- mvr2r( mem, tmp_buffer, delay );
- mvr2r( x + len - delay, mem, delay );
- mvr2r( x, x + delay, len - delay );
- mvr2r( tmp_buffer, x, delay );
-
- return;
-}
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index efa9d7e5afc6fd54420d3fc6875dfa6dae55d478..5219d076cacffe36612af264db444d4f788d4851 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -50,7 +50,6 @@
#include "basop32.h"
#include "wmc_auto.h"
#include "prot_fx_enc.h"
-#include "prot.h"
#include "ivas_prot_fx.h"
#define INV_BANDS10 3277 /* 1/10 in Q15 */
@@ -484,26 +483,17 @@ void Copy(
move16();
}
-#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
/* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */
return;
-#endif
}
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
- ELSE
+ FOR( i = L - 1; i >= 0; i-- )
{
-#endif
- FOR( i = L - 1; i >= 0; i-- )
- {
- y[i] = x[i];
- move16();
- }
-
- return;
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
+ y[i] = x[i];
+ move16();
}
-#endif
+
+ return;
}
/*-------------------------------------------------------------------*
* Copy64:
@@ -525,26 +515,17 @@ void Copy64(
move64();
}
-#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
/* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */
return;
-#endif
}
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
- ELSE
+ FOR( i = L - 1; i >= 0; i-- )
{
-#endif
- FOR( i = L - 1; i >= 0; i-- )
- {
- y[i] = x[i];
- move64();
- }
-
- return;
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
+ y[i] = x[i];
+ move64();
}
-#endif
+
+ return;
}
void set64_fx(
@@ -581,28 +562,19 @@ void Copy_pword(
move16();
}
-#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
/* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */
return;
-#endif
}
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
- ELSE
+ FOR( i = L - 1; i >= 0; i-- )
{
-#endif
- FOR( i = L - 1; i >= 0; i-- )
- {
- y[i].v.im = x[i].v.im;
- y[i].v.re = x[i].v.re;
- move16();
- move16();
- }
-
- return;
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
+ y[i].v.im = x[i].v.im;
+ y[i].v.re = x[i].v.re;
+ move16();
+ move16();
}
-#endif
+
+ return;
}
/*-------------------------------------------------------------------*
* Copy32:
@@ -624,23 +596,14 @@ void Copy32(
move32();
}
-#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
return;
-#endif
}
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
- ELSE
+ FOR( i = L - 1; i >= 0; i-- )
{
-#endif
- FOR( i = L - 1; i >= 0; i-- )
- {
- y[i] = x[i];
- move32();
- }
-#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
+ y[i] = x[i];
+ move32();
}
-#endif
}
void set8_fx(
@@ -689,7 +652,6 @@ void set32_fx(
const Word16 N /* i : Lenght of the vector */
)
{
-#ifdef FIX_1106_SIMPLIFY_SET32FX
Word16 i;
FOR( i = 0; i < N; i++ )
@@ -697,26 +659,6 @@ void set32_fx(
y[i] = a;
move32();
}
-#else
- Word16 i, tmp;
- tmp = extract_l( a );
- IF( EQ_32( L_deposit_l( tmp ), a ) )
- {
- FOR( i = 0; i < N; i++ )
- {
- y[i] = L_deposit_l( tmp );
- move32();
- }
- }
- ELSE
- {
- FOR( i = 0; i < N; i++ )
- {
- y[i] = a;
- move32();
- }
- }
-#endif
return;
}
@@ -802,7 +744,6 @@ void Copy_Scale_sig_16_32_DEPREC(
}
return;
}
-#ifdef FIX_ISSUE_1237
#ifdef DEBUGGING
if ( exp0 >= 16 )
{
@@ -810,7 +751,6 @@ void Copy_Scale_sig_16_32_DEPREC(
}
#else
assert( exp0 < 16 );
-#endif
#endif
tmp = shl_o( 1, exp0, &Overflow );
FOR( i = 0; i < lg; i++ )
@@ -4005,13 +3945,14 @@ void floating_point_add(
move16();
return;
}
+
/*-------------------------------------------------------------------*
- * delay_signal()
+ * delay_signal_fx()
*
* Delay buffer by defined number of samples
*-------------------------------------------------------------------*/
-void delay_signal(
+void delay_signal_fx(
Word16 x[], /* i/o: signal to be delayed */
const Word16 len, /* i : length of the input signal */
Word16 mem[], /* i/o: synchronization memory */
@@ -4028,14 +3969,13 @@ void delay_signal(
return;
}
-void delay_signal_fx(
+void delay_signal32_fx(
Word32 x[], /* i/o: signal to be delayed */
const Word16 len, /* i : length of the input signal */
Word32 mem[], /* i/o: synchronization memory */
const Word16 delay /* i : delay in samples */
)
{
-
Word32 tmp_buffer[L_FRAME48k];
Copy32( mem, tmp_buffer, delay );
@@ -4045,6 +3985,7 @@ void delay_signal_fx(
return;
}
+
void delay_signal_q_adj_fx(
Word32 x[], /* i/o: signal to be delayed */
const Word16 len, /* i : length of the input signal */
@@ -4137,30 +4078,6 @@ void v_shr_16(
return;
}
-/*-------------------------------------------------------------------*
- * delay_signal()
- *
- * Delay buffer by defined number of samples
- *-------------------------------------------------------------------*/
-
-void delay_signal32(
- Word32 x[], /* i/o: signal to be delayed */
- const Word16 len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const Word16 delay /* i : delay in samples */
-)
-{
- Word32 tmp_buffer[L_FRAME48k];
-
- Copy32( mem, tmp_buffer, delay );
- Copy32( x + sub( len, delay ), mem, delay );
- Copy32( x, x + delay, sub( len, delay ) );
- Copy32( tmp_buffer, x, delay );
-
- return;
-}
-
-
/*---------------------------------------------------------------------*
* lin_interp_fx()
*
diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c
index d4792fb7517c940a9244a9cc51089d14137b636a..6a3cdf108733bc3601d87d7398f6686087eae3cf 100644
--- a/lib_com/trans_direct_fx.c
+++ b/lib_com/trans_direct_fx.c
@@ -40,9 +40,7 @@ void direct_transform_fx(
Word16 shift, Qmin = 31;
Word32 L_tmp;
Word16 Qs[NUM_TIME_SWITCHING_BLOCKS];
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) ( element_mode );
-#endif
move16();
segment_length = shr( L, 1 );
diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c
index fbe0f0d6ddd6910eabb38ed912be67dad0d819a3..0683e266ce67faea01f2768f6b51a98bd56f3ab4 100644
--- a/lib_com/trans_inv_fx.c
+++ b/lib_com/trans_inv_fx.c
@@ -84,7 +84,9 @@ void preecho_sb_fx(
UWord16 tmp_u16;
Word32 mean_prev_hb_fx_loc, mean_prev_nc_fx_loc, mean_prev_fx_loc; /* */
Word16 q16p1, qmemp1, qtmp;
-
+#ifdef OPT_STEREO_32KBPS_V1
+ Word16 shift_q = sub( 15, q_sig32 );
+#endif /* OPT_STEREO_32KBPS_V1 */
q16p1 = add( q_sig16, 1 );
qmemp1 = q16p1;
@@ -137,6 +139,18 @@ void preecho_sb_fx(
/* len3xLp20 = framelength/2-(short)((float)framelength*N_ZERO_MDCT/FRAME_SIZE_MS); in float*/
fxptr1 = imdct_mem_fx;
+#ifdef OPT_STEREO_32KBPS_V1
+ FOR( i = 0; i < len3xLp20; i++ )
+ {
+ *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[len3xLp20 - 1 - i], shift_q ) ) ); /*Q-1*/
+ move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */
+ }
+ FOR( i = 0; i < framelength >> 1; i++ )
+ {
+ *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], shift_q ) ) ); /*Q-1*/
+ move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */
+ }
+#else /* OPT_STEREO_32KBPS_V1 */
fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; /*q_sig32*/
FOR( i = 0; i < len3xLp20; i++ )
{
@@ -148,7 +162,10 @@ void preecho_sb_fx(
*fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], sub( 15, q_sig32 ) ) ) ); /*Q-1*/
move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */
}
+#endif /* OPT_STEREO_32KBPS_V1 */
+
qmemp1 = 0; /*already in q-1*/
+ move16();
subframelength = shr( framelength, LOG2_NUMSF ); /*Q0*/
subsubframelength = shr( subframelength, log2_num_subsubframes ); /*Q0*/
@@ -391,6 +408,17 @@ void preecho_sb_fx(
move16();
FOR( i = 1; i <= NUMSF; i++ )
{
+#ifdef OPT_STEREO_32KBPS_V1
+ max_es_hb_fx = L_max( max_es_hb_fx, es_mdct_hb_fx[i] ); /* max energy low band, 8 present and 1 future subframes */
+
+ max_es_fx = L_max( max_es_fx, es_mdct_fx[i] ); /* max energy low band, 8 present and 1 future subframes */
+
+ if ( GE_32( es_mdct_fx[i], max_es_fx ) ) /* '=' to handle the first window*/
+ {
+ maxind = i;
+ move16();
+ }
+#else /* OPT_STEREO_32KBPS_V1 */
IF( GE_32( es_mdct_hb_fx[i], max_es_hb_fx ) ) /* '=' to handle the first window*/
{
max_es_hb_fx = L_add( es_mdct_hb_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */
@@ -402,6 +430,7 @@ void preecho_sb_fx(
maxind = i;
move16();
}
+#endif /* OPT_STEREO_32KBPS_V1 */
}
cnt2 = cnt5 = 0;
@@ -486,11 +515,7 @@ void preecho_sb_fx(
tmp_fx1 = norm_l( es_mdct_hb_fx[i] );
tmp_fxL1 = L_shl( es_mdct_hb_fx[i], tmp_fx1 );
tmp_fxL2 = L_shl( mean_prev_hb_fx_loc, tmp_fx1 );
-#ifdef FIX_1013_CRASH_HQ_CORE_DEC
tmp_fx1 = round_fx_sat( tmp_fxL1 );
-#else
- tmp_fx1 = round_fx( tmp_fxL1 );
-#endif
tmp_fx2 = round_fx( tmp_fxL2 );
tmp_fx3 = div_s( tmp_fx2, tmp_fx1 );
min_g_hb_fx[i] = Frac_sqrt( tmp_fx3 );
@@ -967,9 +992,7 @@ void Inverse_Transform(
Word16 segment_length_div2, segment_length_div4;
Word16 tmp, q_out;
Word32 L_temp;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) ( element_mode );
-#endif
/* This value is used to right shift all vectors returned by 'iedct_short_fx()' */
/* to bring them to a scaling that is equal to the 1st 'Q' returned by the 1st */
/* call to 'iedct_short_fx()' minus these guard bits. */
diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c
index 19725735ae1d549aecbf4640c6f70f9747a88525..2948e725ecdb0ca7d1add2a05b91500c4b2b8aaa 100644
--- a/lib_com/window_ola_fx.c
+++ b/lib_com/window_ola_fx.c
@@ -833,13 +833,13 @@ void core_switching_OLA_fx(
IF( ( output_frame - L_FRAME16k ) == 0 ) /* no resampling */
{
- Copy( mem_over_hp + 2, tmp_buf_switch + i_mult2( SWITCH_GAP_LENGTH_8k, delta ), NS2SA( output_Fs, DELAY_CLDFB_NS ) );
+ Copy( mem_over_hp + 2, tmp_buf_switch + i_mult2( SWITCH_GAP_LENGTH_8k, delta ), NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) );
}
ELSE
{
IF( ( output_frame - L_FRAME8k ) == 0 ) /* not done yet */
{
- Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */
+ Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */
}
ELSE
{
@@ -950,7 +950,7 @@ void core_switching_OLA_fx(
pt = synth;
pt2 = tmp_buf_switch;
- tmp = NS2SA( output_Fs, DELAY_CLDFB_NS );
+ tmp = NS2SA_FX2( output_Fs, DELAY_CLDFB_NS );
move16();
pt3 = synth_subfr_bwe;
diff --git a/lib_com/wtda.c b/lib_com/wtda.c
index a7ea5314c916b07875136020956b2a30358d72ad..3fb40813816c7b4462bdcc3ec82b8df2314fb845 100644
--- a/lib_com/wtda.c
+++ b/lib_com/wtda.c
@@ -37,11 +37,10 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include
#include "wmc_auto.h"
-#include "prot_fx.h"
void wtda_fx32(
diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c
deleted file mode 100644
index 186a22bc75bec0db781564f277a699daf377adc3..0000000000000000000000000000000000000000
--- a/lib_dec/ACcontextMapping_dec.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "ivas_rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h" /* Range coder header file */
-#include
diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c
index 34e74a06f9ae9d5f1838d46efb8007cec71a00d8..22e9fff0114f1f5c0d3b5057744a446f95a0a0bb 100644
--- a/lib_dec/ACcontextMapping_dec_fx.c
+++ b/lib_dec/ACcontextMapping_dec_fx.c
@@ -12,7 +12,6 @@
#include "prot_fx.h"
#include "ivas_prot_fx.h"
-#include "ivas_prot.h"
#include "ivas_rom_com.h"
/*-------------------------------------------------------------------*
* ACcontextMapping_decode2_no_mem_s17_LC()
diff --git a/lib_dec/FEC.c b/lib_dec/FEC.c
deleted file mode 100644
index 3dd25fd27f419e7d83635ac506c7ad158b197333..0000000000000000000000000000000000000000
--- a/lib_dec/FEC.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "rom_dec.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-
-#define WMC_TOOL_SKIP
-/*-------------------------------------------------------------------*
- * pulseRes_preCalc()
- *
- * calculates some conditions for Pulse resynchronization to take place
- *-------------------------------------------------------------------*/
-
-#undef WMC_TOOL_SKIP
diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c
deleted file mode 100644
index 6a119b365552212f9ae48f4a3e4c760f9d226dac..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_HQ_core.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_dec.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-
-void save_synthesis_hq_fec_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word32 output_fx[], /* i : decoded synthesis */
- const Word16 output_frame, /* i : decoded synthesis */
- CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
-)
-{
- Word16 post_hq_delay;
-
- SWITCH( st->element_mode )
- {
- case EVS_MONO:
- post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS );
- BREAK;
- case IVAS_SCE:
- post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS );
- BREAK;
- case IVAS_CPE_DFT:
- test();
- IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
- {
- post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS );
- }
- ELSE
- {
- post_hq_delay = 0;
- move16();
- }
- BREAK;
- default:
- post_hq_delay = 0;
- move16();
- BREAK;
- }
-
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) )
- {
- Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) );
- FOR( Word16 i = 0; i < output_frame; i++ )
- {
- st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16
- move16();
- }
-
- IF( st->element_mode == EVS_MONO )
- {
- /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill
- this buffer are not available for all cases, the impact on the output is limited */
-
- set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay );
- IF( GE_16( output_frame, L_FRAME16k ) )
- {
- Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
- }
- ELSE
- {
- Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
- }
-
- IF( st->core != ACELP_CORE )
- {
- IF( GE_16( output_frame, L_FRAME16k ) )
- {
- Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) );
- Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
- }
- ELSE
- {
- Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) );
- Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
- }
- }
- }
- ELSE
- {
- IF( st->core != ACELP_CORE )
- {
- Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay );
- Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
- }
- }
- }
- return;
-}
diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c
index f88927ee50f3d5ee6c7d6a412805ee7e9fe9151e..cc03dcf525f424e500118ee9f8d2362c74ebedd3 100644
--- a/lib_dec/FEC_HQ_core_fx.c
+++ b/lib_dec/FEC_HQ_core_fx.c
@@ -725,10 +725,9 @@ void HQ_FEC_Mem_update_fx(
move32();
#endif
move32(); // tmp_energy_fx
-#ifdef ADD_IVAS_HQ_CODE_FEC
+
IF( EQ_16( output_frame, L_FRAME8k ) )
{
-#endif
IF( is_transient )
{
@@ -759,226 +758,222 @@ void HQ_FEC_Mem_update_fx(
}
}
}
-#ifndef ADD_IVAS_HQ_CODE_FEC
- IF( EQ_16( output_frame, L_FRAME8k ) )
- {
-#endif
- /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */
- test();
- IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) )
- {
- /* First group */
- logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
- j = ynrm[0];
- move16();
- offset = WID_G1;
- move16();
- FOR( i = 1; i < SFM_G1; i++ )
- {
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
- offset = add( offset, WID_G1 );
- }
+ /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */
+ test();
+ IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) )
+ {
+ /* First group */
+ logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ j = ynrm[0];
+ move16();
+ offset = WID_G1;
+ move16();
- /* Second group */
- FOR( i = SFM_G1; i < SFM_G1 + 2; i++ )
- {
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
- offset = add( offset, WID_G2 );
- }
+ FOR( i = 1; i < SFM_G1; i++ )
+ {
+ logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ offset = add( offset, WID_G1 );
}
- /* Memory update for the LGF log2 Norm */
- FOR( i = 0; i < nb_sfm; i++ )
+ /* Second group */
+ FOR( i = SFM_G1; i < SFM_G1 + 2; i++ )
{
- normq_fx[i] = dicn_fx[ynrm[i]];
- move32();
+ logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ offset = add( offset, WID_G2 );
}
- k = 0;
- move16();
- FOR( i = 0; i < num_Sb; i++ )
- {
- norm_values_fx = &hHQ_nbfec->ynrm_values_fx[i][0];
- Copy32( norm_values_fx, &norm_values_fx[1], MAX_PGF - 1 );
+ }
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < Num_bands_p[i]; j++ )
- {
- L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
- k = add( k, 1 );
- }
- tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/
- norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/
- move32();
- tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/
+ /* Memory update for the LGF log2 Norm */
+ FOR( i = 0; i < nb_sfm; i++ )
+ {
+ normq_fx[i] = dicn_fx[ynrm[i]];
+ move32();
+ }
+ k = 0;
+ move16();
+ FOR( i = 0; i < num_Sb; i++ )
+ {
+ norm_values_fx = &hHQ_nbfec->ynrm_values_fx[i][0];
+ Copy32( norm_values_fx, &norm_values_fx[1], MAX_PGF - 1 );
+
+ L_tmp = L_deposit_l( 0 );
+ FOR( j = 0; j < Num_bands_p[i]; j++ )
+ {
+ L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
+ k = add( k, 1 );
}
- test();
- test();
- IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
+ tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/
+ norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/
+ move32();
+ tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/
+ }
+ test();
+ test();
+ IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
+ {
+ FOR( i = 0; i < MAX_SB_NB; i++ )
{
- FOR( i = 0; i < MAX_SB_NB; i++ )
+ FOR( j = 1; j < MAX_PGF; j++ )
{
- FOR( j = 1; j < MAX_PGF; j++ )
- {
- hHQ_nbfec->ynrm_values_fx[i][j] = hHQ_nbfec->ynrm_values_fx[i][0];
- move32();
- }
+ hHQ_nbfec->ynrm_values_fx[i][j] = hHQ_nbfec->ynrm_values_fx[i][0];
+ move32();
}
}
- set16_fx( hHQ_nbfec->Norm_gain_fx, 32767, SFM_N_NB ); /*15*/
- /* st->energy_MA_Curr[1]=Energy of the current frame */
- tmp_fx = inv_tbl_fx[nb_sfm];
- move16(); /*15*/
- L_tmp = Mult_32_16( tmp_energy_fx, tmp_fx ); /*8 + 15 - 15*/
+ }
+ set16_fx( hHQ_nbfec->Norm_gain_fx, 32767, SFM_N_NB ); /*15*/
+ /* st->energy_MA_Curr[1]=Energy of the current frame */
+ tmp_fx = inv_tbl_fx[nb_sfm];
+ move16(); /*15*/
+ L_tmp = Mult_32_16( tmp_energy_fx, tmp_fx ); /*8 + 15 - 15*/
- hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl_sat( L_tmp, 16 - 8 ) );
- move16();
- /* Moving Average */
- hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) );
- move16();
+ hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl_sat( L_tmp, 16 - 8 ) );
+ move16();
+ /* Moving Average */
+ hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) );
+ move16();
+
+ /*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */
+ hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) );
+ move16();
+ exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 );
+ exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] );
+ hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) );
+ move16();
+ exp = add( 15, sub( exp1, exp2 ) );
+ hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/
+ move16();
- /*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */
- hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) );
+ /* Classify the stationary mode : 12% */
+ IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) )
+ {
+ stat_mode_curr = 1;
move16();
- exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 );
- exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] );
- hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) );
+ }
+ ELSE
+ {
+ stat_mode_curr = 0;
move16();
- exp = add( 15, sub( exp1, exp2 ) );
- hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/
+ }
+
+ /* Apply Hysteresis to prevent frequent mode changing */
+ if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
+ {
+ hHQ_nbfec->stat_mode_out = stat_mode_curr;
move16();
+ }
- /* Classify the stationary mode : 12% */
- IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) )
- {
- stat_mode_curr = 1;
- move16();
- }
- ELSE
- {
- stat_mode_curr = 0;
- move16();
- }
+ hHQ_nbfec->stat_mode_old = stat_mode_curr;
+ move16();
- /* Apply Hysteresis to prevent frequent mode changing */
- if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
+ /* Find max. band index (Minimum value means maximum energy) */
+ Min_ind = 0;
+ move16();
+ Min_value = L_deposit_l( 100 );
+ FOR( i = 0; i < num_Sb; i++ )
+ {
+ IF( GT_32( Min_value, ynrm[i] ) )
{
- hHQ_nbfec->stat_mode_out = stat_mode_curr;
+ Min_value = ynrm[i];
+ move16();
+ Min_ind = i;
move16();
}
+ }
- hHQ_nbfec->stat_mode_old = stat_mode_curr;
- move16();
-
- /* Find max. band index (Minimum value means maximum energy) */
- Min_ind = 0;
- move16();
- Min_value = L_deposit_l( 100 );
- FOR( i = 0; i < num_Sb; i++ )
+ /* Find max. coeff in band 0 */
+ Max_ind = 0;
+ move16();
+ IF( Min_ind == 0 )
+ {
+ Max_coeff_fx = L_deposit_l( 0 );
+ FOR( i = 0; i < 8; i++ )
{
- IF( GT_32( Min_value, ynrm[i] ) )
+ L_tmp = L_abs( t_audio_q_fx[i] );
+ IF( LT_32( Max_coeff_fx, L_tmp ) )
{
- Min_value = ynrm[i];
- move16();
- Min_ind = i;
+ Max_coeff_fx = L_add( L_tmp, 0 );
+ Max_ind = i;
move16();
}
}
+ }
- /* Find max. coeff in band 0 */
- Max_ind = 0;
- move16();
- IF( Min_ind == 0 )
- {
- Max_coeff_fx = L_deposit_l( 0 );
- FOR( i = 0; i < 8; i++ )
- {
- L_tmp = L_abs( t_audio_q_fx[i] );
- IF( LT_32( Max_coeff_fx, L_tmp ) )
- {
- Max_coeff_fx = L_add( L_tmp, 0 );
- Max_ind = i;
- move16();
- }
- }
- }
+ /* Find energy difference from band 16 */
+ k = 1;
+ move16();
- /* Find energy difference from band 16 */
- k = 1;
+ FOR( i = k; i < num_Sb; i++ )
+ {
+ en_high_fx[i] = L_deposit_l( 0 );
move16();
-
- FOR( i = k; i < num_Sb; i++ )
+ FOR( j = 0; j < 2; j++ )
{
- en_high_fx[i] = L_deposit_l( 0 );
- move16();
- FOR( j = 0; j < 2; j++ )
- {
- /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/
- en_high_fx[i] = L_add( en_high_fx[i], L_shr( hHQ_nbfec->ynrm_values_fx[i][j + 1], 1 ) ); /*Q12*/
- move32();
- }
+ /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/
+ en_high_fx[i] = L_add( en_high_fx[i], L_shr( hHQ_nbfec->ynrm_values_fx[i][j + 1], 1 ) ); /*Q12*/
+ move32();
}
+ }
- *mean_en_high_fx = 0;
- move16();
- FOR( i = k; i < num_Sb; i++ )
- {
- /* *mean_en_high += (float)(en_high[i]/st->ynrm_values[i][0]);*/
- exp1 = sub( norm_l( en_high_fx[i] ), 1 );
- exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
- tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
- exp = add( 15, sub( exp1, exp2 ) );
- *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow );
- move16();
- }
- *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
+ *mean_en_high_fx = 0;
+ move16();
+ FOR( i = k; i < num_Sb; i++ )
+ {
+ /* *mean_en_high += (float)(en_high[i]/st->ynrm_values[i][0]);*/
+ exp1 = sub( norm_l( en_high_fx[i] ), 1 );
+ exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
+ tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
+ exp = add( 15, sub( exp1, exp2 ) );
+ *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow );
move16();
+ }
+ *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
+ move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) && EQ_16( st_fx->last_core, HQ_CORE ) )
+ {
+ hHQ_nbfec->phase_mat_flag = 1;
+ move16();
test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) && EQ_16( st_fx->last_core, HQ_CORE ) )
- {
- hHQ_nbfec->phase_mat_flag = 1;
- move16();
- test();
- if ( Min_ind == 0 && ( LT_16( Max_ind, 3 ) ) )
- {
- hHQ_nbfec->phase_mat_flag = 0;
- move16();
- }
- }
- ELSE
+ if ( Min_ind == 0 && ( LT_16( Max_ind, 3 ) ) )
{
hHQ_nbfec->phase_mat_flag = 0;
move16();
}
-
- hHQ_nbfec->old_Min_ind = Min_ind;
+ }
+ ELSE
+ {
+ hHQ_nbfec->phase_mat_flag = 0;
move16();
}
+ hHQ_nbfec->old_Min_ind = Min_ind;
+ move16();
+
+
FOR( i = 0; i < L_FRAME8k; i++ )
{
hHQ_nbfec->old_coeffs_fx[i] = t_audio_q_fx[i];
move32();
}
-
- hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1];
- move16();
- hHQ_core->old_is_transient[1] = hHQ_core->old_is_transient[0];
- move16();
- hHQ_core->old_is_transient[0] = is_transient;
- move16();
-#ifdef ADD_IVAS_HQ_CODE_FEC
}
-#endif
+
+ hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1];
+ move16();
+ hHQ_core->old_is_transient[1] = hHQ_core->old_is_transient[0];
+ move16();
+ hHQ_core->old_is_transient[0] = is_transient;
+ move16();
+
return;
}
@@ -1961,89 +1956,105 @@ static void Next_good_after_burst_erasures_fx(
return;
}
-#ifdef ADD_IVAS_HQ_CODE_FEC
/*--------------------------------------------------------------------------
- * save_synthesis_hq_fec()
+ * save_synthesis_hq_fec_fx()
*
* Save synthesis for HQ FEC
*-------------------------------------------------------------------------*/
-void save_synthesis_hq_fec(
- Decoder_State *st, /* i/o: decoder state structure */
- const float *output, /* i : decoded synthesis */
- const int16_t output_frame, /* i : decoded synthesis */
- CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
+void save_synthesis_hq_fec_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word16 synth_fx[], /* i : decoded synthesis (EVS) */
+ const Word32 output_fx[], /* i : decoded synthesis */
+ const Word16 output_frame, /* i : decoded synthesis */
+ const Word16 Qpostd, /* i : Q value of delayed signal */
+ CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
)
{
- int16_t post_hq_delay;
+ Word16 post_hq_delay;
- switch ( st->element_mode )
+ SWITCH( st->element_mode )
{
case EVS_MONO:
- post_hq_delay = NS2SA( st->output_Fs, POST_HQ_DELAY_NS );
- break;
+ post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS );
+ BREAK;
case IVAS_SCE:
- post_hq_delay = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
- break;
+ post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS );
+ BREAK;
case IVAS_CPE_DFT:
- if ( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
{
- post_hq_delay = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
+ post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS );
}
- else
+ ELSE
{
post_hq_delay = 0;
+ move16();
}
- break;
+ BREAK;
default:
post_hq_delay = 0;
- break;
+ move16();
+ BREAK;
}
-
- if ( ( st->codec_mode == MODE1 && st->hTcxDec != NULL ) && ( ( st->core == ACELP_CORE && !( st->bfi == 1 && st->con_tcx == 1 ) ) || st->core == HQ_CORE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) )
{
- mvr2r( st->hTcxDec->synth_history + output_frame, st->hTcxDec->synth_history, output_frame - post_hq_delay + NS2SA( st->output_Fs, PH_ECU_MEM_NS ) );
- mvr2r( output, st->hTcxDec->old_synthFB + output_frame - post_hq_delay, output_frame );
-
- if ( st->element_mode == EVS_MONO )
+ IF( st->element_mode == EVS_MONO )
{
+ Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); /*hTcxDec->q_synth_history_fx*/
+ Copy_Scale_sig( synth_fx, st->hTcxDec->old_synthFB_fx + sub( output_frame, post_hq_delay ), output_frame, negate( Qpostd ) ); /* output_sp not initialized yet */
/* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill
this buffer are not available for all cases, the impact on the output is limited */
- set_f( st->hTcxDec->old_synthFB + 2 * output_frame - post_hq_delay, 0.f, post_hq_delay );
- if ( output_frame >= L_FRAME16k )
+ set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay );
+
+ IF( GE_16( output_frame, L_FRAME16k ) )
{
- mvr2r( st->prev_synth_buffer, st->hTcxDec->old_synthFB + 2 * output_frame - NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
+ Copy_Scale_sig( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( st->Qprev_synth_buffer_fx ) ); /*Q0*/
}
+ /* IVAS Floating point code has the commented-out else branch below, but it does not appear to be necessary. To be verified
else
{
mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB + 2 * output_frame, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
+ */
- if ( st->core != ACELP_CORE )
+ IF( st->core != ACELP_CORE )
{
- if ( output_frame >= L_FRAME16k )
+ IF( GE_16( output_frame, L_FRAME16k ) )
{
- mvr2r( st->delay_buf_out, st->hTcxDec->old_synthFB + 2 * output_frame - NS2SA( st->output_Fs, DELAY_CLDFB_NS ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) );
- mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB + 2 * output_frame, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ Copy_Scale_sig( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/
+ Copy_Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( st->hHQ_core->Q_old_wtda ) ); /*Q0*/
}
- else
+ ELSE
{
- mvr2r( st->delay_buf_out, st->hTcxDec->old_synthFB + 2 * output_frame - NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) );
- mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB + 2 * output_frame - NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+
+ Copy_Scale_sig( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/
+ Copy_Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( st->hHQ_core->Q_old_wtda ) ); /*Q0*/
}
}
}
- else
+ ELSE
{
- if ( st->core != ACELP_CORE )
+ Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) );
+ FOR( Word16 i = 0; i < output_frame; i++ )
{
- mvr2r( st->delay_buf_out, st->hTcxDec->old_synthFB + 2 * output_frame - post_hq_delay, post_hq_delay );
- mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB + 2 * output_frame, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16
+ move16();
+ }
+
+ IF( st->core != ACELP_CORE )
+ {
+ Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay );
+ Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
}
}
-
return;
}
-#endif
diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c
deleted file mode 100644
index 85b25b3369f0737666a24b05d1687290a62fce41..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_HQ_phase_ecu.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "rom_dec.h"
-#include "rom_com.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c
index 708fc39e6544f87830590ccc9a2c584121938d50..ef09c3de3272be34c95156d3f9d7d17033284ec2 100644
--- a/lib_dec/FEC_HQ_phase_ecu_fx.c
+++ b/lib_dec/FEC_HQ_phase_ecu_fx.c
@@ -1590,11 +1590,7 @@ static void ivas_spec_ana_fx(
test();
IF( n > 0 && *pPlocs == 0 ) /* Very 1st peak position possible to have a peak at 0/DC index position. */
{
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs], xfp_32, 3, Q15 ); // Q + 15
-#else
- Copy_Scale_sig_16_32_DEPREC( &xfp[*pPlocs], xfp_32, 3, Q16 ); // Q + 16
-#endif
+ Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs], xfp_32, 3, Q15 ); // Q + 15
acc = L_deposit_h( *pPlocs ); // Q16
*pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16
move32();
@@ -1605,11 +1601,7 @@ static void ivas_spec_ana_fx(
test();
IF( n > 0 && EQ_16( *pPlocs, 1 ) ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */
{
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs - 1], xfp_32, 3, Q15 ); // Q + 15
-#else
- Copy_Scale_sig_16_32_DEPREC( &xfp[*pPlocs - 1], xfp_32, 3, Q16 ); // Q + 16
-#endif
+ Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs - 1], xfp_32, 3, Q15 ); // Q + 15
acc = L_deposit_h( sub( *pPlocs, 1 ) ); // Q16
*pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16
move32();
@@ -1655,11 +1647,7 @@ static void ivas_spec_ana_fx(
IF( EQ_16( currPlocs, ( sub( Lprot2_1, DELTA_CORR_F0_INT ) ) ) ) /* Also 2nd last peak position uses fs/2 which makes jacobsen less suitable. */
{
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 1], xfp_32, 3, Q15 ); // Q + 15
-#else
- Copy_Scale_sig_16_32_DEPREC( &xfp[currPlocs - 1], xfp_32, 3, Q16 ); // Q + 16
-#endif
+ Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 1], xfp_32, 3, Q15 ); // Q + 15
acc = L_deposit_h( sub( currPlocs, 1 ) ); // Q16
*pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16
move32();
@@ -1673,11 +1661,7 @@ static void ivas_spec_ana_fx(
* whould point */
IF( n > 0 ) /* fs/2 which makes special case . */
{
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 2], xfp_32, 3, Q15 ); // Q + 15
-#else
- Copy_Scale_sig_16_32_DEPREC( &xfp[currPlocs - 2], xfp_32, 3, Q16 ); // Q + 16
-#endif
+ Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 2], xfp_32, 3, Q15 ); // Q + 15
acc = L_deposit_h( sub( currPlocs, 2 ) ); // Q16
*pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16
move32();
@@ -2156,7 +2140,7 @@ static void ivas_subst_spec_fx(
ELSE
{
// tmp = NS2SA(output_frame*50,PH_ECU_ALDO_OLP2_NS-PH_ECU_LOOKAHEAD_NS);
- tmp = NS2SA_FX2( output_frame * 50, PH_ECU_ALDO_OLP2_NS );
+ tmp = NS2SA_FX2( L_mult0( output_frame, 50 ), PH_ECU_ALDO_OLP2_NS );
move16();
tmp = sub( tmp, ph_ecu_lookahead );
tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) );
@@ -2559,7 +2543,7 @@ static void subst_spec_fx(
}
ELSE
{
- tmp = NS2SA( output_frame * 50, PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS );
+ tmp = NS2SA_FX2( L_mult0( output_frame, 50 ), PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS );
move16();
tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) );
tmp = sub( tmp, shr( output_frame, 1 ) );
@@ -2920,9 +2904,9 @@ static void ivas_rec_wtda_fx(
Word16 copy_len;
Word16 ola_len;
- copy_len = NS2SA( output_frame * FRAMES_PER_SEC, ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */
+ copy_len = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */
move16();
- ola_len = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */
+ ola_len = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */
move16();
xf_len = 26;
@@ -2980,7 +2964,7 @@ static void ivas_rec_wtda_fx(
}
/* extract reconstructed frame with aldo window */
- timesh = sub( NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) );
+ timesh = sub( NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) );
set16_fx( xsubst_, 0, add( sub( shl( output_frame, 1 ), Lprot ), timesh ) );
Copy( X, xsubst_ + add( sub( shl( output_frame, 1 ), Lprot ), timesh ), sub( Lprot, timesh ) );
@@ -2988,9 +2972,9 @@ static void ivas_rec_wtda_fx(
/* Copy and OLA look ahead zero part of MDCT window from decoded signal */
IF( element_mode != EVS_MONO )
{
- Copy( old_dec, xsubst_ + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */
+ Copy( old_dec, xsubst_ + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */
pOld = old_dec + copy_len;
- pNew = xsubst_ + add( copy_len, NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) );
+ pNew = xsubst_ + add( copy_len, NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ) );
tmp = div_s( 1, shl( ola_len, 1 ) ); // Q15
tmp = round_fx( L_shl( L_mult( tmp, EVS_PI_FX ), 2 ) ); // Q15
sinq_fx( tmp, 0, ola_len, xfwin );
@@ -4005,11 +3989,7 @@ static void ivas_fec_ecu_dft_fx(
tmp = Exp16Array( *Nfft, Tfr16 );
*exp = add( tmp, add( 2, norm_s( *Nfft ) ) );
move16();
-#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */
-#else
- Copy_Scale_sig_16_32_DEPREC( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */
-#endif
*exp = s_min( *exp, 15 );
DoRTFTn_fx( Tfr32, Tfi32, *Nfft );
@@ -4125,20 +4105,12 @@ static void fec_ecu_dft_fx(
tmp = Exp16Array( *Nfft, Tfr16 );
*exp = add( tmp, add( 2, norm_s( *Nfft ) ) );
move16();
-#ifdef FIX_ISSUE_1237
{
-#ifdef FIX_ISSUE_1237_KEEP_EVS_BE
Word16 loctmp = *exp;
move16();
loctmp = s_min( 15, loctmp );
Copy_Scale_sig_16_32_DEPREC( Tfr16, Tfr32, *Nfft, loctmp ); /*Qin+exp; */ /*Even with limiting loctmp, if Copy_Scale_sig_16_32_no_sat() is used, can lead to 1 difference */
-#else
- Copy_Scale_sig_16_32_no_sat( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */
-#endif
}
-#else
- Copy_Scale_sig_16_32_DEPREC( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */
-#endif
DoRTFTn_fx( Tfr32, Tfi32, *Nfft );
N_LP = shr( *Nfft, 1 );
@@ -4583,7 +4555,7 @@ static void ivas_fec_noise_filling_fx(
}
ELSE
{
- kk = NS2SA( L * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
+ kk = NS2SA_FX2( L_mult0( L, FRAMES_PER_SEC ), N_ZERO_MDCT_NS );
p_mdct_ola = old_out + kk;
}
@@ -4593,13 +4565,13 @@ static void ivas_fec_noise_filling_fx(
pt6 = &p_mdct_ola[0];
FOR( k = 0; k < tmp_fx; k++ )
{
- L_tmp = L_mult( *sinq_tab, *sinq_tab ); /*Q30 */
+ L_tmp = L_mult( *sinq_tab, *sinq_tab ); /*Q31 */
sinq_tab++;
- q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */
- q1 = round_fx( L_tmp ); /*Q15 */
- L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */
- L_tmp = L_mac( L_tmp, shr( *pt6++, Q_old_out ), q2 ); /*Qsynth+16 */
- ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */
+ q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */
+ q1 = round_fx( L_tmp ); /*Q15 */
+ L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */
+ L_tmp = L_add_sat( L_tmp, L_shr_sat( Mpy_32_16_1( L_deposit_h( *pt6++ ), q2 ), Q_old_out ) ); /*Qsynth+16 */
+ ( *pt1++ ) = round_fx_sat( L_tmp ); /*Qsynth */
move16();
}
@@ -4939,7 +4911,7 @@ static void ivas_hq_phase_ecu_fx(
IF( element_mode == EVS_MONO )
{
- ph_ecu_lookahead = NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS );
+ ph_ecu_lookahead = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS );
move16();
}
ELSE
@@ -5018,7 +4990,7 @@ static void ivas_hq_phase_ecu_fx(
alpha, beta, *beta_mute, Xavg, element_mode, ph_ecu_lookahead, noise_fac );
/* reconstructed frame in tda domain */
- old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) );
+ old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ) );
ivas_rec_frame_fx( X, ecu_rec, output_frame, *Q_spec, old_dec, element_mode, num_p, plocs );
*last_fec = 0;
@@ -5223,11 +5195,11 @@ void ivas_hq_ecu_fx(
move16();
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
- fec_alg_input = prevsynth + NS2SA( output_frame * FRAMES_PER_SEC, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS );
+ fec_alg_input = prevsynth + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS );
}
ELSE
{
- fec_alg_input = prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS );
+ fec_alg_input = prevsynth - NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS );
}
/* init (values ar changed after) */
@@ -5286,7 +5258,7 @@ void ivas_hq_ecu_fx(
}
ELSE
{
- ivas_hq_phase_ecu_fx( prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, Q_spec, num_p, plocs, plocsi,
+ ivas_hq_phase_ecu_fx( prevsynth - NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, Q_spec, num_p, plocs, plocsi,
env_stab, last_fec, ph_ecu_active, prev_bfi, old_is_transient,
mag_chg_1st, Xavg, beta_mute, st_fx->bwidth, output_frame, corr, st_fx->element_mode );
@@ -5354,7 +5326,7 @@ void hq_ecu_fx(
#ifdef IVAS_FEC_ECU_TO_COMPLETE
fec_ecu_pitch_fx( fec_alg_input, prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing );
#else
- fec_ecu_pitch_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing );
+ fec_ecu_pitch_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing );
#endif
}
ELSE
@@ -5409,7 +5381,7 @@ void hq_ecu_fx(
( LT_32( st_fx->total_brate, 48000 ) && ( ( ph_ecu_HqVoicing || GT_16( corr, 27853 ) ) && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) ) ) )
{
- fec_alg_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth );
+ fec_alg_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth );
*last_fec = 1;
move16();
*ph_ecu_active = 0;
diff --git a/lib_dec/FEC_adapt_codebook.c b/lib_dec/FEC_adapt_codebook.c
deleted file mode 100644
index f07b5952aa50ba7b62d1e571859e7fe2e101e32e..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_adapt_codebook.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_dec.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------------
- * FEC_synchro_exc()
- *
- * Perform resynchronisation of the last glottal pulse in voiced frame lost
- *------------------------------------------------------------------------*/
-
-/*! r: do_WI flag */
diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c
deleted file mode 100644
index 77501d3fa8c08c7566e2f6454cb52558cb217597..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_clas_estim.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include "cnst.h"
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "rom_com.h"
-#include "stat_dec.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c
index 9b58084e36ef1cb0d935be70990bb95aa18d485a..e56a77be12f49bf6522a1b129d91eaa0edbe4bb9 100644
--- a/lib_dec/FEC_clas_estim_fx.c
+++ b/lib_dec/FEC_clas_estim_fx.c
@@ -82,7 +82,7 @@ void FEC_clas_estim_fx(
Word16 bfi,
/* i : bad frame indicator */ /*B*/
Word32 last_core_brate, /* i : bitrate of previous frame */
- const int16_t FEC_mode /* i : ACELP FEC mode */
+ const Word16 FEC_mode /* i : ACELP FEC mode */
)
{
Word16 i, j, pos;
diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c
index 35bb254af835011d3ec461752e47c43ee3c7b2f3..612816efd236c6ca1a51dcca0933ec4d1b7b6284 100644
--- a/lib_dec/FEC_fx.c
+++ b/lib_dec/FEC_fx.c
@@ -504,11 +504,7 @@ void FEC_exc_estim_fx(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( EQ_16( st_fx->last_coder_type, AUDIO ) || ( EQ_16( st_fx->last_good, INACTIVE_CLAS ) && st_fx->inactive_coder_type_flag && !st_fx->Opt_AMR_WB ) )
-#else
- IF( EQ_16( st_fx->last_coder_type, AUDIO ) || ( EQ_16( st_fx->last_good, INACTIVE_CLAS ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && !st_fx->Opt_AMR_WB ) )
-#endif
{
st_fx->GSC_noisy_speech = st_fx->Last_GSC_noisy_speech_flag;
move16();
@@ -670,11 +666,7 @@ void FEC_exc_estim_fx(
test();
test();
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( EQ_16( st_fx->last_coder_type, AUDIO ) || ( EQ_16( st_fx->last_good, INACTIVE_CLAS ) && st_fx->inactive_coder_type_flag && !st_fx->Opt_AMR_WB ) )
-#else
- IF( ( EQ_16( st_fx->last_coder_type, AUDIO ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && !st_fx->Opt_AMR_WB )
-#endif
{
/* For GSC - the excitation is already computed */
Copy( exc, exc2, st_fx->L_frame );
diff --git a/lib_dec/FEC_lsf_estim.c b/lib_dec/FEC_lsf_estim.c
deleted file mode 100644
index 49a4adafc6059bab49770c37cd8b67a4fb4c5d1a..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_lsf_estim.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * FEC_lsf2lsp_interp_flt()
- *
- * - LSP calculation
- * - A(z) calculation
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/FEC_pitch_estim.c b/lib_dec/FEC_pitch_estim.c
deleted file mode 100644
index bae1a853986494545af28286226a5759dddbd913..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_pitch_estim.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-
-#include
-#include "options.h"
-#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
deleted file mode 100644
index 5c3581f4f1c4bf43ac4c588aedcfcb74046e0acb..0000000000000000000000000000000000000000
--- a/lib_dec/FEC_scale_syn.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c
deleted file mode 100644
index 494df80ce227c53b8ee9f5aabff094efb6e747e7..0000000000000000000000000000000000000000
--- a/lib_dec/LD_music_post_filter.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "prot_fx.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c
deleted file mode 100644
index a8ad442c0829fae304c13c6d0b323fbbb722bd98..0000000000000000000000000000000000000000
--- a/lib_dec/TonalComponentDetection.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#define _USE_MATH_DEFINES
-
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "cnst.h"
-#include "stat_com.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h"
diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c
index ca7bec1408a10c55203b4a1990f6a7cc95bb71c8..e820f1399780d3fca13070925d67b8d76e443140 100644
--- a/lib_dec/TonalComponentDetection_fx.c
+++ b/lib_dec/TonalComponentDetection_fx.c
@@ -30,6 +30,7 @@ static void modifyThresholds( Word16 F0, Word16 origF0, Word16 *thresholdModific
static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification );
static void ivas_RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification );
static void findTonalComponents( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, Word16 F0, Word16 *thresholdModification, Word16 element_mode );
+static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, const Word16 powerSpectrum_e, Word16 F0, Word16 *thresholdModification, Word16 element_mode );
/*-------------------------------------------------------------------*
* DetectTonalComponents()
@@ -52,7 +53,8 @@ void ivas_DetectTonalComponents_fx(
const Word16 scaleFactors[],
const Word16 scaleFactors_exp[],
const Word16 scaleFactors_max_e,
- const Word32 secondLastPowerSpectrum[], /*Qx*/
+ const Word32 secondLastPowerSpectrum[], /*Q31-secondLastPowerSpectrum_e*/
+ const Word16 secondLastPowerSpectrum_e,
const Word16 nSamples,
const Word16 nSamplesCore,
Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/
@@ -74,13 +76,11 @@ void ivas_DetectTonalComponents_fx(
pScaledMdctSpectrum[i] = L_shl( lastMDCTSpectrum[i], 16 ); /*15-lastMDCTSpectrum_exp+16 -> 31 - lastMDCTSpectrum_exp*/
move32();
}
-#ifdef MSAN_FIX
FOR( Word16 i = 0; i < FDNS_NPTS; i++ )
{
sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16
move32();
}
-#endif
IF( psychParamsCurrent == NULL )
{
nBands = FDNS_NPTS;
@@ -92,12 +92,6 @@ void ivas_DetectTonalComponents_fx(
}
ELSE
{
-#ifndef MSAN_FIX
- FOR( Word16 i = 0; i < FDNS_NPTS; i++ )
- {
- sns_int_scf_fx[i] = L_shl( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16
- }
-#endif
q_pScaledMdctSpectrum = sub( 31, lastMDCTSpectrum_exp );
sns_shape_spectrum_fx( pScaledMdctSpectrum, &q_pScaledMdctSpectrum, psychParamsCurrent, sns_int_scf_fx, 16, nSamplesCore, NULL );
q_pScaledMdctSpectrum = add( q_pScaledMdctSpectrum, 1 );
@@ -127,7 +121,7 @@ void ivas_DetectTonalComponents_fx(
ivas_RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification );
/* Find peaks in the second last frame */
- findTonalComponents( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, F0, thresholdModification, element_mode );
+ ivas_findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode );
}
void DetectTonalComponents(
@@ -306,7 +300,8 @@ void ivas_RefineTonalComponents_fx(
const Word16 scaleFactors[],
const Word16 scaleFactors_exp[],
const Word16 scaleFactors_max_e,
- const Word32 secondLastPowerSpectrum[], /*Qx*/
+ const Word32 secondLastPowerSpectrum[], /*Q31-secondLastPowerSpectrum_e*/
+ const Word16 secondLastPowerSpectrum_e,
const Word16 nSamples,
const Word16 nSamplesCore,
const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/
@@ -322,7 +317,7 @@ void ivas_RefineTonalComponents_fx(
ivas_DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum,
- lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, nSamples, nSamplesCore, floorPowerSpectrum,
+ lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum,
psychParamsCurrent, element_mode );
nPreservedPeaks = 0;
@@ -1280,6 +1275,171 @@ static void RefineThresholdsUsingPitch(
return;
}
+static void ivas_findTonalComponents_fx(
+ Word16 *indexOfTonalPeak, /* OUT Q0*/
+ Word16 *lowerIndex, /* OUT Q0*/
+ Word16 *upperIndex, /* OUT Q0*/
+ Word16 *numIndexes, /* OUT Q0*/
+ Word16 nSamples, /* IN */
+ const Word32 *powerSpectrum, /* IN Q31-powerSpectrum_e*/
+ const Word16 powerSpectrum_e,
+ Word16 F0, /* IN */
+ Word16 *thresholdModification, /* IN Q10*/
+ Word16 element_mode ) /* IN */
+{
+ Word32 envelope[L_FRAME_MAX]; /*powerSpec_exp + LEVEL_EXP*/
+ Word32 smoothedSpectrum[L_FRAME_MAX]; /*powerSpec_exp + LEVEL_EXP*/
+ Word16 nrOfFIS;
+ Word16 upperIdx, lowerIdx, lowerBound;
+ Word16 k, j, m;
+ Word32 biggerNeighbor;
+ Word16 tmp_loop1, tmp_loop2, tmp_loop3;
+
+ getEnvelope( nSamples, powerSpectrum, F0, envelope, smoothedSpectrum );
+
+
+ nrOfFIS = 0;
+ move16();
+ lowerBound = 0;
+ move16();
+
+ k = GROUP_LENGTH / 2;
+ move16();
+ tmp_loop1 = sub( nSamples, ( GROUP_LENGTH - GROUP_LENGTH / 2 ) );
+ tmp_loop2 = sub( nSamples, 1 );
+ WHILE( LE_16( k, tmp_loop1 ) )
+ {
+ Word64 mult_64 = W_mult_32_16( envelope[k], thresholdModification[k] ); // (Q31-(powerSpectrum_e+LEVEL_EXP))+1+10
+ Word16 lshift = W_norm( mult_64 );
+ Word32 mult_32 = W_extract_h( W_shl( mult_64, lshift ) ); //(Q31-(powerSpectrum_e+LEVEL_EXP) + lshift )+11 -32
+ Word16 mult_exp = sub( Q31, sub( add( sub( Q31, add( powerSpectrum_e, LEVEL_EXP ) ), add( 10, lshift ) ), 31 ) );
+ Word16 flag = BASOP_Util_Cmp_Mant32Exp( smoothedSpectrum[k], ( powerSpectrum_e + LEVEL_EXP ), mult_32, mult_exp );
+ /* There is 3 bits headroom in envelope and max of thresholdModification is 16384, so shifting left for 4 would produce overflow only when the result is anyhow close to 1 */
+ IF( EQ_16( flag, 1 ) )
+ {
+ /* The check that bin at k is bigger than bins at k-1 and k+1 is needed to avoid deadlocks when the thresholds are low. */
+ /* It removes some true peaks, especially if non weighted sum is used for the smoothed spectrum. */
+ biggerNeighbor = L_max( powerSpectrum[k - 1], powerSpectrum[k + 1] ); /*Qx*/
+
+ IF( GE_32( powerSpectrum[k], biggerNeighbor ) )
+ {
+ /* Find the right foot */
+ upperIdx = add( k, 1 );
+ WHILE( LT_16( upperIdx, tmp_loop2 ) )
+ {
+ IF( LT_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx + 1] ) )
+ {
+ /* Side lobes may increase for certain amount */
+ IF( LT_32( L_shl( Mpy_32_16_1( powerSpectrum[upperIdx], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ), powerSpectrum[upperIdx + 1] ) )
+ {
+ BREAK;
+ }
+ /* Check for further decrease after a side lobe increase */
+ FOR( j = add( upperIdx, 1 ); j < tmp_loop2; j++ )
+ {
+ IF( LT_32( powerSpectrum[j], L_shl( Mpy_32_16_1( powerSpectrum[j + 1], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ) ) )
+ {
+ BREAK;
+ }
+ }
+ /* Side lobe increase must be 2 times smaller than the decrease to the foot */
+ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */
+ test();
+ test();
+ test();
+ IF( ( EQ_16( element_mode, EVS_MONO ) && GT_32( Mpy_32_32( L_shl( powerSpectrum[upperIdx + 1], 1 ), powerSpectrum[j] ), Mpy_32_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx] ) ) ) ||
+ ( NE_16( element_mode, EVS_MONO ) && ( GT_64( W_mult_32_32( L_shl( powerSpectrum[upperIdx + 1], 1 ), powerSpectrum[j] ), W_mult_32_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx] ) ) ) ) )
+ {
+ BREAK;
+ }
+ upperIdx = sub( j, 1 );
+ }
+ upperIdx = add( upperIdx, 1 );
+ }
+ /* left foot */
+ lowerIdx = sub( k, 1 );
+ WHILE( GT_16( lowerIdx, lowerBound ) )
+ {
+ IF( LT_32( powerSpectrum[lowerIdx], powerSpectrum[lowerIdx - 1] ) )
+ {
+ /* Side lobes may increase for certain amount */
+ IF( LT_32( L_shl( Mpy_32_16_1( powerSpectrum[lowerIdx], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ), powerSpectrum[lowerIdx - 1] ) )
+ {
+ BREAK;
+ }
+ /* Check for further decrease after a side lobe increase */
+ FOR( j = sub( lowerIdx, 1 ); j > 0; j-- )
+ {
+ IF( LT_32( powerSpectrum[j], L_shl( Mpy_32_16_1( powerSpectrum[j - 1], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ) ) )
+ {
+ BREAK;
+ }
+ }
+ /* Side lobe increase must be 2 times smaller than the decrease to the foot */
+ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */
+ IF( GT_32( Mpy_32_32( L_shl( powerSpectrum[lowerIdx - 1], 1 ), powerSpectrum[j] ), Mpy_32_32( powerSpectrum[lowerIdx], powerSpectrum[lowerIdx] ) ) )
+ {
+ BREAK;
+ }
+ lowerIdx = add( j, 1 );
+ }
+ lowerIdx = sub( lowerIdx, 1 );
+ }
+
+ lowerBound = upperIdx;
+ move16();
+
+ /* Check if there is a bigger peak up to the next peak foot */
+ tmp_loop3 = s_min( upperIdx, tmp_loop1 );
+ FOR( j = s_max( GROUP_LENGTH / 2, lowerIdx ); j <= tmp_loop3; j++ )
+ {
+ if ( GT_32( powerSpectrum[j], powerSpectrum[k] ) )
+ {
+
+ k = j;
+ move16();
+ }
+ }
+
+ assert( ( nrOfFIS == 0 ) || ( indexOfTonalPeak[nrOfFIS - 1] < k ) );
+
+ lowerIndex[nrOfFIS] = sub( k, GROUP_LENGTH / 2 );
+ move16();
+
+ upperIndex[nrOfFIS] = add( k, ( GROUP_LENGTH - GROUP_LENGTH / 2 - 1 ) );
+ move16();
+
+ test();
+ IF( ( nrOfFIS > 0 ) && ( LE_16( lowerIndex[nrOfFIS], upperIndex[nrOfFIS - 1] ) ) )
+ {
+ m = shr( add( k, indexOfTonalPeak[nrOfFIS - 1] ), 1 );
+ upperIndex[nrOfFIS - 1] = m;
+ move16();
+ lowerIndex[nrOfFIS] = add( m, 1 );
+ move16();
+ }
+
+ indexOfTonalPeak[nrOfFIS++] = k;
+ move16();
+
+ IF( EQ_16( nrOfFIS, MAX_NUMBER_OF_IDX ) )
+ {
+ BREAK;
+ }
+ /* Jump to the next foot of the peak. */
+ k = upperIdx;
+ move16();
+ }
+ }
+ k = add( k, 1 );
+ }
+
+ *numIndexes = nrOfFIS;
+ move16();
+ return;
+}
+
+
static void ivas_RefineThresholdsUsingPitch_fx(
const Word16 nSamples,
const Word16 nSamplesCore,
diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c
deleted file mode 100644
index 2374f1b7c3168fd81d10bc1050a230ab2b9ba4bf..0000000000000000000000000000000000000000
--- a/lib_dec/acelp_core_dec.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-
-#include
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "prot_fx.h"
-#include "ivas_cnst.h"
-#include "ivas_prot.h"
-#include "ivas_rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c
index 1b2207491020bd08416ac1c78f69aeef75ab491c..7a3c786448fbef596e0b6b44660224d4e66e8b4e 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -107,16 +107,12 @@ ivas_error acelp_core_dec_fx(
Word16 uc_two_stage_flag, dec;
Word16 nb_bits, indice;
Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
-#ifdef ADD_LRTD
- Word16 *p_tdm_Pri_pitch_buf;
-#endif
MUSIC_POSTFILT_HANDLE hMusicPF;
BPF_DEC_HANDLE hBPF;
TD_BWE_DEC_HANDLE hBWE_TD;
FD_BWE_DEC_HANDLE hBWE_FD;
TCX_DEC_HANDLE hTcxDec;
ivas_error error;
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) ( tdm_lspQ_PCh );
(void) ( tdm_lsfQ_PCh );
(void) ( use_cldfb_for_dft );
@@ -128,7 +124,6 @@ ivas_error acelp_core_dec_fx(
(void) ( output );
(void) ( read_sid_info );
(void) hStereoCng;
-#endif
hMusicPF = st_fx->hMusicPF;
hBPF = st_fx->hBPF;
hBWE_TD = st_fx->hBWE_TD;
@@ -146,66 +141,6 @@ ivas_error acelp_core_dec_fx(
return error;
}
-
-#ifdef IVAS_CODE
- output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC );
-
- /*----------------------------------------------------------------*
- * stereo SID and CNG frames processing
- *----------------------------------------------------------------*/
-
- if ( st->core_brate <= SID_2k40 && st->element_mode == IVAS_CPE_DFT && nchan_out == 2 )
- {
- if ( st->cng_type == FD_CNG )
- {
- configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
-
- /* Only run parameter decoding in SID frames */
- if ( st->core_brate == SID_2k40 )
- {
- FdCng_decodeSID_fx( st );
- }
-
- for ( i = 0; i < NPART; i++ )
- {
- st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i];
- }
-
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ApplyFdCng_fx( NULL, NULL, NULL, NULL, st, 0, 0 );
-#else
- ApplyFdCng_fx( NULL, NULL, NULL, NULL, st, 0, 0 );
-#endif
- }
- else
- {
- configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
-
- /* decode CNG parameters */
- CNG_dec( st, last_element_mode, Aq, lsp_new, lsf_new, &allow_cn_step, sid_bw, q_env );
-
- /* comfort noise generation */
- CNG_exc( st->core_brate, st->L_frame, &st->hTdCngDec->Enew, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->hTdCngDec->num_ho, q_env, st->hTdCngDec->lp_env, st->hTdCngDec->old_env, st->hTdCngDec->exc_mem, st->hTdCngDec->exc_mem1, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode );
-
- mvr2r( Aq, st->Aq_cng, M + 1 );
-
- /* update old LSP and LSF vector */
- mvr2r( lsf_new, st->lsf_old, M );
- mvr2r( lsp_new, st->lsp_old, M );
- }
-
- set_f( output, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
- set_f( synth, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
-
- /* CN generation done in DFT domain */
- wmops_sub_end();
- return error;
- }
-
- /*----------------------------------------------------------------*
- * Active frames processing
- *----------------------------------------------------------------*/
-#endif
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
@@ -268,13 +203,7 @@ ivas_error acelp_core_dec_fx(
move32();
}
}
-#ifdef IVAS_CODE
- if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) )
- {
- set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2, FFTLEN );
- set_zero( hStereoCng->olapBufferSynth22, FFTLEN );
- }
-#endif
+
st_fx->clas_dec = st_fx->last_good;
move16();
enr_q_fx = 0;
@@ -359,9 +288,6 @@ ivas_error acelp_core_dec_fx(
tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
-#ifdef ADD_LRTD
- p_tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf;
-#endif
move16();
move16();
move16();
@@ -380,9 +306,6 @@ ivas_error acelp_core_dec_fx(
move16();
}
tdm_Pitch_reuse_flag = 0;
-#ifdef ADD_LRTD
- p_tdm_Pri_pitch_buf = NULL;
-#endif
move16();
}
/*----------------------------------------------------------------*
@@ -422,7 +345,7 @@ ivas_error acelp_core_dec_fx(
Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56)
}
set16_fx( st_fx->mem_MA_fx, 0, M );
-#if 1 // def IVAS_CODE
+
dec = DEC;
move16();
IF( NE_16( st_fx->element_mode, EVS_MONO ) )
@@ -433,9 +356,7 @@ ivas_error acelp_core_dec_fx(
/* update synthesis filter memories */
synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec );
-#else
- synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC );
-#endif
+
Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc
Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/
@@ -600,7 +521,7 @@ ivas_error acelp_core_dec_fx(
{
tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame );
}
-#if 1 // def IVAS_CODE
+
/*----------------------------------------------------------------*
* Decoding of GSC IVAS mode
*----------------------------------------------------------------*/
@@ -620,7 +541,7 @@ ivas_error acelp_core_dec_fx(
move16();
}
}
-#endif
+
/*----------------------------------------------------------------*
* Decoding of inactive CNG frames
*----------------------------------------------------------------*/
@@ -631,23 +552,14 @@ ivas_error acelp_core_dec_fx(
IF( st_fx->cng_type == LP_CNG )
{
- CNG_dec_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env );
-#ifdef IVAS_CODE
- local_element_mode = st_fx->element_mode;
- move16();
- IF( ( EQ_16( nchan_out, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st_fx->masa_sid_format, 1 ) )
- {
- local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */
- move16();
- }
-#endif
+ CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env );
+
/* comfort noise generation */
CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate,
&st_fx->first_CNG, &( st_fx->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho,
q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1, exc3_fx, st_fx->Opt_AMR_WB, st_fx->element_mode );
-#if 1 // def IVAS_CODE
+
Copy( Aq_fx, st_fx->Aq_cng, M + 1 ); // Q12
-#endif
}
ELSE
{
@@ -658,32 +570,7 @@ ivas_error acelp_core_dec_fx(
*sid_bw = 0;
move16();
}
-#ifdef IVAS_CODE
- if ( st->element_mode == IVAS_CPE_DFT )
- {
- assert( nchan_out == 1 );
- for ( i = 0; i < NPART; i++ )
- {
- st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i];
- }
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ApplyFdCng_fx( syn, 0, NULL, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-#else
- ApplyFdCng_fx( syn, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-#endif
- }
- if ( !read_sid_info )
- {
- float noise_lvl_highest;
-
- noise_lvl_highest = st->hFdCngDec->hFdCngCom->cngNoiseLevel[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1];
- for ( int16_t b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ )
- {
- st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest;
- }
- }
-#endif
generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 );
FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
@@ -777,21 +664,13 @@ ivas_error acelp_core_dec_fx(
move16();
}
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
test();
test();
IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) )
{
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
}
}
@@ -818,10 +697,6 @@ ivas_error acelp_core_dec_fx(
move16();
st_fx->last_nq_preQ = 0;
move16();
-#ifdef IVAS_CODE
- st_fx->last_code_preq = 0;
- move16();
-#endif
}
st_fx->use_acelp_preq = 0;
@@ -830,86 +705,10 @@ ivas_error acelp_core_dec_fx(
/*-----------------------------------------------------------------*
* LSF de-quantization and interpolation
*-----------------------------------------------------------------*/
-#ifdef ADD_LRTD
- if ( !tdm_lp_reuse_flag )
-#endif
- {
- lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode,
- tdm_lsfQ_PCh );
- }
-#ifdef ADD_LRTD
- else
- {
- const float *pt_interp_2;
-#ifdef LSF_RE_USE_SECONDARY_CHANNEL
- if ( st->active_cnt != 1 )
- {
- int16_t beta_index;
-
- beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS );
- tdm_SCh_lsf_reuse( DEC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, NULL, &beta_index );
- }
- else
- {
- mvr2r( tdm_lspQ_PCh, lsp_new, M );
- mvr2r( tdm_lsfQ_PCh, lsf_new, M );
- }
-#else
- mvr2r( tdm_lspQ_PCh, lsp_new, M );
- mvr2r( tdm_lsfQ_PCh, lsf_new, M );
-#endif
- if ( st->rate_switching_reset )
- {
- /* extrapolation in case of unstable LSF convert */
- mvr2r( lsp_new, st->lsp_old, M );
- mvr2r( lsf_new, st->lsf_old, M );
- }
-
- pt_interp_2 = interpol_frac_12k8;
- if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED )
- {
- pt_interp_2 = interpol_frac2;
- }
-
- if ( st->active_cnt == 1 )
- {
- mvr2r( lsp_new, st->lsp_old, M );
- lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core );
- }
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 );
- /* Check LSF stability (distance between old LSFs and current LSFs) */
- st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame );
- }
+ lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode,
+ tdm_lsfQ_PCh );
- if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory from last HQ frame */
- old_exc_s = st->old_exc + L_EXC_MEM_DEC - st->L_frame;
- tmpF = *old_exc_s;
- st->mem_deemph = old_exc_s[st->L_frame - 1];
- preemph( old_exc_s, st->preemph_fac, L_FRAME16k, &tmpF );
- mvr2r( old_exc_s + st->L_frame - M, st->mem_syn2, M );
- residu( Aq, M, old_exc_s, old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame );
- }
- if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory of old_bwe_exc */
-#ifdef CR_FIX_639_HQ_ACELP_TRANSITION
- if ( st->L_frame == L_FRAME )
- {
- lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
- }
- else
- {
- lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
- }
-#else
- lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
-#endif
- }
-#endif
/*-----------------------------------------------------------------*
* FEC - first good frame after lost frame(s) (possibility to correct the ACB)
*-----------------------------------------------------------------*/
@@ -979,27 +778,7 @@ ivas_error acelp_core_dec_fx(
test();
test();
-#ifdef ADD_LRTD
- IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
- {
- IF( LE_16( st_fx->coder_type, UNVOICED ) )
- {
- tdm_low_rate_dec( st_fx, dct_exc_tmp, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new );
- }
- ELSE /* GENERIC */
- {
- decod_gen_2sbfr( st_fx, sharpFlag, Aq, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf );
-
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise = st_fx->lp_gainc_fx;
- move16();
- }
- }
- }
- else
-#endif
- IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
+ IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
{
/* SC-VBR - NELP frames */
Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
@@ -1033,12 +812,7 @@ ivas_error acelp_core_dec_fx(
}
ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) )
{
- decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf
-#ifdef ADD_LRTD
- ,
- tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf
-#endif
- );
+ decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf );
tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
}
ELSE
@@ -1519,103 +1293,8 @@ ivas_error acelp_core_dec_fx(
#endif
}
/* CNA: Generate additional comfort noise to mask potential coding artefacts */
-
-#ifdef IVAS_CODE
- if ( !st->cna_dirac_flag )
- {
- /* CNA: Generate additional comfort noise to mask potential coding artefacts */
- if ( st->flag_cna && !( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
- {
- if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 )
- {
- if ( hStereoCng->flag_cna_fade )
- {
- generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 0;
- }
- else
- {
- if ( st->element_mode != last_element_mode && st->idchan == 0 )
- {
- /* Clear memory for secondary channel CNA */
- set_f( hStereoCng->olapBufferSynth22, 0.0f, st->hFdCngDec->hFdCngCom->frameSize / 2 );
- }
-
- generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
- }
- }
- else if ( st->element_mode != IVAS_CPE_DFT )
- {
- if ( st->idchan == 0 )
- {
- if ( st->element_mode != last_element_mode )
- {
- set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0.0f, st->hFdCngDec->hFdCngCom->fftlen );
- }
- generate_masking_noise_fx( syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out );
- }
- }
- }
- else if ( st->flag_cna && st->coder_type == AUDIO && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == TCX_20_CORE ) )
- {
- if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 )
- {
- generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 1;
- }
- else
- {
- v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4, (float) ( st->hFdCngDec->hFdCngCom->fftlen / 2 ), temp_buf, st->hFdCngDec->hFdCngCom->frameSize / 2 );
- v_add( temp_buf, syn, syn, st->hFdCngDec->hFdCngCom->frameSize / 2 );
- }
- }
- else
- {
- if ( hStereoCng != NULL )
- {
- hStereoCng->flag_cna_fade = 1;
- hStereoCng->enableSecCNA = 0;
- }
- }
-
- if ( st->element_mode == IVAS_CPE_TD )
- {
- /*Noise estimate*/
- if ( st->idchan == 0 && ( nchan_out == 2 || ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) )
- {
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ApplyFdCng_fx( syn, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-#else
- ApplyFdCng_fx( syn, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-#endif
- }
- }
- }
-#endif
}
-#ifdef IVAS_CODE
- if ( !st->cna_dirac_flag )
- {
- if ( st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == AMR_WB_CORE ) )
- {
- v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 );
- v_add( temp_buf, syn, syn, st->L_frame / 2 );
- }
-
- if ( st->flag_cna == 0 || ( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
- {
- if ( st->idchan == 0 )
- {
- set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0.f, st->hFdCngDec->hFdCngCom->fftlen );
- }
- if ( hStereoCng != NULL && st->idchan == 0 )
- {
- set_f( hStereoCng->olapBufferSynth22, 0.f, st->hFdCngDec->hFdCngCom->fftlen );
- }
- }
- }
-#else
test();
test();
test();
@@ -1632,9 +1311,7 @@ ivas_error acelp_core_dec_fx(
move16();
}
}
-#endif
-#ifndef IVAS_CODE
test();
test();
test();
@@ -1654,7 +1331,6 @@ ivas_error acelp_core_dec_fx(
{
set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen );
}
-#endif
}
/*----------------------------------------------------------------*
@@ -1676,10 +1352,7 @@ ivas_error acelp_core_dec_fx(
move16();
}
}
-#ifdef ADD_LRTD
- /* analyze pitch coherence for bass post-filter */
- bpf_pitch_coherence( st, pitch_buf );
-#endif
+
test();
IF( !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->bpf_off ) )
{
@@ -1702,22 +1375,8 @@ ivas_error acelp_core_dec_fx(
test();
IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
{
-#ifdef IVAS_CODE
- float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- float imagBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- float *pRealSave[CLDFB_NO_COL_MAX], *pImagSave[CLDFB_NO_COL_MAX];
- for ( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- pRealSave[i] = realBufferSave[i];
- pImagSave[i] = imagBufferSave[i];
- }
- if ( st->p_bpf_noise_buf )
- {
- mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame );
- }
-#endif
/* analysis of the synthesis at internal sampling rate */
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
@@ -1776,42 +1435,8 @@ ivas_error acelp_core_dec_fx(
/* synthesis of the combined signal */
st_fx->Q_syn2 = st_fx->Q_syn;
move16();
-#ifdef IVAS_CODE
- if ( save_hb_synth != NULL )
{
- /* save and then zero-out lowband */
- for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- for ( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBufferSave[i][j] = realBuffer[i][j];
- imagBufferSave[i][j] = imagBuffer[i][j];
- if ( j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots )
- {
- realBuffer[i][j] = 0.0f;
- imagBuffer[i][j] = 0.0f;
- }
- }
- }
-
- cldfbSynthesis( realBuffer, imagBuffer, save_hb_synth, -1, st->cldfbSynHB );
-
- /* restore lowband */
- for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- for ( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBuffer[i][j] = realBufferSave[i][j];
- imagBuffer[i][j] = imagBufferSave[i][j];
- }
- }
-
- cldfbSynthesis( pRealSave, pImagSave, synth, -1, st->cldfbSyn );
- }
- else
-#endif
- {
- cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
}
/* Bring CLDFB output to Q0 */
Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) );
@@ -1821,34 +1446,7 @@ ivas_error acelp_core_dec_fx(
/* save synthesis - needed in case of core switching */
Copy( synth_out, st_fx->previoussynth_fx, output_frame );
}
-#ifdef IVAS_CODE
- ELSE
- {
- int16_t nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
-
- /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
- cldfbAnalysis( syn + st->L_frame - nSamples, realBuffer, imagBuffer, nSamples, st->cldfbAna );
-
- /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
- addBassPostFilter( bpf_error_signal + st->L_frame - nSamples, st->bpf_off ? 0 : nSamples, realBuffer, imagBuffer, st->cldfbBPF );
-
- /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
- cldfbSynthesis( realBuffer, imagBuffer, synth /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn );
-
- if ( st->p_bpf_noise_buf )
- {
- mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame );
- }
-
- set_f( synth, 0.0f, output_frame );
- }
- /* Copy output signal */
- if ( st->element_mode > EVS_MONO )
- {
- mvr2r( syn, output, st->L_frame );
- }
-#endif
/*-----------------------------------------------------------------*
* Bandwidth extension 6kHz-7kHz
*-----------------------------------------------------------------*/
@@ -1864,8 +1462,7 @@ ivas_error acelp_core_dec_fx(
IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) &&
( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) )
{
- hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc,
- st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &st_fx->hBWE_zero->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode );
+ hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 );
}
ELSE
{
diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
index 42e4e36ef155b0bf5f11146901f3d5ab4d1eeda8..38999e99e4f462d9b9c0af182a5532afb935d672 100644
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ b/lib_dec/acelp_core_dec_ivas_fx.c
@@ -39,10 +39,8 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
#include "prot_fx.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
@@ -79,29 +77,21 @@ ivas_error acelp_core_dec_ivas_fx(
{
Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
- Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
- Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
- Word16 output_frame; /* frame length at output sampling freq. */
- Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */
- Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
-#ifdef MSAN_FIX
- Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
-#else
+ Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
+ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
+ Word16 output_frame; /* frame length at output sampling freq. */
+ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */
+ Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */
+ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
-#endif
- Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
- Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
- Word32 enr_q_fx; /* E information for FER protection */
- Word16 tmp_noise_fx; /* Long term temporary noise energy */
- Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */
- Word16 FEC_pitch_fx; /* FEC pitch */
-#ifdef MSAN_FIX
+ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
+ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
+ Word32 enr_q_fx; /* E information for FER protection */
+ Word16 tmp_noise_fx; /* Long term temporary noise energy */
+ Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */
+ Word16 FEC_pitch_fx; /* FEC pitch */
Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
-#else
- Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
-#endif
- Word16 *bwe_exc_fx; /* Excitation for SWB TBE */
+ Word16 *bwe_exc_fx; /* Excitation for SWB TBE */
Word16 i, j, int_fs;
Word16 tc_subfr;
Word16 allow_cn_step;
@@ -135,13 +125,9 @@ ivas_error acelp_core_dec_ivas_fx(
ivas_error error;
Word32 bpf_error_signal_fx[L_FRAME16k];
-#ifdef MSAN_FIX
set32_fx( bpf_error_signal_fx, 0, L_FRAME16k );
-#endif
Word16 bpf_error_signal_16fx[L_FRAME16k];
-#ifdef MSAN_FIX
set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k );
-#endif
set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) );
set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) );
Word16 tmp;
@@ -180,7 +166,6 @@ ivas_error acelp_core_dec_ivas_fx(
IF( EQ_32( st->core_brate, SID_2k40 ) )
{
FdCng_decodeSID_ivas_fx( st );
-#ifdef FIX_ISSUE_1218
Word16 n1, n2;
n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
@@ -190,9 +175,6 @@ ivas_error acelp_core_dec_ivas_fx(
scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
move16();
-#else
- rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
-#endif
}
FOR( i = 0; i < NPART; i++ )
{
@@ -623,11 +605,7 @@ ivas_error acelp_core_dec_ivas_fx(
{
test();
test();
-#ifdef FIX_1189_GSC_IVAS_OMASA
IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) )
-#else
- IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
-#endif
{
st->GSC_IVAS_mode = get_next_indice_fx( st, 2 );
move16();
@@ -644,14 +622,6 @@ ivas_error acelp_core_dec_ivas_fx(
IF( st->cng_type == LP_CNG )
{
CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
-#ifndef FIX_1100_REMOVE_LPC_RESCALING
- FOR( Word32 nsf = 0; nsf < NB_SUBFR16k; nsf++ )
- {
- Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[nsf * ( M + 1 )] ), Q2 ) );
- Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12;
- move16();
- }
-#endif
Copy( Aq_fx, st->Aq_cng, add( M, 1 ) );
/* comfort noise generation */
@@ -690,7 +660,7 @@ ivas_error acelp_core_dec_ivas_fx(
STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
move32();
}
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+
Word16 new_sidNoiseEstExp = 31 - Q4;
move16();
Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
@@ -748,11 +718,7 @@ ivas_error acelp_core_dec_ivas_fx(
IF( st->hMusicPF && st->hGSCDec )
{
Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
-#ifdef FIX_ISSUE_1291
L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
-#else
- imult1616( st->L_frame, HIBND_ACB_L_FAC ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
-#endif
}
IF( st->hPFstat != NULL )
{
@@ -783,9 +749,6 @@ ivas_error acelp_core_dec_ivas_fx(
/* synthesis at 12.8kHz sampling rate */
-#ifndef FIX_1100_REMOVE_LPC_RESCALING
- Aq_fx[0] = ONE_IN_Q12;
-#endif
move16();
syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn );
@@ -806,11 +769,7 @@ ivas_error acelp_core_dec_ivas_fx(
Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1)
IF( st->hBWE_FD != NULL )
{
-#ifdef FIX_ISSUE_1290
save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
-#else
- save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
-#endif
}
}
@@ -850,21 +809,13 @@ ivas_error acelp_core_dec_ivas_fx(
move16();
}
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-#else
- config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-#endif
test();
test();
IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) )
{
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-#else
- config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-#endif
}
}
@@ -946,18 +897,6 @@ ivas_error acelp_core_dec_ivas_fx(
st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
move16();
}
-#ifndef FIX_1100_REMOVE_LPC_RESCALING
-#ifndef MSAN_FIX
- for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
-#else
- FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ )
-#endif
- {
- Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[nsf * ( M + 1 )] ), Q2 ) ); // Q(x-2)
- Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12;
- move16();
- }
-#endif
test();
IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
{
@@ -1100,12 +1039,8 @@ ivas_error acelp_core_dec_ivas_fx(
ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) )
{
/* AUDIO and INACTIVE frames (coded by GSC technology) */
- decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx
-#if 1 // def ADD_LRTD
- ,
- tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx
-#endif
- );
+ decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx,
+ tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
ELSE
@@ -1135,11 +1070,7 @@ ivas_error acelp_core_dec_ivas_fx(
* Apply energy matching when switching to inactive frames
*-----------------------------------------------------------------*/
-#ifdef NONBE_FIX_GSC_BSTR
Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-#else
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-#endif
/*------------------------------------------------------------*
* Decode information and modify the excitation signal of stationary unvoiced frames
@@ -1297,18 +1228,6 @@ ivas_error acelp_core_dec_ivas_fx(
lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
-#ifndef FIX_1100_REMOVE_LPC_RESCALING
-#ifndef MSAN_FIX
- for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
-#else
- FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ )
-#endif
- {
- Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[nsf * ( M + 1 )] ), Q2 ) ); // Qx->Q(x-2)
- Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12;
- move16();
- }
-#endif
IF( EQ_16( st->nelp_mode_dec, 1 ) )
{
/* SC-VBR */
@@ -1346,11 +1265,7 @@ ivas_error acelp_core_dec_ivas_fx(
}
/* Apply energy matching when switching to inactive frames */
-#ifdef NONBE_FIX_GSC_BSTR
Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-#else
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-#endif
/* update past excitation signals for LD music post-filter */
IF( st->hMusicPF != NULL )
@@ -1482,6 +1397,7 @@ ivas_error acelp_core_dec_ivas_fx(
IF( st->hTcxDec != NULL )
{
Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
+ st->hTcxDec->Q_old_syn_Overl = -1;
}
Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
@@ -1771,23 +1687,14 @@ ivas_error acelp_core_dec_ivas_fx(
pRealSave_fx[i] = realBufferSave_fx[i];
pImagSave_fx[i] = imagBufferSave_fx[i];
}
-#ifndef MSAN_FIX
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
-#endif
IF( st->p_bpf_noise_buf_32 )
{
-#ifdef MSAN_FIX
Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
-#endif
Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11
}
-#ifdef MSAN_FIX
FOR( i = 0; i < st->L_frame; i++ )
-#else
- for ( i = 0; i < L_FRAME16k; i++ )
-#endif
{
syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
move32();
@@ -1808,15 +1715,7 @@ ivas_error acelp_core_dec_ivas_fx(
q_bpf_error_signal = Q6;
move16();
-#ifdef MSAN_FIX
-#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
-#else
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
-#endif
-#else
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6
-#endif
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
@@ -1908,12 +1807,15 @@ ivas_error acelp_core_dec_ivas_fx(
scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag
}
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
+#endif /* OPT_STEREO_32KBPS_V1 */
st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
move16();
-#ifndef MSAN_FIX
- Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) ); // Q_real-1
-#endif
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
@@ -1933,12 +1835,18 @@ ivas_error acelp_core_dec_ivas_fx(
}
}
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB );
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0
Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
st->cldfbSynHB->Q_cldfb_state = Q10;
move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
/* restore lowband */
FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
@@ -1950,14 +1858,21 @@ ivas_error acelp_core_dec_ivas_fx(
move32();
}
}
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
move16();
- cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn );
Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0
Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
st->cldfbSynHB->Q_cldfb_state = Q10;
move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
}
ELSE
{
@@ -1989,19 +1904,20 @@ ivas_error acelp_core_dec_ivas_fx(
scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
}
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#endif /* OPT_STEREO_32KBPS_V1 */
st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
move16();
-#ifndef MSAN_FIX
- Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 );
-#endif
-
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn );
-#ifdef MSAN_FIX
- scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
-#else
- Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) );
-#endif
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
st->cldfbSyn->Q_cldfb_state = Q10;
move16();
@@ -2015,11 +1931,7 @@ ivas_error acelp_core_dec_ivas_fx(
Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
/* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
-#ifndef MSAN_FIX
- for ( i = 0; i < L_FRAME16k; i++ )
-#else
FOR( i = 0; i < st->L_frame; i++ )
-#endif
{
syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
move32();
@@ -2042,11 +1954,7 @@ ivas_error acelp_core_dec_ivas_fx(
// Get Q-factor
q_bpf_error_signal = Q6;
move16();
-#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
-#else
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
-#endif
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
@@ -2096,21 +2004,26 @@ ivas_error acelp_core_dec_ivas_fx(
scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
}
- scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
-#ifndef MSAN_FIX
- Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 );
-#endif
-
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn );
-
-#ifdef MSAN_FIX
- Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
-#else
- Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) );
-#endif
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
st->cldfbSyn->Q_cldfb_state = Q10;
move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
IF( st->p_bpf_noise_buf_32 )
{
Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
@@ -2123,11 +2036,7 @@ ivas_error acelp_core_dec_ivas_fx(
}
/* Copy output signal */
-#ifndef MSAN_FIX
- Scale_sig( syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn );
-#else
Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0
-#endif
IF( st->element_mode > EVS_MONO )
{
Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/
@@ -2150,26 +2059,14 @@ ivas_error acelp_core_dec_ivas_fx(
IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) &&
( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
{
-#ifdef MSAN_FIX
Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
-#else
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
-#endif
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx,
- psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1,
- st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode );
-#ifdef MSAN_FIX
+ hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
-#else
- Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, L_FRAME48k, 0 );
-#endif
}
ELSE
{
hf_synth_reset_fx( st->hBWE_zero );
-#ifdef MSAN_FIX
set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
-#endif
}
}
@@ -2204,11 +2101,7 @@ ivas_error acelp_core_dec_ivas_fx(
test();
IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
{
-#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
-#else
- Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
-#endif
non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
}
@@ -2249,18 +2142,7 @@ ivas_error acelp_core_dec_ivas_fx(
{
Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
}
-#ifdef MSAN_FIX
Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
-#else
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
-#endif
-#ifndef FIX_1100_REMOVE_LPC_RESCALING
- if ( st->hFdCngDec )
- {
- st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12;
- move16();
- }
-#endif
}
pop_wmops();
diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c
deleted file mode 100644
index b25a46f03b521c59cfd2d349c3cd49bafb0b6183..0000000000000000000000000000000000000000
--- a/lib_dec/acelp_core_switch_dec.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index 3875339571c907267d06ede6126a3022dc03d558..7657491885adbc296ef9f41cfad150842b149f7e 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -7,7 +7,6 @@
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
-#include "prot.h" /* Function prototypes */
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
@@ -129,11 +128,7 @@ ivas_error acelp_core_switch_dec_fx(
* Excitation decoding
*----------------------------------------------------------------*/
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
-#else
- config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
-#endif
decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc );
@@ -205,8 +200,7 @@ ivas_error acelp_core_switch_dec_fx(
{
return error;
}
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, synth_intFreq,
- negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, synth_intFreq, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH, workBuffer );
cldfb_restore_memory( st_fx->cldfbAna );
/* CLDFB synthesis of the combined signal */
@@ -237,12 +231,12 @@ ivas_error acelp_core_switch_dec_fx(
{
return error;
}
- cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_subfr_out, 0, CLDFB_NO_COL_MAX_SWITCH, workBuffer );
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_subfr_out, 0, CLDFB_NO_COL_MAX_SWITCH, workBuffer );
cldfb_restore_memory( st_fx->cldfbSyn );
*Q_syn = 0;
move16();
- Copy_Scale_sig( synth_intFreq + sub( NS2SA( i_mult( L_frame_for_cs, 50 ), ( SWITCH_GAP_LENGTH_NS - DELAY_CLDFB_NS ) ), 2 ), mem_synth, add( NS2SA( i_mult( L_frame_for_cs, 50 ), DELAY_CLDFB_NS ), 2 ), negate( st_fx->Q_syn ) ); /* Copy mem with Q0 */
+ Copy_Scale_sig( synth_intFreq + sub( NS2SA_FX2( i_mult( L_frame_for_cs, 50 ), ( SWITCH_GAP_LENGTH_NS - DELAY_CLDFB_NS ) ), 2 ), mem_synth, add( NS2SA_FX2( i_mult( L_frame_for_cs, 50 ), DELAY_CLDFB_NS ), 2 ), negate( st_fx->Q_syn ) ); /* Copy mem with Q0 */
/*----------------------------------------------------------------*
* BWE decoding
@@ -579,8 +573,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
{
return error;
}
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn,
- negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
cldfb_restore_memory( st_fx->cldfbAna );
scaleFactor.hb_scale = scaleFactor.lb_scale;
@@ -591,8 +584,8 @@ ivas_error acelp_core_switch_dec_bfi_fx(
{
return error;
}
- cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
- negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
+ negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
/* output to Q0 */
Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0
@@ -822,16 +815,12 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
*----------------------------------------------------------------*/
/* CLDFB analysis of the synthesis at internal sampling rate */
Qtmp = sub( 11, st_fx->Q_syn );
-#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11)
-#else
- Copy_Scale_sig_16_32_DEPREC( syn, syn32, L_FRAME16k, Qtmp ); // Q(11)
-#endif
IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
{
return error;
}
- /*cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn,
+ /*cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn,
negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer);*/
cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna );
cldfb_restore_memory_ivas_fx( st_fx->cldfbAna );
@@ -841,19 +830,27 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
{
return error;
}
- /*cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
+ /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, 1 ); // Q_cldfb_state+1
st_fx->cldfbSyn->Q_cldfb_state = add( st_fx->cldfbSyn->Q_cldfb_state, 1 );
move16();
Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/
- // cldfbSynthesis_ivas_fx(realBuffer, imagBuffer, synth_out, (int16_t)(st_fx->output_Fs * 0.01f), st_fx->cldfbSyn);
- cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), st_fx->cldfbSyn );
+ cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), 0, st_fx->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) );
+ cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn );
+ Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, -1 ); // Q_cldfb_state-1
st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 );
move16();
Copy_Scale_sig_32_16( synth32, synth_out, L_FRAME48k, -5 ); // 11-5-1 -> 11
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
// Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) );
diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c
deleted file mode 100644
index 47e1f0be1a2a79b57dd772f7d1e5b59af4112750..0000000000000000000000000000000000000000
--- a/lib_dec/amr_wb_dec.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c
index d45655903fb6f8f427e3d28ea4f7e91cbd2be7a2..db4ad2bb021122533aba2ec98cb77b9455a90804 100644
--- a/lib_dec/amr_wb_dec_fx.c
+++ b/lib_dec/amr_wb_dec_fx.c
@@ -214,11 +214,10 @@ ivas_error amr_wb_dec_fx(
test();
IF( !st_fx->bfi && st_fx->prev_bfi && ( EQ_16( st_fx->last_codec_mode, MODE2 ) ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) )
{
- /* v_multc(st_fx->old_out_fx, st_fx->plcInfo.recovery_gain, */
- /* st_fx->old_out_fx, st_fx->L_frameTCX); */
+ /* v_multc(st_fx->old_out_fx, st_fx->hPlcInfo.recovery_gain, st_fx->old_out_fx, st_fx->L_frameTCX); */
FOR( i = 0; i < hTcxDec->L_frameTCX; i++ )
{
- hHQ_core->old_out_fx[i] = shl( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 );
+ hHQ_core->old_out_fx[i] = shl( mult_r( hHQ_core->old_out_fx[i], st_fx->hPlcInfo->recovery_gain ), 1 );
move16();
}
}
@@ -756,6 +755,7 @@ ivas_error amr_wb_dec_fx(
/* TCX=Q-1, ACELP2 Q0 */
Copy_Scale_sig( syn_fx + L_FRAME / 2, hTcxDec->old_syn_Overl, L_FRAME / 2, sub( -1, st_fx->Q_syn ) );
+ hTcxDec->Q_old_syn_Overl = -1;
Copy_Scale_sig( syn_fx + L_FRAME - M - 1, st_fx->syn, M + 1, sub( 0, st_fx->Q_syn ) );
/*------------------------------------------------------------------*
@@ -872,8 +872,7 @@ ivas_error amr_wb_dec_fx(
bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, L_FRAME, pitch_buf_fx, st_fx->bpf_off, st_fx->stab_fac_fx,
&st_fx->stab_fac_smooth_fx, GENERIC, st_fx->Q_syn, bpf_error_signal );
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx,
- negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
@@ -898,8 +897,9 @@ ivas_error amr_wb_dec_fx(
move16();
}
cldfb_synth_set_bandsToZero( st_fx, realBuffer, imagBuffer, CLDFB_NO_COL_MAX, scaleFactor );
+
/* CLDFB synthesis of the combined signal */
- cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out_fx, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out_fx, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
/* Bring CLDFB output to Q-1 */
Scale_sig( synth_out_fx, output_frame, negate( st_fx->Q_syn2 ) );
@@ -963,7 +963,7 @@ ivas_error amr_wb_dec_fx(
test();
test();
- IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) )
+ IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) )
{
waveadj_rec = 1;
move16();
@@ -1062,7 +1062,7 @@ ivas_error amr_wb_dec_fx(
{
tmps = NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS );
Scale_sig( st_fx->prev_synth_buffer_fx, tmps, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) );
- delay_signal( synth_out_fx, output_frame, st_fx->prev_synth_buffer_fx, tmps );
+ delay_signal_fx( synth_out_fx, output_frame, st_fx->prev_synth_buffer_fx, tmps );
}
IF( waveadj_rec )
@@ -1075,9 +1075,7 @@ ivas_error amr_wb_dec_fx(
move16();
}
- waveform_adj2_fix( st_fx->tonalMDCTconceal.secondLastPcmOut, synth_out_fx + tmps, st_fx->plcInfo.data_noise, &st_fx->plcInfo.outx_new_n1_fx,
- &st_fx->plcInfo.nsapp_gain_fx, &st_fx->plcInfo.nsapp_gain_n_fx, &st_fx->plcInfo.recovery_gain, st_fx->plcInfo.step_concealgain_fx,
- st_fx->plcInfo.Pitch_fx, st_fx->plcInfo.FrameSize, tmps, add( extract_l( st_fx->plcInfo.nbLostCmpt ), 1 ), st_fx->bfi );
+ waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth_out_fx + tmps, tmps, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
}
/* HP filter */
@@ -1095,7 +1093,7 @@ ivas_error amr_wb_dec_fx(
move16();
Scale_sig( hTcxLtpDec->tcxltp_mem_in, delta, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) );
Scale_sig( hTcxLtpDec->tcxltp_mem_out, output_frame, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) );
- tcx_ltp_post( st_fx, hTcxLtpDec, ACELP_CORE, output_frame, 0, synth_out_fx, NULL );
+ tcx_ltp_post_fx( st_fx, hTcxLtpDec, ACELP_CORE, output_frame, 0, synth_out_fx, NULL );
}
/* final output of synthesis signal */
syn_output_fx( st_fx->codec_mode, synth_out_fx, output_frame, output_sp, st_fx->Q_syn2 );
diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c
deleted file mode 100644
index b45cb5d9c77b2379a1d38cc544eb9ba5a8d42d53..0000000000000000000000000000000000000000
--- a/lib_dec/ari_dec.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "prot_fx.h"
-#include "stat_com.h"
-#include "basop_util.h"
-#include "wmc_auto.h"
-
-
-/*---------------------------------------------------------------
- * Ari decode 14 bits routines
- -------------------------------------------------------------*/
-
-/*---------------------------------------------------------------
- * ari_start_decoding_14bits_ivas()
- *
- * Start ArCo decoding
- *-------------------------------------------------------------*/
-
-
-Word16 ari_start_decoding_14bits_prm_ivas_fx(
- const Word16 *ptr,
- Word16 bp,
- Tastat *s )
-{
- Word32 val;
- Word16 i;
- const Word16 *p;
-
- val = 0;
- move32();
- p = ptr + bp;
-
- FOR( i = 0; i < cbitsnew; i++ )
- {
- val = L_or( L_shl( val, 1 ), *( p + i ) );
- }
- s->low = 0;
- move32();
- s->high = ari_q4new;
- move32();
- s->value = val;
- move32();
-
- return add( bp, i );
-}
-
-
-Word16 ari_decode_14bits_pow_ivas(
- Word16 *ptr,
- Word16 bp,
- Word16 bits,
- Word16 *res,
- Tastat *s,
- UWord16 base )
-{
- UWord16 symbol;
- Word32 low, high;
- UWord32 range, value, cum;
- Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */
- Word16 lowlim, highlim, testval;
- Word16 k;
-
- highlim = 0;
- low = s->low;
- high = L_add( s->high, 1 );
- value = s->value;
- lowlim = 0;
- symbol = 0;
- move16();
- move32();
- move32();
- move16();
- move16();
-
- range = (UWord32) W_sub( high, low );
- move32();
-
- /* the value read from bitstream */
- assert( value >= (UWord32) low );
- cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 );
- move32();
-
- /* search for the interval where "cum" fits */
- IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */
- {
- pows[0] = testval = base;
- move16();
- move16();
- /* increase exponent until it is smaller than "cum" */
- FOR( k = 1; k < 12; k++ )
- {
- highlim = testval;
- move16();
- pows[k] = mult_r( pows[k - 1], pows[k - 1] );
- move16();
- testval = mult_r( pows[k], base );
- IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */
- {
- lowlim = testval;
- move16();
- k = sub( k, 1 );
- symbol = (UWord16) L_shl( 1, k );
- BREAK;
- }
- }
- assert( k < 12 ); /* maximum 2^10-1*/
- /* narrow the range down */
- FOR( k--; k > 0; k-- )
- {
- testval = mult_r( highlim, pows[k] );
- IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) )
- {
- lowlim = testval;
- move16();
- symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) );
- }
- ELSE
- {
- highlim = testval;
- move16();
- }
- }
- highlim = shr( highlim, 1 );
- lowlim = shr( lowlim, 1 );
- }
- ELSE /* trivial case, above pow-1, that is, first symbol */
- {
- symbol = 0;
- lowlim = extract_l( L_shr( base, 1 ) );
- highlim = 16384;
- move16();
- move16();
- }
-
-
- high = L_add( low, mul_sbc_14bits( range, highlim ) );
-
- low = L_add( low, mul_sbc_14bits( range, lowlim ) );
-
- /*ptr init for ptr*/
- FOR( ; bp < bits; )
- {
- IF( GT_32( high, ari_q2new ) )
- {
- IF( GE_32( low, ari_q2new ) )
- {
- value = (UWord32) W_sub( value, ari_q2new );
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new );
- }
- ELSE
- {
- test();
- IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) )
- {
- value = (UWord32) W_sub( value, ari_q1new );
- low = L_sub( low, ari_q1new );
- high = L_sub( high, ari_q1new );
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- low = L_add( low, low );
- high = L_add( high, high );
-
- assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" );
-
- value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] );
- }
-
- test();
- test();
- test();
- IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) )
- {
- /* This should not happen except of bit errors. */
- s->high = s->low = 0;
- move32();
- move32();
- *res = 0;
- move16();
- return -1;
- }
-
- s->low = low;
- s->high = L_sub( high, 1 );
- s->value = value;
- move32();
- move32();
- move32();
-
- *res = symbol;
- move16();
- return bp;
-}
-
-Word16 ari_decode_14bits_sign_ivas(
- Word16 *ptr,
- Word16 bp,
- Word16 bits,
- Word16 *res,
- Tastat *s )
-{
- Word16 symbol;
- Word32 low, high;
- UWord32 range, value, cum;
-
- low = s->low;
- high = L_add( s->high, 1 );
- value = s->value;
- move32();
- move32();
-
- range = (UWord32) W_sub( high, low );
-
- IF( LT_16( bp, bits ) )
- {
- assert( value >= (UWord32) low );
- cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 );
- IF( GT_64( W_shl( range, 13 ), cum ) )
- {
- symbol = 2;
- move16();
- high = L_add( low, W_extract_l( W_shr( range, 1 ) ) );
- }
- ELSE
- {
- symbol = 1;
- move16();
- low = L_add( low, W_extract_l( W_shr( range, 1 ) ) );
- }
-
- /*ptr init for ptr*/
- FOR( ; bp < bits; )
- {
- IF( GT_32( high, ari_q2new ) )
- {
- IF( GE_32( low, ari_q2new ) )
- {
- value = (UWord32) W_sub( value, ari_q2new );
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new );
- }
- ELSE
- {
- test();
- IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) )
- {
- value = (UWord32) W_sub( value, ari_q1new );
- low = L_sub( low, ari_q1new );
- high = L_sub( high, ari_q1new );
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- low = L_add( low, low );
- high = L_add( high, high );
-
- assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" );
-
- value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] );
- }
- }
- ELSE
- {
- cum = (UWord32) W_sub( value, low );
- range = (UWord32) W_shr( range, 1 );
- IF( GT_64( range, cum ) )
- {
- symbol = 2;
- move16();
- high = L_add( low, range );
- }
- ELSE
- {
- symbol = 1;
- move16();
- low = L_add( low, range );
- }
- }
-
- s->low = low;
- s->high = L_sub( high, 1 );
- s->value = value;
- move32();
- move32();
- move32();
-
- *res = symbol;
- move16();
-
- return bp;
-}
diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c
index 3681568f28f46665132a75fefe5aa2ec05ac5bca..3aabbdaa58cbcdda0a7c83d962eb9297c8a8608f 100644
--- a/lib_dec/ari_dec_fx.c
+++ b/lib_dec/ari_dec_fx.c
@@ -551,3 +551,291 @@ Word16 ari_decode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, Word16 *r
{
return ari_decode_14bits_notbl_fx( ptr, bp, bits, res, s, 0, ari_lookup_sign_fx );
}
+
+/*---------------------------------------------------------------
+ * ari_start_decoding_14bits_ivas()
+ *
+ * Start ArCo decoding
+ *-------------------------------------------------------------*/
+
+
+Word16 ari_start_decoding_14bits_prm_ivas_fx(
+ const Word16 *ptr,
+ Word16 bp,
+ Tastat *s )
+{
+ Word32 val;
+ Word16 i;
+ const Word16 *p;
+
+ val = 0;
+ move32();
+ p = ptr + bp;
+
+ FOR( i = 0; i < cbitsnew; i++ )
+ {
+ val = L_or( L_shl( val, 1 ), *( p + i ) );
+ }
+ s->low = 0;
+ move32();
+ s->high = ari_q4new;
+ move32();
+ s->value = val;
+ move32();
+
+ return add( bp, i );
+}
+
+
+Word16 ari_decode_14bits_pow_ivas(
+ Word16 *ptr,
+ Word16 bp,
+ Word16 bits,
+ Word16 *res,
+ Tastat *s,
+ UWord16 base )
+{
+ UWord16 symbol;
+ Word32 low, high;
+ UWord32 range, value, cum;
+ Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */
+ Word16 lowlim, highlim, testval;
+ Word16 k;
+
+ highlim = 0;
+ low = s->low;
+ high = L_add( s->high, 1 );
+ value = s->value;
+ lowlim = 0;
+ symbol = 0;
+ move16();
+ move32();
+ move32();
+ move16();
+ move16();
+
+ range = (UWord32) W_sub( high, low );
+ move32();
+
+ /* the value read from bitstream */
+ assert( value >= (UWord32) low );
+ cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 );
+ move32();
+
+ /* search for the interval where "cum" fits */
+ IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */
+ {
+ pows[0] = testval = base;
+ move16();
+ move16();
+ /* increase exponent until it is smaller than "cum" */
+ FOR( k = 1; k < 12; k++ )
+ {
+ highlim = testval;
+ move16();
+ pows[k] = mult_r( pows[k - 1], pows[k - 1] );
+ move16();
+ testval = mult_r( pows[k], base );
+ IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */
+ {
+ lowlim = testval;
+ move16();
+ k = sub( k, 1 );
+ symbol = (UWord16) L_shl( 1, k );
+ BREAK;
+ }
+ }
+ assert( k < 12 ); /* maximum 2^10-1*/
+ /* narrow the range down */
+ FOR( k--; k > 0; k-- )
+ {
+ testval = mult_r( highlim, pows[k] );
+ IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) )
+ {
+ lowlim = testval;
+ move16();
+ symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) );
+ }
+ ELSE
+ {
+ highlim = testval;
+ move16();
+ }
+ }
+ highlim = shr( highlim, 1 );
+ lowlim = shr( lowlim, 1 );
+ }
+ ELSE /* trivial case, above pow-1, that is, first symbol */
+ {
+ symbol = 0;
+ lowlim = extract_l( L_shr( base, 1 ) );
+ highlim = 16384;
+ move16();
+ move16();
+ }
+
+
+ high = L_add( low, mul_sbc_14bits( range, highlim ) );
+
+ low = L_add( low, mul_sbc_14bits( range, lowlim ) );
+
+ /*ptr init for ptr*/
+ FOR( ; bp < bits; )
+ {
+ IF( GT_32( high, ari_q2new ) )
+ {
+ IF( GE_32( low, ari_q2new ) )
+ {
+ value = (UWord32) W_sub( value, ari_q2new );
+ low = L_sub( low, ari_q2new );
+ high = L_sub( high, ari_q2new );
+ }
+ ELSE
+ {
+ test();
+ IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) )
+ {
+ value = (UWord32) W_sub( value, ari_q1new );
+ low = L_sub( low, ari_q1new );
+ high = L_sub( high, ari_q1new );
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+ }
+ low = L_add( low, low );
+ high = L_add( high, high );
+
+ assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" );
+
+ value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] );
+ }
+
+ test();
+ test();
+ test();
+ IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) )
+ {
+ /* This should not happen except of bit errors. */
+ s->high = s->low = 0;
+ move32();
+ move32();
+ *res = 0;
+ move16();
+ return -1;
+ }
+
+ s->low = low;
+ s->high = L_sub( high, 1 );
+ s->value = value;
+ move32();
+ move32();
+ move32();
+
+ *res = symbol;
+ move16();
+ return bp;
+}
+
+Word16 ari_decode_14bits_sign_ivas(
+ Word16 *ptr,
+ Word16 bp,
+ Word16 bits,
+ Word16 *res,
+ Tastat *s )
+{
+ Word16 symbol;
+ Word32 low, high;
+ UWord32 range, value, cum;
+
+ low = s->low;
+ high = L_add( s->high, 1 );
+ value = s->value;
+ move32();
+ move32();
+
+ range = (UWord32) W_sub( high, low );
+
+ IF( LT_16( bp, bits ) )
+ {
+ assert( value >= (UWord32) low );
+ cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 );
+ IF( GT_64( W_shl( range, 13 ), cum ) )
+ {
+ symbol = 2;
+ move16();
+ high = L_add( low, W_extract_l( W_shr( range, 1 ) ) );
+ }
+ ELSE
+ {
+ symbol = 1;
+ move16();
+ low = L_add( low, W_extract_l( W_shr( range, 1 ) ) );
+ }
+
+ /*ptr init for ptr*/
+ FOR( ; bp < bits; )
+ {
+ IF( GT_32( high, ari_q2new ) )
+ {
+ IF( GE_32( low, ari_q2new ) )
+ {
+ value = (UWord32) W_sub( value, ari_q2new );
+ low = L_sub( low, ari_q2new );
+ high = L_sub( high, ari_q2new );
+ }
+ ELSE
+ {
+ test();
+ IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) )
+ {
+ value = (UWord32) W_sub( value, ari_q1new );
+ low = L_sub( low, ari_q1new );
+ high = L_sub( high, ari_q1new );
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+ }
+ low = L_add( low, low );
+ high = L_add( high, high );
+
+ assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" );
+
+ value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] );
+ }
+ }
+ ELSE
+ {
+ cum = (UWord32) W_sub( value, low );
+ range = (UWord32) W_shr( range, 1 );
+ IF( GT_64( range, cum ) )
+ {
+ symbol = 2;
+ move16();
+ high = L_add( low, range );
+ }
+ ELSE
+ {
+ symbol = 1;
+ move16();
+ low = L_add( low, range );
+ }
+ }
+
+ s->low = low;
+ s->high = L_sub( high, 1 );
+ s->value = value;
+ move32();
+ move32();
+ move32();
+
+ *res = symbol;
+ move16();
+
+ return bp;
+}
diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c
index da7722325058b1ca10f3ed0060b97a37d320444b..ef4fb62d5579e0f89500a76227fbe459a7f1719e 100644
--- a/lib_dec/ari_hm_dec.c
+++ b/lib_dec/ari_hm_dec.c
@@ -40,10 +40,9 @@
#include "cnst.h"
#include "stl.h"
#include "basop_util.h"
-#include "prot.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx.h"
Word16
DecodeIndex_fx(
diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c
deleted file mode 100644
index 93bd8877cf6f23910bb7436b7bb6528b7f0e54ef..0000000000000000000000000000000000000000
--- a/lib_dec/arith_coder_dec.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "basop_util.h"
-#include "basop_proto_func.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------*
- * tcx_arith_decode()
- *
- *
- *-------------------------------------------------------*/
-
-/*! r: number of bits consumed */
-
-static Word16 tcx_arith_decode_ivas_fx(
- const Word16 L_frame, /* i : number of spectral lines */
- const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */
- Word16 envelope_e, /* i : scaled envelope exponent (Q0) */
- const Word16 target_bits, /* i : target bit budget */
- Word16 prm[], /* i : bitstream parameters */
- Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */
- Word16 *q_spectrum_e /* o : spectrum exponent */
-)
-{
- Word16 bp, k, q;
- Word16 s;
- Tastat as;
- UWord16 exp_k;
- Word16 tmp;
-
- bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as );
-
- tmp = sub( envelope_e, 1 );
-
- FOR( k = 0; k < L_frame; k++ )
- {
- IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */
- {
- set32_fx( q_spectrum, 0, L_frame );
- return -1;
- }
- ELSE
- {
- exp_k = expfp_evs_fx( negate( envelope[k] ), tmp );
- }
-
- /* decode line magnitude */
- bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k );
-
- IF( q )
- {
- /* line is non-zero, decode sign */
- bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as );
- q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) );
- move32();
- q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20)
- move32();
- }
- ELSE
- {
- /* line is zero, no sign needed */
- q_spectrum[k] = 0;
- move32();
- }
-
- IF( LE_32( as.high, as.low ) )
- {
- if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */
- {
- bp = -1;
- move16();
- }
- BREAK; /* no bits left, so exit loop */
- }
- }
- *q_spectrum_e = SPEC_EXP_DEC;
- move16();
-
- set32_fx( q_spectrum + k, 0, sub( L_frame, k ) );
-
- return bp;
-}
-
-/*-------------------------------------------------------*
- * tcx_arith_decode_envelope()
- *
- *
- *-------------------------------------------------------*/
-
-void tcx_arith_decode_envelope_ivas_fx(
- Decoder_State *st, /* i/o: coder state */
- Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */
- Word16 *q_spectrum_e, /* o : MDCT exponent */
- const Word16 L_frame, /* i : frame or MDCT length */
- Word16 L_spec, /* i : length w/o BW limitation */
- const Word16 A_ind[], /* i : quantised LPC coefficients */
- const Word16 target_bits, /* i : number of available bits */
- Word16 prm[], /* i : bitstream parameters */
- const Word16 use_hm, /* i : use HM in current frame? */
- const Word16 prm_hm[], /* i : HM parameter area */
- Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
- Word16 *arith_bits, /* o : bits used for ari. coding */
- Word16 *signaling_bits, /* o : bits used for signaling */
- const Word16 low_complexity /* i : low-complexity flag */
-)
-{
- Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */
- Word16 *envelope; /* scaled envelope (Q15-e) */
- Word16 envelope_e;
- Word16 L_spec_core;
- TCX_CONFIG_HANDLE hTcxCfg;
- TCX_DEC_HANDLE hTcxDec;
- Word16 gamma_w, gamma_uw;
- Word16 hm_bits;
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
- ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) ||
- ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) ||
- ( target_bits <= 0 ) )
- {
- /* this could happen in case of bit errors */
- st->BER_detect = 1;
- move16();
- L_spec = N_MAX_ARI;
- move16();
- *signaling_bits = 0;
- move16();
- *arith_bits = 0;
- move16();
- set32_fx( q_spectrum, 0, L_frame );
-
- return;
- }
-
- hTcxCfg = st->hTcxCfg;
- hTcxDec = st->hTcxDec;
- *signaling_bits = 0;
- move16();
-
- assert( hTcxDec->enableTcxLpc );
- gamma_w = MAX16B;
- move16();
- gamma_uw = st->inv_gamma;
- move16();
-
-#define WMC_TOOL_SKIP
- tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
-#undef WMC_TOOL_SKIP
-
- IF( use_hm != 0 )
- {
- IF( prm_hm[0] != 0 )
- {
- tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits );
-
- IF( hm_bits < 0 )
- {
- st->BER_detect = 1;
- move16();
- *signaling_bits = 0;
- move16();
- *arith_bits = 0;
- move16();
- set32_fx( q_spectrum, 0, L_frame );
-
- return;
- }
- }
- ELSE
- {
- hm_bits = 1;
- move16();
- }
- *signaling_bits = add( *signaling_bits, hm_bits );
- move16();
- }
-
- L_spec_core = L_spec;
- move16();
- IF( st->igf )
- {
- L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine );
- }
-
- envelope = (Word16 *) env;
- tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
-
- *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e );
- move16();
-
- /* safety check in case of bit errors */
- IF( *arith_bits < 0 )
- {
- st->BER_detect = 1;
- move16();
- set32_fx( q_spectrum, 0, L_frame );
- }
-
- set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) );
-
- return;
-}
diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c
index 4a18f64f9af7a503a0e66756353605e7e5d03b07..60a59c4da469f113f7195179ed0521d2c343bc2d 100644
--- a/lib_dec/arith_coder_dec_fx.c
+++ b/lib_dec/arith_coder_dec_fx.c
@@ -8,6 +8,8 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot_fx.h"
+#include "basop_util.h"
+#include "basop_proto_func.h"
/* Returns: number of bits consumed */
static Word16 tcx_arith_decode_fx(
@@ -213,3 +215,207 @@ void tcx_arith_decode_envelope_fx(
set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) );
}
+
+/*-------------------------------------------------------*
+ * tcx_arith_decode()
+ *
+ *
+ *-------------------------------------------------------*/
+
+/*! r: number of bits consumed */
+
+static Word16 tcx_arith_decode_ivas_fx(
+ const Word16 L_frame, /* i : number of spectral lines */
+ const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */
+ Word16 envelope_e, /* i : scaled envelope exponent (Q0) */
+ const Word16 target_bits, /* i : target bit budget */
+ Word16 prm[], /* i : bitstream parameters */
+ Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */
+ Word16 *q_spectrum_e /* o : spectrum exponent */
+)
+{
+ Word16 bp, k, q;
+ Word16 s;
+ Tastat as;
+ UWord16 exp_k;
+ Word16 tmp;
+
+ bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as );
+
+ tmp = sub( envelope_e, 1 );
+
+ FOR( k = 0; k < L_frame; k++ )
+ {
+ IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */
+ {
+ set32_fx( q_spectrum, 0, L_frame );
+ return -1;
+ }
+ ELSE
+ {
+ exp_k = expfp_evs_fx( negate( envelope[k] ), tmp );
+ }
+
+ /* decode line magnitude */
+ bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k );
+
+ IF( q )
+ {
+ /* line is non-zero, decode sign */
+ bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as );
+ q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) );
+ move32();
+ q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20)
+ move32();
+ }
+ ELSE
+ {
+ /* line is zero, no sign needed */
+ q_spectrum[k] = 0;
+ move32();
+ }
+
+ IF( LE_32( as.high, as.low ) )
+ {
+ if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */
+ {
+ bp = -1;
+ move16();
+ }
+ BREAK; /* no bits left, so exit loop */
+ }
+ }
+ *q_spectrum_e = SPEC_EXP_DEC;
+ move16();
+
+ set32_fx( q_spectrum + k, 0, sub( L_frame, k ) );
+
+ return bp;
+}
+
+/*-------------------------------------------------------*
+ * tcx_arith_decode_envelope()
+ *
+ *
+ *-------------------------------------------------------*/
+
+void tcx_arith_decode_envelope_ivas_fx(
+ Decoder_State *st, /* i/o: coder state */
+ Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */
+ Word16 *q_spectrum_e, /* o : MDCT exponent */
+ const Word16 L_frame, /* i : frame or MDCT length */
+ Word16 L_spec, /* i : length w/o BW limitation */
+ const Word16 A_ind[], /* i : quantised LPC coefficients */
+ const Word16 target_bits, /* i : number of available bits */
+ Word16 prm[], /* i : bitstream parameters */
+ const Word16 use_hm, /* i : use HM in current frame? */
+ const Word16 prm_hm[], /* i : HM parameter area */
+ Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
+ Word16 *arith_bits, /* o : bits used for ari. coding */
+ Word16 *signaling_bits, /* o : bits used for signaling */
+ const Word16 low_complexity /* i : low-complexity flag */
+)
+{
+ Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */
+ Word16 *envelope; /* scaled envelope (Q15-e) */
+ Word16 envelope_e;
+ Word16 L_spec_core;
+ TCX_CONFIG_HANDLE hTcxCfg;
+ TCX_DEC_HANDLE hTcxDec;
+ Word16 gamma_w, gamma_uw;
+ Word16 hm_bits;
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
+ ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) ||
+ ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) ||
+ ( target_bits <= 0 ) )
+ {
+ /* this could happen in case of bit errors */
+ st->BER_detect = 1;
+ move16();
+ L_spec = N_MAX_ARI;
+ move16();
+ *signaling_bits = 0;
+ move16();
+ *arith_bits = 0;
+ move16();
+ set32_fx( q_spectrum, 0, L_frame );
+
+ return;
+ }
+
+ hTcxCfg = st->hTcxCfg;
+ hTcxDec = st->hTcxDec;
+ *signaling_bits = 0;
+ move16();
+
+ assert( hTcxDec->enableTcxLpc );
+ gamma_w = MAX16B;
+ move16();
+ gamma_uw = st->inv_gamma;
+ move16();
+
+#define WMC_TOOL_SKIP
+ tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
+#undef WMC_TOOL_SKIP
+
+ IF( use_hm != 0 )
+ {
+ IF( prm_hm[0] != 0 )
+ {
+ tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits );
+
+ IF( hm_bits < 0 )
+ {
+ st->BER_detect = 1;
+ move16();
+ *signaling_bits = 0;
+ move16();
+ *arith_bits = 0;
+ move16();
+ set32_fx( q_spectrum, 0, L_frame );
+
+ return;
+ }
+ }
+ ELSE
+ {
+ hm_bits = 1;
+ move16();
+ }
+ *signaling_bits = add( *signaling_bits, hm_bits );
+ move16();
+ }
+
+ L_spec_core = L_spec;
+ move16();
+ IF( st->igf )
+ {
+ L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine );
+ }
+
+ envelope = (Word16 *) env;
+ tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
+
+ *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e );
+ move16();
+
+ /* safety check in case of bit errors */
+ IF( *arith_bits < 0 )
+ {
+ st->BER_detect = 1;
+ move16();
+ set32_fx( q_spectrum, 0, L_frame );
+ }
+
+ set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) );
+
+ return;
+}
diff --git a/lib_dec/avq_dec.c b/lib_dec/avq_dec.c
deleted file mode 100644
index 1e54dc9d9b8ff20e758e5525619ab0e3aeaa5f7e..0000000000000000000000000000000000000000
--- a/lib_dec/avq_dec.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "cnst.h"
-#include "wmc_auto.h"
-#include
diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c
index 3bf7e3eb62ff897d2028a462d3e8f30c33ead199..a8ba2bfc3612253b30e153d2cb22f863afe3d4a4 100644
--- a/lib_dec/avq_dec_fx.c
+++ b/lib_dec/avq_dec_fx.c
@@ -7,7 +7,6 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot.h" /* Function prototypes */
#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c
deleted file mode 100644
index 478a814744be7f47d9ae8df548e54b14d10d289c..0000000000000000000000000000000000000000
--- a/lib_dec/bass_psfilter.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "prot_fx.h"
-#include "ivas_prot.h"
-#include "cnst.h"
-#include "stat_dec.h"
-#include "rom_com.h"
-#include
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-
-/*---------------------------------------------------------------------*
- * Local constants
- *---------------------------------------------------------------------*/
-
-
-#define NBPSF_L_EXTRA 120
-#define BPF_STOP_STOPBAND_16 16
-#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */
-#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */
-#define C_PC_DEC_FX 6583 /*in Q8*/
-
-/*---------------------------------------------------------------------*
- * Local function prototypes
- *---------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------*
- * bass_psfilter()
- *
- * Perform low-frequency postfiltering
- *---------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------*
- * Pit_track()
- *
- * Perform pitch tracking and test pitch/2 to avoid continuous pitch doubling
- *---------------------------------------------------------------------*/
-
-/*! r: Pitch */
-
-
-/*---------------------------------------------------------------------*
- * addBassPostFilter()
- *
- * Add BPF component in cldfb domain
- *---------------------------------------------------------------------*/
-
-
-void addBassPostFilter_ivas_fx(
- const Word32 *harm_timeIn_fx, // Qx
- const Word16 samplesToProcess,
- Word32 **rAnalysis_fx, // Qx - 5
- Word32 **iAnalysis_fx, // Qx - 5
- HANDLE_CLDFB_FILTER_BANK cldfb )
-{
- Word32 *tmp_R_fx[CLDFB_NO_COL_MAX];
- Word32 *tmp_I_fx[CLDFB_NO_COL_MAX];
- Word32 cldfbBufferReal_fx[CLDFB_NO_COL_MAX][20];
- Word32 cldfbBufferImag_fx[CLDFB_NO_COL_MAX][20];
- Word16 i, b;
- Word16 maxBand;
- const Word32 *weights_fx;
- Word16 nCol = cldfb->no_col;
- move16();
- Word16 nColToProcess = nCol;
- move16();
- Word16 nChan = cldfb->no_channels;
- move16();
- IF( GT_16( samplesToProcess, -1 ) )
- {
- nColToProcess = idiv1616( sub( add( samplesToProcess, cldfb->no_channels ), 1 ), cldfb->no_channels );
- move16();
- }
-
- assert( nCol == 16 );
-
- weights_fx = bpf_weights_16_ivas_fx_32;
-
- IF( GT_16( nChan, BPF_STOP_STOPBAND_16 ) )
- {
- maxBand = BPF_STOP_STOPBAND_16;
- move16();
- }
- ELSE
- {
- maxBand = nChan;
- move16();
- }
-
- FOR( i = 0; i < nColToProcess; i++ )
- {
- tmp_R_fx[i] = cldfbBufferReal_fx[i];
- tmp_I_fx[i] = cldfbBufferImag_fx[i];
- }
-
- cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb );
-
- /* now do the subtraction */
- FOR( i = 0; i < nColToProcess; i++ )
- {
- /* loop over low frequency bands */
- FOR( b = 0; b < maxBand; b++ )
- {
- rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6
- move32();
- iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6
- move32();
- }
- }
-
- return;
-}
-
-
-/*---------------------------------------------------------------------*
- * res_bpf_adapt_ivas_fx()
- *
- * Analyze BPF output and decide if it should be applied on DFT stereo
- * residual signal
- *---------------------------------------------------------------------*/
-
-/*! r: Decision to enable or disable BPF on DFT stereo residual */
-Word16 res_bpf_adapt_ivas_fx(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */
- const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */
- Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer Q12 */
- Word16 q_res )
-{
- Word32 error_nrg;
- Word32 tmp;
- Word32 res_hb_nrg;
- Word16 bpf_error_ratio;
- Word16 res_bpf_flag;
- Word16 i;
- Word16 i_start;
- Word16 i_end;
- Word16 bw_inv;
- Word64 W_tmp;
-
- IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) )
- {
- i_start = 39;
- move16();
- i_end = 64;
- move16();
- bw_inv = 1311;
- move16(); /* 1/(64 - 39) in Q15 */
- }
- ELSE
- {
- i_start = 28;
- move16();
- i_end = 40;
- move16();
- bw_inv = 2720;
- move16(); /* 1/(40 - 28) in Q15*/
- }
-
- /* Measure energy of high frequency band in MDCT domain */
- res_hb_nrg = L_deposit_l( 0 );
- W_tmp = W_deposit32_l( 0 );
- FOR( i = i_start; i < i_end; i++ )
- {
- W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) );
- }
-
- res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0
- res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0
- res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) );
- hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg;
- move32();
-
- /* Measure energy of discontinuities at subframe boundaries */
- error_nrg = 0;
- move32();
- FOR( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k )
- {
- tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx );
- error_nrg = Madd_32_32( error_nrg, tmp, tmp );
- hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )];
- move32();
- }
- error_nrg = L_shl( error_nrg, 1 ); // Q0
- error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */
- /* Form decision variable and apply limit */
- IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) )
- {
- Word16 temp;
- bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp );
- bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) );
- }
- ELSE
- {
- bpf_error_ratio = ONE_IN_Q14; // Q13
- move16();
- }
- bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) );
- hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio;
- move16();
-
- res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 );
- move16();
-
- return res_bpf_flag;
-}
-
-void bpf_pitch_coherence_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */
-)
-{
- Word16 nb_subfr;
- Word32 pc, pcn1, pcn2, pcn3;
- Word32 scaled_inv_L_frame; // Q8 + Q23
-
- SWITCH( st->L_frame )
- {
- case 80:
- scaled_inv_L_frame = 26843545; // 1/80 in Q31
- move32();
- BREAK;
- case 160:
- scaled_inv_L_frame = 13421773; // 1/160 in Q31
- move32();
- BREAK;
- case 256:
- scaled_inv_L_frame = 8388608; // 1/256 in Q31
- move32();
- BREAK;
- case 320:
- scaled_inv_L_frame = 6710886; // 1/320 in Q31
- move32();
- BREAK;
- case 512:
- scaled_inv_L_frame = 4194304; // 1/512 in Q31
- move32();
- BREAK;
- case 640:
- scaled_inv_L_frame = 3355443; // 1/640 in Q31
- move32();
- BREAK;
- case 960:
- scaled_inv_L_frame = 2236962; // 1/80 in Q31
- move32();
- BREAK;
- default:
- scaled_inv_L_frame = 0;
- move32();
- }
-
- nb_subfr = shr( st->L_frame, 6 );
- test();
- IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) )
- {
- pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) );
- pc = Mpy_32_32( pc, scaled_inv_L_frame );
- pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
- pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12
-
- pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
- pc = Mpy_32_32( pc, scaled_inv_L_frame );
- pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
- pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12
-
- pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
- pc = Mpy_32_32( pc, scaled_inv_L_frame );
- pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
- pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12
-
- IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) )
- {
- st->hBPF->psf_att_fx = 13107; //.4 in Q15
- move16(); /*Q15*/
- set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr );
- }
- }
-
- return;
-}
diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c
index c11e30c93af6770d9f053cd177f56482d43484d1..45cf7feed026f9c1ef1b419d1f21e5fb08b2691a 100644
--- a/lib_dec/bass_psfilter_fx.c
+++ b/lib_dec/bass_psfilter_fx.c
@@ -4,11 +4,12 @@
#include
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx.h" /* Function prototypes */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "rom_dec.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "ivas_prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "rom_dec.h" /* Static table prototypes */
#include "basop_util.h"
/*---------------------------------------------------------------------*
@@ -17,6 +18,9 @@
#define NBPSF_L_EXTRA 120
#define BPF_STOP_STOPBAND_16 16
+#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */
+#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */
+#define C_PC_DEC_FX 6583 /*in Q8*/
/*---------------------------------------------------------------------*
* Local function prototypes
@@ -837,14 +841,7 @@ void addBassPostFilter_fx(
}
/* do the CLDFB anlysis of filtered signal */
- cldfbAnalysisFiltering( cldfbBank_bpf_Fx,
- tmp_R_Fx,
- tmp_I_Fx,
- &scale,
- harm_timeIn_Fx,
- timeIn_e,
- nTimeSlots,
- workBuffer );
+ cldfbAnalysis_fx( cldfbBank_bpf_Fx, tmp_R_Fx, tmp_I_Fx, &scale, harm_timeIn_Fx, timeIn_e, nTimeSlots, workBuffer );
/* now do the subtraction */
@@ -889,6 +886,246 @@ void addBassPostFilter_fx(
return;
}
+/*---------------------------------------------------------------------*
+ * addBassPostFilter()
+ *
+ * Add BPF component in cldfb domain
+ *---------------------------------------------------------------------*/
+
+
+void addBassPostFilter_ivas_fx(
+ const Word32 *harm_timeIn_fx, // Qx
+ const Word16 samplesToProcess,
+ Word32 **rAnalysis_fx, // Qx - 5
+ Word32 **iAnalysis_fx, // Qx - 5
+ HANDLE_CLDFB_FILTER_BANK cldfb )
+{
+ Word32 *tmp_R_fx[CLDFB_NO_COL_MAX];
+ Word32 *tmp_I_fx[CLDFB_NO_COL_MAX];
+ Word32 cldfbBufferReal_fx[CLDFB_NO_COL_MAX][20];
+ Word32 cldfbBufferImag_fx[CLDFB_NO_COL_MAX][20];
+ Word16 i, b;
+ Word16 maxBand;
+ const Word32 *weights_fx;
+ Word16 nCol = cldfb->no_col;
+ move16();
+ Word16 nColToProcess = nCol;
+ move16();
+ Word16 nChan = cldfb->no_channels;
+ move16();
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ nColToProcess = idiv1616( sub( add( samplesToProcess, cldfb->no_channels ), 1 ), cldfb->no_channels );
+ move16();
+ }
+
+ assert( nCol == 16 );
+
+ weights_fx = bpf_weights_16_ivas_fx_32;
+
+ IF( GT_16( nChan, BPF_STOP_STOPBAND_16 ) )
+ {
+ maxBand = BPF_STOP_STOPBAND_16;
+ move16();
+ }
+ ELSE
+ {
+ maxBand = nChan;
+ move16();
+ }
+
+ FOR( i = 0; i < nColToProcess; i++ )
+ {
+ tmp_R_fx[i] = cldfbBufferReal_fx[i];
+ tmp_I_fx[i] = cldfbBufferImag_fx[i];
+ }
+
+ cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb );
+
+ /* now do the subtraction */
+ FOR( i = 0; i < nColToProcess; i++ )
+ {
+ /* loop over low frequency bands */
+ FOR( b = 0; b < maxBand; b++ )
+ {
+ rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6
+ move32();
+ iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6
+ move32();
+ }
+ }
+
+ return;
+}
+
+
+/*---------------------------------------------------------------------*
+ * res_bpf_adapt_ivas_fx()
+ *
+ * Analyze BPF output and decide if it should be applied on DFT stereo
+ * residual signal
+ *---------------------------------------------------------------------*/
+
+/*! r: Decision to enable or disable BPF on DFT stereo residual */
+Word16 res_bpf_adapt_ivas_fx(
+ STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */
+ const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */
+ Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer Q12 */
+ Word16 q_res )
+{
+ Word32 error_nrg;
+ Word32 tmp;
+ Word32 res_hb_nrg;
+ Word16 bpf_error_ratio;
+ Word16 res_bpf_flag;
+ Word16 i;
+ Word16 i_start;
+ Word16 i_end;
+ Word16 bw_inv;
+ Word64 W_tmp;
+
+ IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) )
+ {
+ i_start = 39;
+ move16();
+ i_end = 64;
+ move16();
+ bw_inv = 1311;
+ move16(); /* 1/(64 - 39) in Q15 */
+ }
+ ELSE
+ {
+ i_start = 28;
+ move16();
+ i_end = 40;
+ move16();
+ bw_inv = 2720;
+ move16(); /* 1/(40 - 28) in Q15*/
+ }
+
+ /* Measure energy of high frequency band in MDCT domain */
+ res_hb_nrg = L_deposit_l( 0 );
+ W_tmp = W_deposit32_l( 0 );
+ FOR( i = i_start; i < i_end; i++ )
+ {
+ W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) );
+ }
+
+ res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0
+ res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0
+ res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) );
+ hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg;
+ move32();
+
+ /* Measure energy of discontinuities at subframe boundaries */
+ error_nrg = 0;
+ move32();
+ FOR( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k )
+ {
+ tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx );
+ error_nrg = Madd_32_32( error_nrg, tmp, tmp );
+ hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )];
+ move32();
+ }
+ error_nrg = L_shl( error_nrg, 1 ); // Q0
+ error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */
+ /* Form decision variable and apply limit */
+ IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) )
+ {
+ Word16 temp;
+ bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp );
+ bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) );
+ }
+ ELSE
+ {
+ bpf_error_ratio = ONE_IN_Q14; // Q13
+ move16();
+ }
+ bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) );
+ hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio;
+ move16();
+
+ res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 );
+ move16();
+
+ return res_bpf_flag;
+}
+
+void bpf_pitch_coherence_ivas_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */
+)
+{
+ Word16 nb_subfr;
+ Word32 pc, pcn1, pcn2, pcn3;
+ Word32 scaled_inv_L_frame; // Q8 + Q23
+
+ SWITCH( st->L_frame )
+ {
+ case 80:
+ scaled_inv_L_frame = 26843545; // 1/80 in Q31
+ move32();
+ BREAK;
+ case 160:
+ scaled_inv_L_frame = 13421773; // 1/160 in Q31
+ move32();
+ BREAK;
+ case 256:
+ scaled_inv_L_frame = 8388608; // 1/256 in Q31
+ move32();
+ BREAK;
+ case 320:
+ scaled_inv_L_frame = 6710886; // 1/320 in Q31
+ move32();
+ BREAK;
+ case 512:
+ scaled_inv_L_frame = 4194304; // 1/512 in Q31
+ move32();
+ BREAK;
+ case 640:
+ scaled_inv_L_frame = 3355443; // 1/640 in Q31
+ move32();
+ BREAK;
+ case 960:
+ scaled_inv_L_frame = 2236962; // 1/80 in Q31
+ move32();
+ BREAK;
+ default:
+ scaled_inv_L_frame = 0;
+ move32();
+ }
+
+ nb_subfr = shr( st->L_frame, 6 );
+ test();
+ IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) )
+ {
+ pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) );
+ pc = Mpy_32_32( pc, scaled_inv_L_frame );
+ pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
+ pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12
+
+ pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
+ pc = Mpy_32_32( pc, scaled_inv_L_frame );
+ pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
+ pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12
+
+ pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
+ pc = Mpy_32_32( pc, scaled_inv_L_frame );
+ pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
+ pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12
+
+ IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) )
+ {
+ st->hBPF->psf_att_fx = 13107; //.4 in Q15
+ move16(); /*Q15*/
+ set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr );
+ }
+ }
+
+ return;
+}
+
+
#ifdef ADD_BPF_ADAPT
/*---------------------------------------------------------------------*
* res_bpf_adapt()
diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c
deleted file mode 100644
index 5f2ee4f7e204ef50b3c934c642685b7b02d1aaa8..0000000000000000000000000000000000000000
--- a/lib_dec/cng_dec.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "ivas_cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local function prototypes
- *---------------------------------------------------------------------*/
diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c
index 3590dae71f9caf434f47e419f4ffcb37e4d4d672..945f0ca758ed89671ff73a19fe0ba7ff25ab0357 100644
--- a/lib_dec/cng_dec_fx.c
+++ b/lib_dec/cng_dec_fx.c
@@ -6,7 +6,6 @@
#include "options.h" /* Compilation switches */
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
#include "prot_fx.h"
#include "ivas_cnst.h"
@@ -1378,9 +1377,8 @@ void swb_CNG_dec_fx(
Decoder_State *st_fx, /* i/o: State structure */
const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/
Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/
- const Word16 sid_bw /* i : 0-NB/WB, 1-SWB SID Q0*/
- ,
- const Word16 Qsyn /* i : Q value of ACELP core synthesis */
+ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/
+ const Word16 Qsyn /* i : Q value of ACELP core synthesis */
)
{
test();
@@ -1394,18 +1392,18 @@ void swb_CNG_dec_fx(
}
st_fx->last_vad_fx = 0;
move16();
- st_fx->hTdCngDec->burst_cnt = 0;
+ st_fx->hTdCngDec->burst_cnt_fx = 0;
move16();
}
ELSE
{
st_fx->last_vad_fx = 1;
move16();
- st_fx->hTdCngDec->burst_cnt = add( st_fx->hTdCngDec->burst_cnt, 1 );
+ st_fx->hTdCngDec->burst_cnt_fx = add( st_fx->hTdCngDec->burst_cnt_fx, 1 );
move16();
- if ( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) )
+ if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) )
{
- st_fx->hTdCngDec->burst_cnt = 0;
+ st_fx->hTdCngDec->burst_cnt_fx = 0;
move16();
}
}
@@ -1432,18 +1430,18 @@ void swb_CNG_dec_ivas_fx(
}
st_fx->last_vad_fx = 0;
move16();
- st_fx->hTdCngDec->burst_cnt = 0;
+ st_fx->hTdCngDec->burst_cnt_fx = 0;
move16();
}
ELSE
{
st_fx->last_vad_fx = 1;
move16();
- st_fx->hTdCngDec->burst_cnt = add_sat( st_fx->hTdCngDec->burst_cnt, 1 ); // saturation reached?
+ st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); // saturation reached?
move16();
- if ( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) )
+ if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) )
{
- st_fx->hTdCngDec->burst_cnt = 0;
+ st_fx->hTdCngDec->burst_cnt_fx = 0;
move16();
}
}
@@ -1467,6 +1465,7 @@ static void shb_CNG_decod_fx(
{
Word16 i;
Word16 idx_ener_fx;
+ TD_CNG_DEC_HANDLE hTdCngDec;
Word16 shb_lpcCNG_fx[LPC_SHB_ORDER + 1];
Word16 shb_lspCNG_fx[LPC_SHB_ORDER];
Word16 excTmp_fx[L_FRAME16k];
@@ -1490,7 +1489,9 @@ static void shb_CNG_decod_fx(
move16();
Word16 q;
TD_BWE_DEC_HANDLE hBWE_TD;
+
hBWE_TD = st_fx->hBWE_TD;
+ hTdCngDec = st_fx->hTdCngDec;
IF( st_fx->bfi == 0 )
{
@@ -1507,18 +1508,12 @@ static void shb_CNG_decod_fx(
IF( st_fx->element_mode == EVS_MONO )
{
/* de-quantization of SHB CNG parameters */
- L_tmp = L_mult( idx_ener_fx, 27400 ); /*Q14 */
- st_fx->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */
+ L_tmp = L_mult( idx_ener_fx, 27400 ); /*Q14 */
+ hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */
move16();
}
ELSE
{
-#ifdef IVAS_CODE_CNG
- /* de-quantization of SHB CNG parameters */ To be verified
- L_tmp = L_mult( idx_ener_fx, 17615 ); /*Q13*/
- st_fx->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 147962 ), 5 ) ); /*Q8 */
- move16();
-#endif
}
}
}
@@ -1526,21 +1521,21 @@ static void shb_CNG_decod_fx(
/* SHB spectrum estimation */
- interp_fx = s_min( st_fx->shb_dtx_count_fx, 32 );
+ interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 );
interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- tmp2 = mult( interp_fx, st_fx->lsp_shb_prev_fx[i] ); /*Q14*/
- tmp = mult( sub( 32767, interp_fx ), st_fx->lsp_shb_prev_prev_fx[i] ); /*Q14*/
+ tmp2 = mult( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ); /*Q14*/
+ tmp = mult( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ); /*Q14*/
shb_lspCNG_fx[i] = add( tmp2, tmp );
move16(); /*Q14*/
}
IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
- if ( LT_16( st_fx->shb_dtx_count_fx, 1000 ) )
+ if ( LT_16( hTdCngDec->shb_dtx_count_fx, 1000 ) )
{
- st_fx->shb_dtx_count_fx = add( st_fx->shb_dtx_count_fx, 1 );
+ hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 );
move16();
}
}
@@ -1549,9 +1544,6 @@ static void shb_CNG_decod_fx(
Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
-#ifdef IVAS_CODE_CNG
- // mvr2r(shb_lpcCNG, st->hTdCngDec->shb_lpcCNG, LPC_SHB_ORDER + 1);
-#endif
/* SHB energy estimation */
wb_ener_fx = L_deposit_l( 1 ); /*Q1 */
FOR( i = 0; i < L_FRAME32k; i++ )
@@ -1565,10 +1557,10 @@ static void shb_CNG_decod_fx(
wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
if ( !st_fx->first_CNG )
{
- st_fx->wb_cng_ener_fx = wb_ener16_fx;
+ hTdCngDec->wb_cng_ener_fx = wb_ener16_fx;
move16(); /*Q8 */
}
- if ( GT_16( abs_s( sub( wb_ener16_fx, st_fx->wb_cng_ener_fx ) ), 3072 ) )
+ if ( GT_16( abs_s( sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ) ), 3072 ) )
{
allow_cn_step_fx = 1;
move16();
@@ -1576,52 +1568,52 @@ static void shb_CNG_decod_fx(
IF( EQ_16( allow_cn_step_fx, 1 ) )
{
- st_fx->wb_cng_ener_fx = wb_ener16_fx;
+ hTdCngDec->wb_cng_ener_fx = wb_ener16_fx;
move16(); /*Q8 */
}
ELSE
{
- tmp = sub( wb_ener16_fx, st_fx->wb_cng_ener_fx ); /*Q8 */
- tmp = mult_r( tmp, 29491 ); /*Q8 */
- st_fx->wb_cng_ener_fx = add( st_fx->wb_cng_ener_fx, tmp ); /*Q8 */
+ tmp = sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ); /*Q8 */
+ tmp = mult_r( tmp, 29491 ); /*Q8 */
+ hTdCngDec->wb_cng_ener_fx = add( hTdCngDec->wb_cng_ener_fx, tmp ); /*Q8 */
move16();
}
test();
test();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st_fx->bfi == 0 ) )
{
- st_fx->last_wb_cng_ener_fx = st_fx->wb_cng_ener_fx;
+ hTdCngDec->last_wb_cng_ener_fx = hTdCngDec->wb_cng_ener_fx;
move16();
if ( !st_fx->first_CNG )
{
- st_fx->shb_cng_ener_fx = st_fx->last_shb_cng_ener_fx;
+ hTdCngDec->shb_cng_ener_fx = hTdCngDec->last_shb_cng_ener_fx;
move16();
}
}
- gain_fx = sub( st_fx->wb_cng_ener_fx, st_fx->last_wb_cng_ener_fx ); /* Q8 */
+ gain_fx = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */
if ( GT_16( gain_fx, 15 ) )
{
gain_fx = 15;
move16();
}
- step_fx = sub( add( gain_fx, st_fx->last_shb_cng_ener_fx ), st_fx->shb_cng_ener_fx ); /*Q8 */
+ step_fx = sub( add( gain_fx, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */
test();
IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st_fx->last_core_brate, SID_2k40 ) )
{
- st_fx->shb_cng_ener_fx = add( st_fx->shb_cng_ener_fx, step_fx ); /* Q8 */
+ hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, step_fx ); /* Q8 */
move16();
}
ELSE
{
- st_fx->shb_cng_ener_fx = add( st_fx->shb_cng_ener_fx, mult( 8192, step_fx ) ); /*Q8 */
+ hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, mult( 8192, step_fx ) ); /*Q8 */
move16();
}
/* generate white noise excitation */
FOR( i = 0; i < L_FRAME16k; i++ )
{
- excTmp_fx[i] = shr_r( Random( &st_fx->swb_cng_seed ), 8 );
+ excTmp_fx[i] = shr_r( Random( &hTdCngDec->swb_cng_seed ), 8 );
move16(); /*Q-8*/
}
@@ -1642,23 +1634,23 @@ static void shb_CNG_decod_fx(
ener_excSHB_fx = round_fx( L_tmp ); /*Qq */
IF( EQ_16( st_fx->last_vad_fx, 1 ) )
{
- st_fx->trans_cnt_fx = 0;
+ hTdCngDec->trans_cnt_fx = 0;
move16();
test();
- IF( GT_16( st_fx->hTdCngDec->burst_cnt, 3 ) && NE_16( st_fx->last_core, HQ_CORE ) )
+ IF( GT_16( hTdCngDec->burst_cnt_fx, 3 ) && NE_16( st_fx->last_core, HQ_CORE ) )
{
- st_fx->trans_cnt_fx = 5;
+ hTdCngDec->trans_cnt_fx = 5;
move16();
}
}
- ener_fx = st_fx->shb_cng_ener_fx;
+ ener_fx = hTdCngDec->shb_cng_ener_fx;
move16(); /*Q8 */
- IF( st_fx->trans_cnt_fx > 0 )
+ IF( hTdCngDec->trans_cnt_fx > 0 )
{
- i = extract_l( L_mult0( st_fx->trans_cnt_fx, 17 ) ); /*Q0 */
- ener_fx = add_sat( st_fx->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( st_fx->last_shb_ener_fx, st_fx->shb_cng_ener_fx ) ) ); /*Q8 */
- st_fx->trans_cnt_fx = sub( st_fx->trans_cnt_fx, 1 );
+ i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */
+ ener_fx = add_sat( hTdCngDec->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( hTdCngDec->last_shb_ener_fx, hTdCngDec->shb_cng_ener_fx ) ) ); /*Q8 */
+ hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 );
move16();
}
@@ -1695,9 +1687,7 @@ static void shb_CNG_decod_fx(
L_tmp = L_deposit_h( tmp ); /*Q31 */
tmp = sub( add( 5, exp ), add( q, exp1 ) );
L_gain_fx = Isqrt_lc( L_tmp, &tmp ); /*Q31-Qtmp */
-#ifdef IVAS_CODE_CNG
- st->hTdCngDec->shb_cng_gain = ener_fx;
-#endif
+
FOR( i = 0; i < L_FRAME16k; i++ )
{
shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
@@ -1710,13 +1700,13 @@ static void shb_CNG_decod_fx(
/* rescale the Hilbert memories to Q0 */
FOR( i = 0; i < HILBERT_MEM_SIZE; i++ )
{
- hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], st_fx->prev_Q_bwe_syn2 ); /* st_fx->prev_Q_bwe_syn2 */
+ hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */
move32();
}
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
- hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], st_fx->prev_Q_bwe_syn2 ); /* st_fx->prev_Q_bwe_syn2 */
+ hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */
move16();
}
}
@@ -1724,13 +1714,10 @@ static void shb_CNG_decod_fx(
IF( EQ_32( st_fx->output_Fs, 48000 ) )
{
- interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, st_fx->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
+ interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
}
-#ifdef IVAS_CODE_CNG
- ResetSHBbuffer_Dec( st->hBWE_TD, st->extl );
-#else
- ResetSHBbuffer_Dec_fx( st_fx );
-#endif
+
+ ResetSHBbuffer_Dec_fx( st_fx->hBWE_TD, st_fx->extl );
return;
}
@@ -1744,6 +1731,7 @@ static void shb_CNG_decod_ivas_fx(
{
Word16 i;
Word16 idx_ener;
+ TD_CNG_DEC_HANDLE hTdCngDec;
Word16 shb_lpcCNG_fx[LPC_SHB_ORDER + 1];
Word16 shb_lspCNG_fx[LPC_SHB_ORDER];
Word16 excTmp_fx[L_FRAME16k];
@@ -1765,7 +1753,9 @@ static void shb_CNG_decod_ivas_fx(
Word16 allow_cn_step_fx;
Word16 q;
TD_BWE_DEC_HANDLE hBWE_TD;
+
hBWE_TD = st->hBWE_TD;
+ hTdCngDec = st->hTdCngDec;
allow_cn_step_fx = 0;
move16();
@@ -1785,37 +1775,37 @@ static void shb_CNG_decod_ivas_fx(
/* de-quantization of SHB CNG parameters */
IF( st->element_mode == EVS_MONO )
{
- st->hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11
+ hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11
move32();
}
ELSE
{
- st->hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 8807 ), 36991 ); // Q11
+ hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 8807 ), 36991 ); // Q11
move32();
}
}
}
/* SHB spectrum estimation */
- interp_fx = s_min( st->hTdCngDec->shb_dtx_count, 32 );
+ interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 );
interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- shb_lspCNG_fx[i] = add( mult_r( interp_fx, st->hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), st->hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14
+ shb_lspCNG_fx[i] = add( mult_r( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14
move16();
}
- IF( LE_16( st->hTdCngDec->shb_dtx_count, 1000 ) )
+ IF( LE_16( hTdCngDec->shb_dtx_count_fx, 1000 ) )
{
- st->hTdCngDec->shb_dtx_count = add( st->hTdCngDec->shb_dtx_count, 1 );
+ hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 );
move16();
}
E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/
E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER );
- Copy_Scale_sig( shb_lpcCNG_fx, st->hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */
+ Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */
Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
@@ -1836,10 +1826,10 @@ static void shb_CNG_decod_ivas_fx(
Word32 wb_ener32_fx = L_shl( wb_ener16_fx, 3 ); /*wb_ener_fx in Q11 */
if ( EQ_16( st->first_CNG, 0 ) )
{
- st->hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
+ hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
move32(); /*Q11 */
}
- if ( GT_32( L_abs( L_sub( wb_ener32_fx, st->hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) ) /* 12.0f in Q11 */
+ if ( GT_32( L_abs( L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) ) /* 12.0f in Q11 */
{
allow_cn_step_fx = 1;
move16();
@@ -1847,52 +1837,52 @@ static void shb_CNG_decod_ivas_fx(
IF( EQ_16( allow_cn_step_fx, 1 ) )
{
- st->hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
+ hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
move32(); /*Q11 */
}
ELSE
{
- tmp = L_sub( wb_ener32_fx, st->hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */
- tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */
- st->hTdCngDec->wb_cng_ener_fx_32 = L_add( st->hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */
+ tmp = L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */
+ tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */
+ hTdCngDec->wb_cng_ener_fx_32 = L_add( hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */
move32();
}
test();
test();
IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && EQ_16( st->bfi, 0 ) )
{
- st->hTdCngDec->last_wb_cng_ener_fx_32 = st->hTdCngDec->wb_cng_ener_fx_32; /* Q11 */
+ hTdCngDec->last_wb_cng_ener_fx_32 = hTdCngDec->wb_cng_ener_fx_32; /* Q11 */
move32();
if ( !st->first_CNG )
{
- st->hTdCngDec->shb_cng_ener_fx_32 = st->hTdCngDec->last_shb_cng_ener_fx_32; /* Q11 */
+ hTdCngDec->shb_cng_ener_fx_32 = hTdCngDec->last_shb_cng_ener_fx_32; /* Q11 */
move32();
}
}
- gain_fx = L_sub( st->hTdCngDec->wb_cng_ener_fx_32, st->hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */
+ gain_fx = L_sub( hTdCngDec->wb_cng_ener_fx_32, hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */
if ( GT_32( gain_fx, 30720 ) )
{
gain_fx = 30720;
move32();
}
- step_fx = L_sub( L_add( gain_fx, st->hTdCngDec->last_shb_cng_ener_fx_32 ), st->hTdCngDec->shb_cng_ener_fx_32 ); /*Q11 */
+ step_fx = L_sub( L_add( gain_fx, hTdCngDec->last_shb_cng_ener_fx_32 ), hTdCngDec->shb_cng_ener_fx_32 ); /*Q11 */
test();
IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) )
{
- st->hTdCngDec->shb_cng_ener_fx_32 = L_add( st->hTdCngDec->shb_cng_ener_fx_32, step_fx ); /* Q11 */
+ hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, step_fx ); /* Q11 */
move32();
}
ELSE
{
- st->hTdCngDec->shb_cng_ener_fx_32 = L_add( st->hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */
+ hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */
move32();
}
/* generate white noise excitation */
FOR( i = 0; i < L_FRAME16k; i++ )
{
- excTmp_fx[i] = shr_r( Random( &st->hTdCngDec->swb_cng_seed ), 8 );
+ excTmp_fx[i] = shr_r( Random( &hTdCngDec->swb_cng_seed ), 8 );
move16(); /*Q-8*/
}
@@ -1911,29 +1901,26 @@ static void shb_CNG_decod_ivas_fx(
L_tmp = L_shl( L_tmp, q );
q = sub( q, 32 );
ener_excSHB_fx = round_fx( L_tmp ); /*Qq */
-#ifdef MSAN_FIX
+
IF( EQ_16( st->last_vad_fx, 1 ) )
-#else
- IF( EQ_16( st->last_vad, 1 ) )
-#endif
{
- st->hTdCngDec->trans_cnt = 0;
+ hTdCngDec->trans_cnt_fx = 0;
move16();
test();
- if ( GT_16( st->hTdCngDec->burst_cnt, 3 ) && NE_16( st->last_core, HQ_CORE ) )
+ if ( GT_16( hTdCngDec->burst_cnt_fx, 3 ) && NE_16( st->last_core, HQ_CORE ) )
{
- st->hTdCngDec->trans_cnt = 5;
+ hTdCngDec->trans_cnt_fx = 5;
move16();
}
}
- ener_fx = st->hTdCngDec->shb_cng_ener_fx_32;
+ ener_fx = hTdCngDec->shb_cng_ener_fx_32;
move32(); /*Q11 */
- IF( GT_16( st->hTdCngDec->trans_cnt, 0 ) )
+ IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) )
{
- i = extract_l( L_mult0( st->hTdCngDec->trans_cnt, 17 ) ); /*Q0 */
- ener_fx = L_add( st->hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( st->hTdCngDec->last_shb_ener_fx, st->hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */
- st->hTdCngDec->trans_cnt = sub( st->hTdCngDec->trans_cnt, 1 );
+ i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */
+ ener_fx = L_add( hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( hTdCngDec->last_shb_ener_fx_32, hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */
+ hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 );
move16();
}
@@ -1975,7 +1962,7 @@ static void shb_CNG_decod_ivas_fx(
L_tmp = L_deposit_h( tmp_16 ); /*Q31 */
tmp_16 = sub( add( 5, exp ), add( q, exp1 ) );
L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */
- st->hTdCngDec->shb_cng_gain_fx_32 = ener_fx;
+ hTdCngDec->shb_cng_gain_fx_32 = ener_fx;
move32();
FOR( i = 0; i < L_FRAME16k; i++ )
{
@@ -1989,13 +1976,13 @@ static void shb_CNG_decod_ivas_fx(
/* rescale the Hilbert memories to Q0 */
FOR( i = 0; i < HILBERT_MEM_SIZE; i++ )
{
- hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], st->prev_Q_bwe_syn2 ); /* st_fx->prev_Q_bwe_syn2 */
+ hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */
move32();
}
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
- hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], st->prev_Q_bwe_syn2 ); /* st_fx->prev_Q_bwe_syn2 */
+ hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */
move16();
}
}
@@ -2003,11 +1990,13 @@ static void shb_CNG_decod_ivas_fx(
IF( EQ_32( st->output_Fs, 48000 ) )
{
- interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, st->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
+ interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
}
Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */
- ResetSHBbuffer_Dec_fx( st );
+
+ ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl );
+
return;
}
@@ -2020,96 +2009,6 @@ static void shb_CNG_decod_ivas_fx(
void td_cng_dec_init_fx(
DEC_CORE_HANDLE st /* i/o: decoder state structure */
)
-{
- TD_CNG_DEC_HANDLE hTdCngDec;
-
- hTdCngDec = st->hTdCngDec;
-
- hTdCngDec->cng_seed = RANDOM_INITSEED;
- move16();
- hTdCngDec->cng_ener_seed = RANDOM_INITSEED;
- move16();
- hTdCngDec->cng_ener_seed1 = RANDOM_INITSEED;
- move16();
- hTdCngDec->old_enr_index = -1;
- move16();
- hTdCngDec->Enew_fx = L_deposit_l( 0 ); /* Q6*/
- move16();
- hTdCngDec->last_allow_cn_step = 0;
- move16();
-#ifdef IVAS_CODE_CNG
- // mvr2r(st->lsp_old, st->lspCNG, M);
- // hTdCngDec->shb_cng_ener = -6.02f;
- IF( st->element_mode != EVS_MONO )
- {
- // set_f(hTdCngDec->shb_lpcCNG, 0.0f, LPC_SHB_ORDER + 1);
- // hTdCngDec->shb_lpcCNG[0] = 1.0f;
- // hTdCngDec->shb_cng_gain = -82.0; /* a dB value approximately corresponding to shb index 0(used as index -15) */
- }
- // hTdCngDec->wb_cng_ener = -6.02f;
- // hTdCngDec->last_wb_cng_ener = -6.02f;
- // hTdCngDec->last_shb_cng_ener = -6.02f;
- // hTdCngDec->swb_cng_seed = RANDOM_INITSEED;
-#endif
- hTdCngDec->ho_hist_ptr = -1;
- move16();
- hTdCngDec->ho_sid_bw = L_deposit_l( 0 );
- move16();
- set16_fx( hTdCngDec->ho_lsp_hist_fx, 0, HO_HIST_SIZE * M );
- set32_fx( hTdCngDec->ho_ener_hist_fx, 0, HO_HIST_SIZE );
- set32_fx( hTdCngDec->ho_env_hist_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG );
- hTdCngDec->ho_hist_size = 0;
- move16();
- hTdCngDec->act_cnt = 0;
- move16();
- hTdCngDec->ho_circ_ptr = -1;
- move16();
- set16_fx( hTdCngDec->ho_lsp_circ_fx, 0, HO_HIST_SIZE * M );
- set32_fx( hTdCngDec->ho_ener_circ_fx, 0, HO_HIST_SIZE );
- set32_fx( hTdCngDec->ho_env_circ_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG );
- hTdCngDec->ho_circ_size = 0;
- move16();
-
- set16_fx( hTdCngDec->ho_16k_lsp, 0, HO_HIST_SIZE );
- hTdCngDec->act_cnt2 = 0;
- move16();
- hTdCngDec->num_ho = 0;
- move16();
- hTdCngDec->last_cng_type_fx = -1;
- move16();
- set32_fx( hTdCngDec->lp_env_fx, 0, NUM_ENV_CNG );
- set16_fx( hTdCngDec->exc_mem_fx, 0, 24 );
- set16_fx( hTdCngDec->exc_mem1_fx, 0, 30 );
- set32_fx( hTdCngDec->old_env_fx, 0, NUM_ENV_CNG );
-#ifdef IVAS_CODE_CNG
- // st->CNG_mode = -1;
- // for (i = 0; i < LPC_SHB_ORDER; i++)
- //{
- // IF (st->element_mode != EVS_MONO)
- // {
- // hTdCngDec->lsp_shb_prev[i] = 0.5f * ((float)(i + 1)) / ((float)(LPC_SHB_ORDER + 1));
- // }
- // else
- // {
- // hTdCngDec->lsp_shb_prev[i] = 0.5f * ((float)i) / ((float)LPC_SHB_ORDER);
- // }
- // hTdCngDec->lsp_shb_prev_prev[i] = hTdCngDec->lsp_shb_prev[i];
- // }
-
- // hTdCngDec->shb_dtx_count = 0;
- // hTdCngDec->trans_cnt = 0;
- // hTdCngDec->last_shb_ener = 0.001f;
- // set_f(hTdCngDec->interpol_3_2_cng_dec, 0.0f, INTERP_3_2_MEM_LEN);
-#endif
- hTdCngDec->burst_cnt = 0;
- move16();
-
- return;
-}
-
-void td_cng_dec_init_ivas_fx(
- DEC_CORE_HANDLE st /* i/o: decoder state structure */
-)
{
Word16 i;
TD_CNG_DEC_HANDLE hTdCngDec;
@@ -2129,6 +2028,8 @@ void td_cng_dec_init_ivas_fx(
Copy( st->lsp_old_fx, st->lspCNG_fx, M ); // Q(15)
hTdCngDec->last_allow_cn_step = 0;
move16();
+ hTdCngDec->shb_cng_ener_fx = -1541; // Q8
+ move16();
hTdCngDec->shb_cng_ener_fx_32 = -12329; // -6.02 in Q(11)
move32();
IF( st->element_mode != EVS_MONO )
@@ -2140,10 +2041,16 @@ void td_cng_dec_init_ivas_fx(
move32();
}
+ hTdCngDec->wb_cng_ener_fx = -1541; // Q8
+ move16();
hTdCngDec->wb_cng_ener_fx_32 = -12329; // Q(11)
move32();
+ hTdCngDec->last_wb_cng_ener_fx = -1541; // Q8
+ move16();
hTdCngDec->last_wb_cng_ener_fx_32 = -12329; // Q(11)
move32();
+ hTdCngDec->last_shb_cng_ener_fx = -1541; // Q8
+ move16();
hTdCngDec->last_shb_cng_ener_fx_32 = -12329; // Q(11)
move32();
hTdCngDec->swb_cng_seed = RANDOM_INITSEED;
@@ -2195,17 +2102,18 @@ void td_cng_dec_init_ivas_fx(
move16();
}
- hTdCngDec->shb_dtx_count = 0;
+ hTdCngDec->shb_dtx_count_fx = 0;
move16();
- hTdCngDec->trans_cnt = 0;
+ hTdCngDec->trans_cnt_fx = 0;
move16();
- hTdCngDec->burst_cnt = 0;
+ hTdCngDec->burst_cnt_fx = 0;
move16();
- hTdCngDec->last_shb_ener_fx = 2; // 0.001 in Q11
+ hTdCngDec->last_shb_ener_fx = 0; // Q8
+ move16();
+ hTdCngDec->last_shb_ener_fx_32 = 2; // 0.001 in Q11
move32();
-
set16_fx( hTdCngDec->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN );
return;
diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c
deleted file mode 100644
index 37c397bbf8c4ba8044d86fd7d321d3f04956186e..0000000000000000000000000000000000000000
--- a/lib_dec/core_dec_init.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "stat_com.h"
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-/*-----------------------------------------------------------------------*
- * open_decoder_LPD()
- *
- * Initialization of state variables
- *-----------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------*
- * tcxltp_dec_init()
- *
- * Initialization TCX-LTP handle
- *-----------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------*
- * reset_tcx_overl_buf()
- *
- * Reset TCX core overlap buffers
- *-----------------------------------------------------------------------*/
-
-void reset_tcx_overl_buf_fx(
- TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */
-)
-{
- set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
- hTcxDec->Q_old_syn_Overl = 0;
- move16();
- set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
- hTcxDec->Q_syn_Overl_TDAC = 0;
- move16();
- set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
- hTcxDec->Q_syn_Overl = 0;
- move16();
- set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
- hTcxDec->Q_syn_Overl_TDACFB = 0;
- move16();
- return;
-}
-
-/*-----------------------------------------------------------------------*
- * acelp_plc_mdct_transition()
- *
- * Prepare MDCT OLA memories in TCX/HQ after ACELP PLC
- *-----------------------------------------------------------------------*/
diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c
index 671dbfd2ca520671ad8ab10abb004f32f8b055f2..967a93bfbb1a0f63da3846387ed0f3b0ccfb998e 100644
--- a/lib_dec/core_dec_init_fx.c
+++ b/lib_dec/core_dec_init_fx.c
@@ -7,7 +7,6 @@
#include
#include
#include "options.h"
-#include "prot.h"
#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -837,7 +836,7 @@ void open_decoder_LPD_fx(
st->Mode2_lp_gainp = L_deposit_l( 0 ); /* 15Q16 */
move32();
- st->prev_widow_left_rect = 0;
+ st->hTcxDec->prev_widow_left_rect = 0;
move16();
if ( st->hTcxDec != NULL )
{
@@ -1030,33 +1029,29 @@ void open_decoder_LPD_fx(
test();
IF( EQ_16( st->ini_frame, 0 ) || LT_32( st->last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset )
{
- concealment_init_x( hTcxDec->L_frameTCX, &st->plcInfo );
+ concealment_init_x( hTcxDec->L_frameTCX, st->hPlcInfo );
}
}
/* PLC: [TCX: Tonal Concealment] */
-#if 0
- PMT("handle to tonalMDCTconceal is missing")
-#endif
- //#ifdef ADD_IVAS_HTONALMDCTCONC
test();
test();
- IF( /*st->ADD_IVAS_HTONALMDCTCONC != NULL &&*/ !( st->element_mode > EVS_MONO && NE_16( st->ini_frame, 0 ) && EQ_16( st->tonalMDCTconceal.nSamples, st->hTcxDec->L_frameTCX ) ) )
+ IF( st->hTonalMDCTConc != NULL && !( st->element_mode > EVS_MONO && NE_16( st->ini_frame, 0 ) && EQ_16( st->hTonalMDCTConc->nSamples, st->hTcxDec->L_frameTCX ) ) )
{
- st->tonalMDCTconceal.nScaleFactors = 0;
+ st->hTonalMDCTConc->nScaleFactors = 0;
move16();
- st->tonalMDCTconceal.nSamples = 0;
+ st->hTonalMDCTConc->nSamples = 0;
move16();
- st->tonalMDCTconceal.lastPcmOut = 0x0;
+ st->hTonalMDCTConc->lastPcmOut = 0x0;
move16();
- st->tonalMDCTconceal.q_lastPcmOut = Q15;
+ st->hTonalMDCTConc->q_lastPcmOut = Q15;
move16();
- st->tonalMDCTconceal.lastBlockData.tonalConcealmentActive = 0;
+ st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0;
move16();
- st->tonalMDCTconceal.lastBlockData.nSamples = 0;
+ st->hTonalMDCTConc->lastBlockData.nSamples = 0;
move16();
- TonalMDCTConceal_Init( &st->tonalMDCTconceal, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
+ TonalMDCTConceal_Init( st->hTonalMDCTConc, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
}
st->last_tns_active = 0;
move16();
@@ -2191,3 +2186,28 @@ void open_decoder_LPD_ivas_fx(
return;
}
+
+/*-----------------------------------------------------------------------*
+ * reset_tcx_overl_buf()
+ *
+ * Reset TCX core overlap buffers
+ *-----------------------------------------------------------------------*/
+
+void reset_tcx_overl_buf_fx(
+ TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */
+)
+{
+ set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ hTcxDec->Q_old_syn_Overl = 0;
+ move16();
+ set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ hTcxDec->Q_syn_Overl_TDAC = 0;
+ move16();
+ set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ hTcxDec->Q_syn_Overl = 0;
+ move16();
+ set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ hTcxDec->Q_syn_Overl_TDACFB = 0;
+ move16();
+ return;
+}
diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c
deleted file mode 100644
index 6bcd541efef2e50b01803c49ce5d67dc175b8a8b..0000000000000000000000000000000000000000
--- a/lib_dec/core_dec_reconf.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "rom_dec.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c
deleted file mode 100644
index 09bd8e8464de50d5ca238dbb031eefed2d7a28f9..0000000000000000000000000000000000000000
--- a/lib_dec/core_dec_switch.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------*
- * mode_switch_decoder_LPD()
- *
- *
- *-------------------------------------------------------------*/
diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c
index c7d2c526574e7a61c710be168e72836de7c5b81b..63c35f876e3da1d41836c8b99f588463a42c8502 100644
--- a/lib_dec/core_dec_switch_fx.c
+++ b/lib_dec/core_dec_switch_fx.c
@@ -8,7 +8,6 @@
#include "basop_util.h"
#include "prot_fx.h"
#include "rom_com.h"
-#include "prot.h"
void mode_switch_decoder_LPD_fx(
Decoder_State *st, /* i/o: decoder state structure */
@@ -198,11 +197,7 @@ void mode_switch_decoder_LPD_fx(
( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) ||
( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) )
{
-#ifdef IVAS_CODE
TBEreset_dec_fx( st );
-#else
- TBEreset_dec_fx( st, st->bwidth );
-#endif
}
ELSE
{
@@ -446,7 +441,7 @@ void mode_switch_decoder_LPD_ivas_fx(
( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) ||
( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) )
{
- TBEreset_dec_ivas_fx( st );
+ TBEreset_dec_fx( st );
}
ELSE
{
diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c
deleted file mode 100644
index 4c48a6fa870f591d77cb92bb17d7ba477ad7da55..0000000000000000000000000000000000000000
--- a/lib_dec/core_switching_dec.c
+++ /dev/null
@@ -1,1076 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "prot_fx.h"
-#include "ivas_cnst.h"
-#include "wmc_auto.h"
-
-#include "ivas_prot_fx.h"
-#include "debug.h"
-/*---------------------------------------------------------------------*
- * Local prototypes
- *---------------------------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------*
- * core_switching_pre_dec()
- *
- * Preprocessing/preparation for ACELP/HQ core switching
- *---------------------------------------------------------------------*/
-ivas_error core_switching_pre_dec_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word16 output_frame, /* i : frame length */
- const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
- const Word16 nchan_out, /* i : number of output channels */
- const Word16 last_element_mode, /* i : last_element_mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- Word16 Q_old_synthFB,
- Word16 *Q_olapBufferSynth,
- Word16 *Q_olapBufferSynth2 )
-{
- Word32 tmp_fx; /*Q-12*/
- Word16 i, oldLenClasBuff, newLenClasBuff;
- ivas_error error;
- Word16 exp = 25;
- move16();
- error = IVAS_ERR_OK;
- move32();
-
- /* Codec mode switching */
- test();
- test();
- test();
- IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) )
- {
- st->mem_deemph_fx = st->syn[M];
- move16();
- set16_fx( st->agc_mem_fx, 0, 2 );
- Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */
-
- Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
-
- st->bpf_off = 1;
- move16();
- IF( st->hPFstat != NULL )
- {
- Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/
- Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/
- Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/
- set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/
- }
- IF( st->hBPF != NULL )
- {
- st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */
- st->hBPF->pst_mem_deemp_err_fx = 0;
- move16();
- move16();
- }
- st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); // Q(23+1-16)->Q8
- move16();
-
- /* reset old HB synthesis buffer */
- IF( EQ_16( st->last_L_frame, L_FRAME ) )
- {
- st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS );
- }
- ELSE
- {
- st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
- }
- move16();
- set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) );
-
- test();
- IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) )
- {
-#ifdef MSAN_FIX
- st->hBWE_TD->prev_hb_synth_fx_exp = 31;
- move16();
-#endif // MSAN_FIX
- /* reset BWE memories */
- set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
-
- /* reset upd_cnt */
- st->upd_cnt = MAX_UPD_CNT;
- move16();
-
- st->igf = 0;
- move16();
-
- test();
- IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
- {
- hf_synth_reset_fx( st->hBWE_zero );
-#ifdef MSAN_FIX
- set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
-#endif
- }
-
- IF( st->hBWE_FD != NULL )
- {
- set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
-
- IF( st->hHQ_core != NULL )
- {
- set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB );
-
- set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
-
- st->hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- IF( GT_32( st->output_Fs, 16000 ) )
- {
- set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
- }
-
- /* pre-echo */
- st->hHQ_core->pastpre = 0;
- move16();
- }
-
- /* reset the GSC pre echo energy threshold in case of switching */
- if ( st->hGSCDec != NULL )
- {
- st->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
-
- test();
- IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
- {
- IF( st->element_mode == EVS_MONO )
- {
- st->last_core = HQ_CORE;
- move16();
-
- Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
- // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0
- }
-
- IF( st->hHQ_core != NULL )
- {
- set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
- st->hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM );
- st->hHQ_core->prev_frm_hfe2 = 0;
- st->hHQ_core->prev_stab_hfe2 = 0;
- move16();
- move16();
- }
- }
-
- IF( st->prev_bfi != 0 )
- {
- Word16 delay_comp;
-
- /*switch off Hq Voicing as it was not updated in MODE2*/
- IF( st->hHQ_core != NULL )
- {
- st->hHQ_core->oldHqVoicing = 0;
- st->hHQ_core->HqVoicing = 0;
- move16();
- move16();
- }
-
- delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
- /*TODO To be tested:control not entering the block*/
- test();
- test();
- IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
- {
- /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/
- assert( 0 );
- Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH];
- Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX];
- Word32 syn_Overl_fx[320];
- Word32 fer_samples_fx[960];
- Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 );
- Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 );
-
-
- FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
- {
- set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer_fx[i] = realBufferTmp_fx[i];
- imagBuffer_fx[i] = imagBufferTmp_fx[i];
- }
-
- /* CLDFB analysis of the synthesis at internal sampling rate */
- IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna );
- cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/
-
- /* CLDFB synthesis of the combined signal */
- IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, st->cldfbSyn );
- cldfb_restore_memory_ivas_fx( st->cldfbSyn );
- Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 );
- Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 );
- }
-
- test();
- test();
- IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
- {
- lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) );
- /*Set to zero the remaining part*/
- set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) );
- }
- }
-
- st->use_acelp_preq = 0;
- st->reset_mem_AR = 0;
- move16();
- move16();
- }
-
- /*FEC*/
- IF( LE_16( st->L_frame, L_FRAME16k ) )
- {
- test();
- IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) )
- {
- IF( NE_16( st->L_frame, st->last_L_frame ) )
- {
- IF( GT_16( st->L_frame, st->last_L_frame ) )
- {
- oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) );
- newLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
- move16();
- }
- ELSE
- {
- oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
- move16();
- newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) );
- }
- lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff );
- }
- }
- ELSE
- {
- set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM );
- }
- }
-
- /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores
- within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
- test();
- test();
- IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) )
- {
- st->last_ppp_mode_dec = 0;
- st->last_nelp_mode_dec = 0;
- move16();
- move16();
- }
-
- /* Handle state reset of stat_noise_uv_mod memory */
- test();
- test();
- test();
- IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) )
- {
- st->act_count = 3;
- st->uv_count = 0;
- move16();
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) &&
- NE_32( st->core_brate, SID_2k40 ) && ( st->core_brate != FRAME_NO_DATA ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) )
- {
- test();
- if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- st->hPFstat->reset = 1;
- move16();
- }
-
- IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */
- Copy( TRWB2_Ave_fx, st->lsfoldbfi1_fx, M );
- Copy( TRWB2_Ave_fx, st->lsfoldbfi0_fx, M );
- Copy( TRWB2_Ave_fx, st->lsf_adaptive_mean_fx, M );
- lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k );
- }
- ELSE
- {
- Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */
- Copy( TRWB_Ave_fx, st->lsfoldbfi1_fx, M );
- Copy( TRWB_Ave_fx, st->lsfoldbfi0_fx, M );
- Copy( TRWB_Ave_fx, st->lsf_adaptive_mean_fx, M );
- lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 );
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL )
- {
- /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */
- set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 );
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN );
- set16_fx( st->agc_mem_fx, 0, 2 );
- }
- st->mem_deemph_fx = 0;
- move16();
- IF( !st->last_con_tcx )
- {
- set16_fx( st->mem_syn2_fx, 0, M );
- }
- set16_fx( st->mem_syn1_fx, 0, M );
- if ( st->hBWE_TD != NULL )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
-
- /* Reset ACELP parameters */
- set16_fx( st->mem_MA_fx, 0, M );
-
- IF( EQ_32( st->sr_core, INT_FS_16k ) )
- {
- Copy( GEWB2_Ave_fx, st->mem_AR_fx, M );
- }
- ELSE
- {
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
- }
-
- st->tilt_code_fx = 0;
- st->gc_threshold_fx = 0;
- st->dm_fx.prev_gain_code = 0;
- st->dm_fx.prev_state = 0;
- move16();
- move32();
- move32();
- move16();
- set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
-
- st->last_coder_type = GENERIC;
- move16();
-
- fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
- st->lp_gainp_fx = 0;
- move16();
- st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/
- move16();
- st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/
- move16();
-
- st->last_voice_factor_fx = 0;
- st->Last_GSC_noisy_speech_flag = 0;
- move16();
- move16();
-
- /* reset CLDFB memories */
- cldfb_reset_memory_fx( st->cldfbAna );
- cldfb_reset_memory_fx( st->cldfbBPF );
- cldfb_reset_memory_fx( st->cldfbSyn );
-
- /* reset TBE memories */
- test();
- test();
- IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && ( st->element_mode > EVS_MONO ) ) )
- {
- set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC );
- }
- ELSE IF( LT_16( st->L_frame, L_FRAME16k ) )
- {
- /* resample from 16kHz to 12.8kHZ */
- synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC );
- }
-
- IF( st->hBWE_TD != NULL )
- {
- set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- }
-
- test();
- IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
- {
- hf_synth_reset_fx( st->hBWE_zero );
-#ifdef MSAN_FIX
- set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
-#endif
- }
-
- IF( st->hBWE_FD != NULL )
- {
- set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
- }
-
- test();
- test();
- test();
- IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) )
- {
- IF( st->hBWE_TD != NULL )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- }
-
- st->tilt_code_fx = 0;
- st->gc_threshold_fx = 0;
- st->dm_fx.prev_gain_code = 0;
- st->dm_fx.prev_state = 0;
- move16();
- move32();
- move32();
- move16();
- set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
- st->last_coder_type = GENERIC;
- move16();
- fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
-
- st->lp_gainp_fx = 0;
- move16();
- st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/
- move16();
- st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/
- move16();
-
- st->last_voice_factor_fx = 0;
- st->Last_GSC_noisy_speech_flag = 0;
- move16();
- move16();
-
- test();
- IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
- {
- hf_synth_reset_fx( st->hBWE_zero );
-#ifdef MSAN_FIX
- set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
-#endif
- }
-
- IF( st->hBWE_FD != NULL )
- {
- set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
-
- test();
- test();
- test();
- IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) )
- {
- /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */
- Word16 offset;
- offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Word32 *old_synthFB_fx;
- IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) );
- }
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10
-#else
- Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10
-#endif
- Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset );
- st->cldfbAna->Q_cldfb_state = Q10;
- move16();
- IF( old_synthFB_fx )
- free( old_synthFB_fx );
- }
- }
-
- test();
- test();
- test();
- test();
- IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) )
- {
- set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB );
-
- set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
- st->hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM );
- st->hHQ_core->prev_frm_hfe2 = 0;
- st->hHQ_core->prev_stab_hfe2 = 0;
- move16();
- move16();
- IF( GT_32( st->output_Fs, 16000 ) )
- {
- set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
- }
-
- IF( st->element_mode != EVS_MONO )
- {
- /* Estimate mem_env_delta to reinit env_stab */
- tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/
-
- st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */
- move16();
- test();
- IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) )
- {
- set16_fx( st->hHQ_core->old_out_fx, 0, output_frame );
- set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k );
- set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k );
- }
-
- st->hHQ_core->no_att_hangover = 0;
- move16();
- st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/
- move32();
- set16_fx( st->hHQ_core->old_is_transient, 0, 3 );
- set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 );
- st->hHQ_core->prev_R = 0;
- move16();
- set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 );
- st->hHQ_core->prev_hqswb_clas = HQ_NORMAL;
- st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/
- move16();
- move16();
- set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS );
- }
- ELSE
- {
- set16_fx( st->hHQ_core->old_out_fx, 0, output_frame );
- set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k );
- }
- }
-
- /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */
- IF( st->hHQ_core != NULL )
- {
- st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 );
- move16();
- IF( st->hHQ_core->pastpre < 0 )
- {
- reset_preecho_dec_fx( st->hHQ_core );
- }
- }
- test();
- IF( st->core_brate == FRAME_NO_DATA )
- {
- st->VAD = 0;
- st->m_frame_type = ZERO_FRAME;
- }
- ELSE IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) )
- {
- st->VAD = 0;
- st->m_frame_type = SID_FRAME;
- }
- ELSE
- {
- st->VAD = 1;
- st->m_frame_type = ACTIVE_FRAME;
- }
-
- move16();
- move16();
- /*switch on CNA on active frames*/
- IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */
- {
- test();
- test();
- test();
- test();
- test();
- test();
- IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) )
- {
- st->flag_cna = 1;
- move16();
- }
- ELSE IF( st->VAD || ( EQ_16( st->cng_type, FD_CNG ) && EQ_16( st->L_frame, L_FRAME16k ) ) )
- {
- st->flag_cna = 0;
- move16();
- }
- }
-
- if ( EQ_16( st->core, AMR_WB_CORE ) )
- {
- st->cng_type = LP_CNG;
- move16();
- }
-
- /* Reconfigure CNG */
- test();
- test();
- test();
- test();
- IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || ( st->ini_frame == 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) )
- {
- /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/
- IF( NE_16( st->core, AMR_WB_CORE ) )
- {
- test();
- IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) )
- {
- configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode );
- }
- ELSE
- {
- configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode );
- }
- }
- ELSE
- {
- configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode );
-
- if ( st->VAD )
- {
- st->hFdCngDec->hFdCngCom->CngBitrate = st->total_brate;
- move32();
- }
- }
- test();
- test();
- IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) )
- {
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame );
- }
-
- L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 );
-
- test();
- IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) )
- {
- L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth );
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- FOR( i = 0; i < ( st->L_frame * 2 ); i++ )
- {
- st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ );
- move32();
- }
- }
- ELSE
- {
- FOR( i = 0; i < ( st->L_frame * 2 ); i++ )
- {
- st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ );
- move32();
- }
- }
- }
- }
- }
-
- return error;
-}
-/*---------------------------------------------------------------------*
- * core_switching_hq_prepare_dec()
- *
- * Preprocessing in the first HQ frame after ACELP frame
- * Modify bit allocation for HQ core by removing ACELP subframe budget
- *---------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------*
- * bandwidth_switching_detect()
- *
- * Classification for band-width switching
- *---------------------------------------------------------------------*/
-
-void bandwidth_switching_detect_ivas_fx(
- Decoder_State *st_fx /* i/o: encoder state structure */
-)
-{
- test();
- test();
- IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
- {
- /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */
- st_fx->prev_bws_cnt = 0;
- st_fx->bws_cnt = 0;
- st_fx->bws_cnt1 = 0;
- move16();
- move16();
- move16();
-
- return;
- }
- /* update band-width switching counter */
- test();
- test();
- test();
- test();
- IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) )
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
- ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) && ( st_fx->last_low_rate_mode == 0 ) )
- {
- st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 );
- move16();
- }
- ELSE IF( st_fx->bws_cnt1 > 0 )
- {
- IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 );
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt = 0;
- move16();
- }
-
- IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
- ELSE
- {
- IF( EQ_16( st_fx->bwidth, SWB ) )
- {
- st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 );
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
- }
- }
-
- /* update band-width switching counter */
- test();
- test();
- test();
- IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) )
- {
- st_fx->bws_cnt = 0;
- move16();
- }
- ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) )
- {
- st_fx->bws_cnt = add( st_fx->bws_cnt, 1 );
- move16();
- }
- ELSE IF( st_fx->bws_cnt > 0 )
- {
- IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 );
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
-
- IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt = 0;
- move16();
- }
- ELSE
- {
- IF( EQ_16( st_fx->bwidth, WB ) )
- {
- st_fx->bws_cnt = add( st_fx->bws_cnt, 1 );
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt = 0;
- move16();
- }
- }
- }
-
- return;
-}
-
-
-/*---------------------------------------------------------------------*
- * bw_switching_pre_proc()
- *
- * Band-width switching pre-processing
- *---------------------------------------------------------------------*/
-void ivas_bw_switching_pre_proc_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 nchan_out /* i : number of output channels */,
- Word32 *old_syn_12k8_16k_fx,
- Word16 Q,
- Word16 Q_audio )
-{
- Word16 i;
- Word32 syn_dct_fx[L_FRAME];
-
-
- Flag Overflow = 0;
- move32();
-
- IF( st->element_mode > EVS_MONO )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) )
- {
- /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */
- Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k];
- Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) );
- st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16
- move16();
- }
-
- return;
- }
-
-
- test();
- test();
- IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) )
- {
- /*----------------------------------------------------------------------*
- * Calculate tilt of the ACELP core synthesis
- *----------------------------------------------------------------------*/
-
- st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame );
- move16();
- /*-------------------------------------------------------------------------------*
- * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis
- *-------------------------------------------------------------------------------*/
- edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q );
- Word64 W_tmp = 0;
- move64();
- Word32 tmp;
- Word16 shift;
- FOR( i = 0; i < L_FRAME / 2; i++ )
- {
- W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
- }
- shift = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, shift );
- tmp = W_extract_h( W_tmp );
- tmp = L_shr( tmp, 8 );
-
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
- move16();
- W_tmp = 0;
- move64();
- FOR( ; i < L_FRAME; i++ )
- {
- W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
- }
- shift = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, shift );
- tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32
- tmp = L_shr( tmp, 7 ); // divide by 128
- tmp = getSqrtWord32( tmp );
- st->enerLH_fx = tmp;
- move32();
- st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
- move16();
- }
- ELSE
- {
- IF( st->hHQ_core->old_is_transient[0] )
- {
- Word32 tmp, L_tmp = 0;
- move32();
- FOR( i = 0; i < 32; i++ )
- {
- L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
- }
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = Q_audio;
- move16();
-
- L_tmp = 0;
- move32();
- FOR( ; i < 64; i++ )
- {
- L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
- }
-
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLH_fx = tmp;
- move32();
- st->enerLH_fx_Q = Q_audio;
- move16();
- }
- ELSE
- {
- Word32 tmp, L_tmp = 0;
- move32();
- FOR( i = 0; i < L_FRAME / 2; i++ )
- {
- L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
- }
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = Q_audio;
- move16();
-
- L_tmp = 0;
- move32();
- FOR( ; i < L_FRAME; i++ )
- {
- L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
- }
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = Q_audio;
- move16();
- }
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) )
- {
-
- st->prev_ener_shb_fx = 0;
- move16();
- IF( st->hBWE_FD != NULL )
- {
- set16_fx( st->prev_SWB_fenv_fx, 0, SWB_FENV );
- }
- }
- ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) )
- {
- st->attenu_fx = 3277; // 0.1f in Q15
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) )
- {
- st->prev_fractive = 0;
- move16();
- }
-
- return;
-}
-/*---------------------------------------------------------------------*
- * core_switch_lb_upsamp()
- *
- * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz)
- *---------------------------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------*
- * smoothTransitionDtxToTcx()
- *
- * apply smoothing to the transition part for inactive to active transitions in DTX
- *---------------------------------------------------------------------*/
-
-#define TRANSITION_SMOOTHING_LEN_16k 15
-#define TRANSITION_SMOOTHING_LEN_32k 31
-#define TRANSITION_SMOOTHING_LEN_48k 47
diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c
index 17df8b5ca95b3054abcf4109bb92b63cd55ad32a..ba7c73741751664b8b8545bcdb85a0d66fc6f557 100644
--- a/lib_dec/core_switching_dec_fx.c
+++ b/lib_dec/core_switching_dec_fx.c
@@ -16,10 +16,6 @@
*
*
*---------------------------------------------------------------------*/
-#ifdef IVAS_CODE_SWITCHING
-static void core_switch_lb_upsamp( Decoder_State *st, float *output );
-static void smoothTransitionDtxToTcx( float synth[], const int16_t output_frame, const int16_t delay_comp );
-#endif
static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp );
static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output );
@@ -189,30 +185,11 @@ void bw_switching_pre_proc_fx(
Flag Overflow = 0;
move32();
#endif
-#ifdef IVAS_CODE_SWITCHING
+
IF( st_fx->element_mode > EVS_MONO )
{
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) &&
- st_fx->hBWE_FD != NULL && !( LE_16( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) &&
- !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_16( last_element_brate, IVAS_SID_4k4 ) ) )
- {
- /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */
- calc_tilt_bwe( old_syn_12k8_16k, &st->tilt_wb, st->L_frame );
- }
-
- return;
}
-#endif
+
test();
test();
IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) )
@@ -300,7 +277,7 @@ void bw_switching_pre_proc_fx(
{
st_fx->prev_ener_shb_fx = 0;
move16();
- set16_fx( st_fx->prev_SWB_fenv_fx, 0, SWB_FENV );
+ set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV );
}
ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) )
{
@@ -321,149 +298,7 @@ void bw_switching_pre_proc_fx(
return;
}
-#ifdef IVAS_CODE_SWITCHING
-
-
-/*---------------------------------------------------------------------*
- * core_switch_lb_upsamp()
- *
- * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz)
- *---------------------------------------------------------------------*/
-
-static void core_switch_lb_upsamp(
- Decoder_State *st, /* i/o: Decoder state */
- float *output /* i/o: LB synth/upsampled LB synth */
-)
-{
- int16_t i;
- float *realBuffer[CLDFB_OVRLP_MIN_SLOTS], *imagBuffer[CLDFB_OVRLP_MIN_SLOTS];
- float realBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX];
- float imagBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX];
-
- /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
- for ( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ )
- {
- set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer[i] = realBufferTmp[i];
- imagBuffer[i] = imagBufferTmp[i];
- }
-
- /* check if the CLDFB works on the right sample rate */
- if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame )
- {
- resampleCldfb( st->cldfbAna, st->L_frame * FRAMES_PER_SEC );
-
- if ( st->cldfbBPF != NULL && st->L_frame <= L_FRAME16k )
- {
- resampleCldfb( st->cldfbBPF, st->L_frame * FRAMES_PER_SEC );
- }
-
- if ( st->ini_frame > 0 )
- {
- st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels;
- }
- }
-
- /* analysis of the synthesis at internal sampling rate */
- cldfbAnalysis( output, realBuffer, imagBuffer, CLDFB_OVRLP_MIN_SLOTS * st->cldfbAna->no_channels, st->cldfbAna );
-
- /* analysis and add the BPF error signal */
- if ( st->p_bpf_noise_buf )
- {
- addBassPostFilter( st->p_bpf_noise_buf, st->bpf_off ? 0 : CLDFB_OVRLP_MIN_SLOTS * st->cldfbBPF->no_channels, realBuffer, imagBuffer, st->cldfbBPF );
- }
-
- /* set output mask for upsampling */
- if ( st->bwidth == NB )
- {
- /* set NB mask for upsampling */
- st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - 10;
- }
- else if ( st->cldfbSyn->bandsToZero != st->cldfbSyn->no_channels - st->cldfbAna->no_channels )
- {
- /* in case of BW switching, re-init to default */
- st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels;
- }
-
- /* synthesis of the combined signal */
- cldfbSynthesis( realBuffer, imagBuffer, output, CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels, st->cldfbSyn );
-
- /* save synthesis - needed in case of core switching */
- if ( st->hTcxDec != NULL )
- {
- mvr2r( output, st->previoussynth, st->hTcxDec->L_frameTCX );
- }
-
- return;
-}
-
-/*---------------------------------------------------------------------*
- * smoothTransitionMdctStereoDtx()
- *
- * apply smoothing to the transition part for MDCT-Stereo DTX
- *---------------------------------------------------------------------*/
-
-#define TRANSITION_SMOOTHING_LEN_16k 15
-#define TRANSITION_SMOOTHING_LEN_32k 31
-#define TRANSITION_SMOOTHING_LEN_48k 47
-
-static void smoothTransitionMdctStereoDtx(
- float synth[], /* i/o: synthesis */
- const int16_t output_frame, /* i : output frame length */
- const int16_t delay_comp /* i : delay compensation in samples */
-)
-{
- int16_t i, filter_len;
- float w, mem, step, fade_in;
- float smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k];
- float smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k];
-
- filter_len = TRANSITION_SMOOTHING_LEN_16k;
- if ( output_frame == L_FRAME32k )
- {
- filter_len = TRANSITION_SMOOTHING_LEN_32k;
- }
- else if ( output_frame == L_FRAME48k )
- {
- filter_len = TRANSITION_SMOOTHING_LEN_48k;
- }
-
- /* prepare buffer */
- for ( i = 0; i < filter_len / 2; i++ )
- {
- smoothing_input_buffer[i] = synth[0];
- }
- mvr2r( synth, smoothing_input_buffer + filter_len / 2, 2 * delay_comp + filter_len / 2 );
-
- /* apply Mean filter */
- w = 1.f / filter_len;
- mem = sum_f( smoothing_input_buffer, filter_len );
- for ( i = 0; i < 2 * delay_comp; i++ )
- {
- smoothing_out_buffer[i] = w * mem;
- mem = mem - smoothing_input_buffer[i] + smoothing_input_buffer[i + filter_len];
- }
-
- /* apply fades around transition */
- step = 1.f / delay_comp;
- fade_in = 0.f;
- for ( i = 0; i < delay_comp; i++ )
- {
- synth[i] = smoothing_out_buffer[i] * fade_in + synth[i] * ( 1 - fade_in );
- fade_in += step;
- }
-
- fade_in = 0.f;
- for ( ; i < 2 * delay_comp; i++ )
- {
- synth[i] = synth[i] * fade_in + smoothing_out_buffer[i] * ( 1 - fade_in );
- fade_in += step;
- }
- return;
-}
-#endif
/*---------------------------------------------------------------------*
* core_switching_pre_dec_fx()
*
@@ -651,7 +486,7 @@ ivas_error core_switching_pre_dec_fx(
{
return error;
}
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer );
cldfb_restore_memory( st_fx->cldfbAna );
scaleFactor.hb_scale = scaleFactor.lb_scale;
@@ -662,7 +497,7 @@ ivas_error core_switching_pre_dec_fx(
{
return error;
}
- cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer );
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer );
cldfb_restore_memory( st_fx->cldfbSyn );
}
@@ -738,13 +573,7 @@ ivas_error core_switching_pre_dec_fx(
test();
test();
- IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) )
- //#ifdef IVAS_CODE_SWITCHING
- // || ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD) ||
- // (EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && last_element_mode == IVAS_CPE_DFT)) && EQ_16(nchan_out,2) &&
- // NE_16(st_fx->core_brate, SID_2k40) && NE_16(st_fx->core_brate, FRAME_NO_DATA) && (EQ_16(last_core_brate_st0, FRAME_NO_DATA) || EQ_16(last_core_brate_st0, SID_2k40)))
- //#endif
- )
+ IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) )
{
test();
IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
@@ -770,14 +599,7 @@ ivas_error core_switching_pre_dec_fx(
lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX );
}
-#ifdef IVAS_CODE_SWITCHING
- if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && nchan_out == 2 && st->core_brate > SID_2k40 && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) && st->hTcxDec != NULL )
- {
- /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */
- set_f( st->hTcxDec->old_syn_Overl, 0.0f, L_FRAME32k / 2 );
- set_f( st->hFdCngDec->hFdCngCom->olapBufferAna, 0.0f, FFTLEN );
- }
-#endif
+
set16_fx( st_fx->agc_mem_fx, 0, 2 );
st_fx->mem_deemph_fx = 0;
move16();
@@ -876,47 +698,7 @@ ivas_error core_switching_pre_dec_fx(
set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) );
}
}
-#ifdef IVAS_CODE_SWITCHING
- if ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE ) )
- {
- if ( st->hBWE_TD != NULL )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f;
- set_f( st->hBWE_TD->old_bwe_exc, 0, PIT16k_MAX * 2 );
- }
-
- st->tilt_code = 0.0f;
- st->gc_threshold = 0.0f;
- set_f( st->dispMem, 0, 8 );
- st->last_coder_type = GENERIC;
-
- fer_energy( output_frame, UNVOICED_CLAS, st->previoussynth, -1, &st->enr_old, 1 );
- st->lp_gainp = 0.0f;
- st->lp_gainc = (float) sqrt( st->lp_ener );
-
- st->last_voice_factor = 0;
- st->Last_GSC_noisy_speech_flag = 0;
-
- if ( st->output_Fs >= 16000 && st->hBWE_zero != NULL )
- {
- hf_synth_reset( st->hBWE_zero );
- }
-
- if ( st->hBWE_FD != NULL )
- {
- set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
-
- if ( nchan_out == 1 && st->element_mode == IVAS_CPE_DFT && st->element_brate <= IVAS_24k4 && last_element_brate > IVAS_24k4 )
- {
- /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */
- int16_t offset;
- offset = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels;
- mvr2r( st->hTcxDec->old_synthFB + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state, offset );
- }
- }
-#endif
test();
test();
test();
@@ -941,40 +723,16 @@ ivas_error core_switching_pre_dec_fx(
{
set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
}
-#ifdef IVAS_CODE_SWITCHING
- if ( st->element_mode != EVS_MONO )
- {
- /* Estimate mem_env_delta to reinit env_stab */
- tmp = max( 0, ENV_STAB_EST1 + ( ENV_STAB_EST2 * st->stab_fac_smooth_lt ) + ( ENV_STAB_EST3 * st->log_energy_diff_lt ) );
- st->hHQ_core->mem_env_delta = (int16_t) min( MAX16B, (int32_t) ( tmp * ( 1 << 12 ) ) ); /* Convert to Q12 and handle saturation */
-
- if ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE )
- {
- set_f( st->hHQ_core->old_out, 0, output_frame );
- set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k );
- }
-
- st->hHQ_core->no_att_hangover = 0;
- st->hHQ_core->energy_lt = 300.0f;
- set_s( st->hHQ_core->old_is_transient, 0, 3 );
- set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 );
- st->hHQ_core->prev_R = 0;
- set_s( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 );
- st->hHQ_core->prev_hqswb_clas = HQ_NORMAL;
- st->hHQ_core->prev_ni_ratio = 0.5f;
- set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS );
+ if ( st_fx->element_mode != EVS_MONO )
+ {
}
else
-#endif
{
set16_fx( hHQ_core->old_out_fx, 0, output_frame );
hHQ_core->Q_old_wtda_LB = 15;
hHQ_core->Q_old_wtda = 15;
move16();
-#ifdef IVAS_CODE_SWITCHING
- set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k );
-#endif
}
}
@@ -1081,12 +839,10 @@ ivas_error core_switching_pre_dec_fx(
IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) )
{
test();
-#ifdef IVAS_CODE_SWITCHING
IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
- lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame );
}
-#endif
+
lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) );
test();
IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) )
@@ -1122,22 +878,12 @@ ivas_error core_switching_pre_dec_fx(
*---------------------------------------------------------------------*/
ivas_error core_switching_post_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 *synth, /* i/o: output synthesis Qsynth*/
-#ifdef IVAS_CODE_SWITCHING
- float *output, /* i/o: LB synth/upsampled LB synth */
- float output_mem[], /* i : OLA memory from last TCX/HQ frame */
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
-#endif
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ Word16 *synth, /* i/o: output synthesis Qsynth*/
const Word16 output_frame, /* i : frame length Q0*/
const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/
-#ifdef IVAS_CODE_SWITCHING
- const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */
- const Word16 nchan_out, /* i : number of output channels */
-#endif
- const Word16 last_element_mode, /* i : element mode of previous frame Q0*/
- Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
+ const Word16 last_element_mode, /* i : element mode of previous frame Q0*/
+ Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
)
{
Word16 i, delay_comp, delta;
@@ -1152,20 +898,13 @@ ivas_error core_switching_post_dec_fx(
HQ_DEC_HANDLE hHQ_core;
ivas_error error;
-#ifdef IVAS_CODE_SWITCHING
- int16_t offset;
-#endif
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) ( last_element_mode );
-#endif
hBWE_TD = st_fx->hBWE_TD;
hBWE_FD = st_fx->hBWE_FD;
hHQ_core = st_fx->hHQ_core;
error = IVAS_ERR_OK;
move32();
- // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ")
-
/* Rescale synthesis in Q0 to avoid multiple rescaling after */
tmp = Find_Max_Norm16( synth, output_frame );
Scale_sig( synth, output_frame, tmp );
@@ -1237,10 +976,7 @@ ivas_error core_switching_post_dec_fx(
Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */
hHQ_core->Q_old_postdec = Qtmp;
move16();
-
- Copy( synth, &synth[delay_comp], output_frame ); /* Qsynth */
- Copy( st_fx->delay_buf_out_fx, synth, delay_comp ); /* Q0 */
- Copy( &synth[output_frame], st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth */
+ delay_signal_fx( synth, output_frame, st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth, Q0 */
test();
test();
@@ -1412,7 +1148,7 @@ ivas_error core_switching_post_dec_fx(
move16();
hBWE_FD->prev_weight_fx = 6554;
move16(); /*0.2 in Q15*/
- st_fx->prev_fb_ener_adjust_fx = 0;
+ hBWE_FD->prev_fb_ener_adjust_fx = 0;
move16();
}
@@ -1464,8 +1200,8 @@ ivas_error core_switching_post_dec_fx(
swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );
- set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 );
- swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx );
+ set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
+ swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );
IF( EQ_16( output_frame, L_FRAME16k ) )
{
@@ -1492,9 +1228,9 @@ ivas_error core_switching_post_dec_fx(
test();
test();
test();
- IF( EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) )
+ IF( st_fx->hTdCngDec != NULL && EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) )
{
- set16_fx( st_fx->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN );
+ set16_fx( st_fx->hTdCngDec->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN );
}
/* reset FB TBE buffers */
@@ -1528,7 +1264,6 @@ ivas_error core_switching_post_dec_ivas_fx(
Word16 *synth, /* i/o: output synthesis Qsynth*/
Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/
Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/
const Word16 output_frame, /* i : frame length Q0*/
const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/
@@ -1549,7 +1284,7 @@ ivas_error core_switching_post_dec_ivas_fx(
FD_BWE_DEC_HANDLE hBWE_FD;
HQ_DEC_HANDLE hHQ_core;
ivas_error error;
- int16_t offset;
+ Word16 offset;
L_tmp = 0;
move32();
@@ -1560,8 +1295,6 @@ ivas_error core_switching_post_dec_ivas_fx(
error = IVAS_ERR_OK;
move32();
- // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ")
-
/* Rescale synthesis in Q0 to avoid multiple rescaling after */
tmp = Find_Max_Norm16( synth, output_frame );
Scale_sig( synth, output_frame, tmp ); /* Qsynth + tmp */
@@ -1671,13 +1404,7 @@ ivas_error core_switching_post_dec_ivas_fx(
Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */
hHQ_core->Q_old_postdec = Qtmp;
move16();
- Word16 temp_buffer[L_FRAME48k];
-
- Copy( st_fx->delay_buf_out_fx, temp_buffer, delay_comp ); /* Q0 */
- Copy( synth + sub( output_frame, delay_comp ), st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth */
- move16();
- Copy( synth, synth + delay_comp, sub( output_frame, delay_comp ) ); /* Qsynth */
- Copy( temp_buffer, synth, delay_comp ); /* Q0 */
+ delay_signal_fx( synth, output_frame, st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth, Q0 */
test();
test();
@@ -1765,7 +1492,7 @@ ivas_error core_switching_post_dec_ivas_fx(
Copy_Scale_sig( st_fx->previoussynth_fx, synth, delay_comp, *Qsynth ); /* Qsynth */
/* Overlap between TCX-LB and TCX-FB*/
- Word16 tmpDelta = NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS );
+ Word16 tmpDelta = NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS );
Word32 L_tmp2;
FOR( i = 0; i < tmpDelta; i++ )
{
@@ -1784,11 +1511,12 @@ ivas_error core_switching_post_dec_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( ivas_format, ISM_FORMAT ) && EQ_16( st_fx->core, TCX_20_CORE ) /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && LE_32( st_fx->last_core_brate, SID_2k40 ) && GT_32( st_fx->core_brate, SID_2k40 ) )
+ IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || ( st_fx->is_ism_format && EQ_16( st_fx->core, TCX_20_CORE ) /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && LE_32( st_fx->last_core_brate, SID_2k40 ) && GT_32( st_fx->core_brate, SID_2k40 ) )
{
/* smooth transitions to avoid pops in car noise items */
smoothTransitionDtxToTcx_fx( synth, output_frame, delay_comp );
}
+
/* Reset memories of CLDFBs */
IF( st_fx->cldfbAna != NULL )
{
@@ -1924,7 +1652,7 @@ ivas_error core_switching_post_dec_ivas_fx(
}
IF( output_mem_fx != NULL )
{
- Scale_sig( output_mem_fx, NS2SA( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */
+ Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */
}
*Qsynth = Qtmp;
move16();
@@ -2052,7 +1780,7 @@ ivas_error core_switching_post_dec_ivas_fx(
move16();
hBWE_FD->prev_weight_fx = 6554;
move16(); /*0.2 in Q15*/
- st_fx->prev_fb_ener_adjust_fx = 0;
+ hBWE_FD->prev_fb_ener_adjust_fx = 0;
move16();
}
@@ -2113,12 +1841,11 @@ ivas_error core_switching_post_dec_ivas_fx(
swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );
- set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 );
- // swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx );
- swb_tbe_reset_synth_ivas_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );
+ set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
+ swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );
- st_fx->hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
- st_fx->hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */
+ hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
+ hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */
move16();
move16();
@@ -2142,7 +1869,7 @@ ivas_error core_switching_post_dec_ivas_fx(
}
ELSE IF( st_fx->hBWE_TD != NULL && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) )
{
- TBEreset_dec_ivas_fx( st_fx );
+ TBEreset_dec_fx( st_fx );
}
/* reset FB TBE buffers */
@@ -2174,9 +1901,9 @@ ivas_error core_switching_post_dec_ivas_fx(
test();
test();
test();
- IF( EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) )
+ IF( st_fx->hTdCngDec != NULL && EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) )
{
- set16_fx( st_fx->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN );
+ set16_fx( st_fx->hTdCngDec->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN );
}
return error;
@@ -2329,7 +2056,11 @@ static void core_switch_lb_upsamp_fx(
}
/* synthesis of the combined signal */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), st->cldfbSyn );
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, 0, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
/*rescaling whole buffer to a common Q*/
no_col = st->cldfbSyn->no_col;
@@ -2367,13 +2098,8 @@ static void smoothTransitionDtxToTcx_fx(
Word16 i, filter_len;
Word16 w, step, fade_in;
Word32 mem;
-#ifdef MSAN_FIX
Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k];
Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k];
-#else
- Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k];
- Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k];
-#endif
set16_fx( smoothing_input_buffer, 0, 2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k );
set16_fx( smoothing_out_buffer, 0, 2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k );
@@ -2435,3 +2161,1003 @@ static void smoothTransitionDtxToTcx_fx(
return;
}
+
+
+/*---------------------------------------------------------------------*
+ * core_switching_pre_dec()
+ *
+ * Preprocessing/preparation for ACELP/HQ core switching
+ *---------------------------------------------------------------------*/
+ivas_error core_switching_pre_dec_ivas_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word16 output_frame, /* i : frame length */
+ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
+ const Word16 nchan_out, /* i : number of output channels */
+ const Word16 last_element_mode, /* i : last_element_mode */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ Word16 Q_old_synthFB,
+ Word16 *Q_olapBufferSynth,
+ Word16 *Q_olapBufferSynth2 )
+{
+ Word32 tmp_fx; /*Q-12*/
+ Word16 i, oldLenClasBuff, newLenClasBuff;
+ ivas_error error;
+ Word16 exp = 25;
+ move16();
+ error = IVAS_ERR_OK;
+ move32();
+
+ /* Codec mode switching */
+ test();
+ test();
+ test();
+ IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) )
+ {
+ st->mem_deemph_fx = st->syn[M];
+ move16();
+ set16_fx( st->agc_mem_fx, 0, 2 );
+ Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */
+
+ Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
+
+ st->bpf_off = 1;
+ move16();
+ IF( st->hPFstat != NULL )
+ {
+ Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/
+ Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/
+ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/
+ set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/
+ }
+ IF( st->hBPF != NULL )
+ {
+ st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */
+ st->hBPF->pst_mem_deemp_err_fx = 0;
+ move16();
+ move16();
+ }
+ st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); // Q(23+1-16)->Q8
+ move16();
+
+ /* reset old HB synthesis buffer */
+ IF( EQ_16( st->last_L_frame, L_FRAME ) )
+ {
+ st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS );
+ }
+ ELSE
+ {
+ st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
+ }
+ move16();
+ set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) );
+
+ test();
+ IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) )
+ {
+ st->hBWE_TD->prev_hb_synth_fx_exp = 31;
+ move16();
+ /* reset BWE memories */
+ set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
+ }
+
+ /* reset upd_cnt */
+ st->upd_cnt = MAX_UPD_CNT;
+ move16();
+
+ st->igf = 0;
+ move16();
+
+ test();
+ IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
+ {
+ hf_synth_reset_fx( st->hBWE_zero );
+ set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
+ }
+
+ IF( st->hBWE_FD != NULL )
+ {
+ set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
+ }
+
+ IF( st->hHQ_core != NULL )
+ {
+ set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
+ set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB );
+
+ set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
+ set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
+
+ st->hHQ_core->last_max_pos_pulse = 0;
+ move16();
+
+ IF( GT_32( st->output_Fs, 16000 ) )
+ {
+ set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
+ }
+
+ /* pre-echo */
+ st->hHQ_core->pastpre = 0;
+ move16();
+ }
+
+ /* reset the GSC pre echo energy threshold in case of switching */
+ if ( st->hGSCDec != NULL )
+ {
+ st->hGSCDec->Last_frame_ener_fx = MAX_32;
+ move32();
+ }
+
+ test();
+ IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
+ {
+ IF( st->element_mode == EVS_MONO )
+ {
+ st->last_core = HQ_CORE;
+ move16();
+
+ Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
+ // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0
+ }
+
+ IF( st->hHQ_core != NULL )
+ {
+ set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
+ set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
+ st->hHQ_core->last_max_pos_pulse = 0;
+ move16();
+
+ set16_fx( st->hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
+ st->hHQ_core->prev_frm_hfe2 = 0;
+ st->hHQ_core->prev_stab_hfe2 = 0;
+ move16();
+ move16();
+ }
+ }
+
+ IF( st->prev_bfi != 0 )
+ {
+ Word16 delay_comp;
+
+ /*switch off Hq Voicing as it was not updated in MODE2*/
+ IF( st->hHQ_core != NULL )
+ {
+ st->hHQ_core->oldHqVoicing = 0;
+ st->hHQ_core->HqVoicing = 0;
+ move16();
+ move16();
+ }
+
+ delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
+ /*TODO To be tested:control not entering the block*/
+ test();
+ test();
+ IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
+ {
+ /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/
+ assert( 0 );
+ Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH];
+ Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX];
+ Word32 syn_Overl_fx[320];
+ Word32 fer_samples_fx[960];
+ Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 );
+ Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 );
+
+
+ FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
+ {
+ set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ realBuffer_fx[i] = realBufferTmp_fx[i];
+ imagBuffer_fx[i] = imagBufferTmp_fx[i];
+ }
+
+ /* CLDFB analysis of the synthesis at internal sampling rate */
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna );
+ cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/
+
+ /* CLDFB synthesis of the combined signal */
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfb_restore_memory_ivas_fx( st->cldfbSyn );
+ Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 );
+ Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 );
+ }
+
+ test();
+ test();
+ IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
+ {
+ lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) );
+ /*Set to zero the remaining part*/
+ set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) );
+ }
+ }
+
+ st->use_acelp_preq = 0;
+ st->reset_mem_AR = 0;
+ move16();
+ move16();
+ }
+
+ /*FEC*/
+ IF( LE_16( st->L_frame, L_FRAME16k ) )
+ {
+ test();
+ IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) )
+ {
+ IF( NE_16( st->L_frame, st->last_L_frame ) )
+ {
+ IF( GT_16( st->L_frame, st->last_L_frame ) )
+ {
+ oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) );
+ newLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
+ move16();
+ }
+ ELSE
+ {
+ oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
+ move16();
+ newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) );
+ }
+ lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff );
+ }
+ }
+ ELSE
+ {
+ set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM );
+ }
+ }
+
+ /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores
+ within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
+ test();
+ test();
+ IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) )
+ {
+ st->last_ppp_mode_dec = 0;
+ st->last_nelp_mode_dec = 0;
+ move16();
+ move16();
+ }
+
+ /* Handle state reset of stat_noise_uv_mod memory */
+ test();
+ test();
+ test();
+ IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) )
+ {
+ st->act_count = 3;
+ st->uv_count = 0;
+ move16();
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) &&
+ NE_32( st->core_brate, SID_2k40 ) && ( st->core_brate != FRAME_NO_DATA ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) )
+ {
+ test();
+ if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ {
+ st->hPFstat->reset = 1;
+ move16();
+ }
+
+ IF( EQ_16( st->L_frame, L_FRAME16k ) )
+ {
+ Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */
+ Copy( TRWB2_Ave_fx, st->lsfoldbfi1_fx, M );
+ Copy( TRWB2_Ave_fx, st->lsfoldbfi0_fx, M );
+ Copy( TRWB2_Ave_fx, st->lsf_adaptive_mean_fx, M );
+ lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k );
+ }
+ ELSE
+ {
+ Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */
+ Copy( TRWB_Ave_fx, st->lsfoldbfi1_fx, M );
+ Copy( TRWB_Ave_fx, st->lsfoldbfi0_fx, M );
+ Copy( TRWB_Ave_fx, st->lsf_adaptive_mean_fx, M );
+ lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 );
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL )
+ {
+ /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */
+ set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 );
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN );
+ set16_fx( st->agc_mem_fx, 0, 2 );
+ }
+ st->mem_deemph_fx = 0;
+ move16();
+ IF( !st->last_con_tcx )
+ {
+ set16_fx( st->mem_syn2_fx, 0, M );
+ }
+ set16_fx( st->mem_syn1_fx, 0, M );
+ if ( st->hBWE_TD != NULL )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
+ }
+
+ /* Reset ACELP parameters */
+ set16_fx( st->mem_MA_fx, 0, M );
+
+ IF( EQ_32( st->sr_core, INT_FS_16k ) )
+ {
+ Copy( GEWB2_Ave_fx, st->mem_AR_fx, M );
+ }
+ ELSE
+ {
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
+ }
+
+ st->tilt_code_fx = 0;
+ st->gc_threshold_fx = 0;
+ st->dm_fx.prev_gain_code = 0;
+ st->dm_fx.prev_state = 0;
+ move16();
+ move32();
+ move32();
+ move16();
+ set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
+
+ st->last_coder_type = GENERIC;
+ move16();
+
+ fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
+ st->lp_gainp_fx = 0;
+ move16();
+ st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/
+ move16();
+ st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/
+ move16();
+
+ st->last_voice_factor_fx = 0;
+ st->Last_GSC_noisy_speech_flag = 0;
+ move16();
+ move16();
+
+ /* reset CLDFB memories */
+ cldfb_reset_memory_fx( st->cldfbAna );
+ cldfb_reset_memory_fx( st->cldfbBPF );
+ cldfb_reset_memory_fx( st->cldfbSyn );
+
+ /* reset TBE memories */
+ test();
+ test();
+ IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && ( st->element_mode > EVS_MONO ) ) )
+ {
+ set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC );
+ }
+ ELSE IF( LT_16( st->L_frame, L_FRAME16k ) )
+ {
+ /* resample from 16kHz to 12.8kHZ */
+ synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC );
+ }
+
+ IF( st->hBWE_TD != NULL )
+ {
+ set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
+ }
+
+ test();
+ IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
+ {
+ hf_synth_reset_fx( st->hBWE_zero );
+ set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
+ }
+
+ IF( st->hBWE_FD != NULL )
+ {
+ set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
+ }
+ }
+
+ test();
+ test();
+ test();
+ IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) )
+ {
+ IF( st->hBWE_TD != NULL )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
+ set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
+ }
+
+ st->tilt_code_fx = 0;
+ st->gc_threshold_fx = 0;
+ st->dm_fx.prev_gain_code = 0;
+ st->dm_fx.prev_state = 0;
+ move16();
+ move32();
+ move32();
+ move16();
+ set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
+ st->last_coder_type = GENERIC;
+ move16();
+ fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
+
+ st->lp_gainp_fx = 0;
+ move16();
+ st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/
+ move16();
+ st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/
+ move16();
+
+ st->last_voice_factor_fx = 0;
+ st->Last_GSC_noisy_speech_flag = 0;
+ move16();
+ move16();
+
+ test();
+ IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
+ {
+ hf_synth_reset_fx( st->hBWE_zero );
+ set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
+ }
+
+ IF( st->hBWE_FD != NULL )
+ {
+ set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
+ }
+
+ test();
+ test();
+ test();
+ IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) )
+ {
+ /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */
+ Word16 offset;
+ offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Word32 *old_synthFB_fx;
+ IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) );
+ }
+ Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10
+ Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset );
+ st->cldfbAna->Q_cldfb_state = Q10;
+ move16();
+ IF( old_synthFB_fx )
+ free( old_synthFB_fx );
+ }
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) )
+ {
+ set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
+ set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB );
+
+ set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
+ set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
+ st->hHQ_core->last_max_pos_pulse = 0;
+ move16();
+
+ set16_fx( st->hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
+ st->hHQ_core->prev_frm_hfe2 = 0;
+ st->hHQ_core->prev_stab_hfe2 = 0;
+ move16();
+ move16();
+ IF( GT_32( st->output_Fs, 16000 ) )
+ {
+ set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
+ }
+
+ IF( st->element_mode != EVS_MONO )
+ {
+ /* Estimate mem_env_delta to reinit env_stab */
+ tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/
+
+ st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */
+ move16();
+ test();
+ IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) )
+ {
+ set16_fx( st->hHQ_core->old_out_fx, 0, output_frame );
+ set32_fx( st->hHQ_core->old_out_LB_fx32, 0, L_FRAME16k );
+ set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k );
+ }
+
+ st->hHQ_core->no_att_hangover = 0;
+ move16();
+ st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/
+ move32();
+ set16_fx( st->hHQ_core->old_is_transient, 0, 3 );
+ set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 );
+ st->hHQ_core->prev_R = 0;
+ move16();
+ set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 );
+ st->hHQ_core->prev_hqswb_clas = HQ_NORMAL;
+ st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/
+ move16();
+ move16();
+ set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS );
+ }
+ ELSE
+ {
+ set16_fx( st->hHQ_core->old_out_fx, 0, output_frame );
+ set32_fx( st->hHQ_core->old_out_LB_fx32, 0, L_FRAME16k );
+ }
+ }
+
+ /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */
+ IF( st->hHQ_core != NULL )
+ {
+ st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 );
+ move16();
+ IF( st->hHQ_core->pastpre < 0 )
+ {
+ reset_preecho_dec_fx( st->hHQ_core );
+ }
+ }
+ test();
+ IF( st->core_brate == FRAME_NO_DATA )
+ {
+ st->VAD = 0;
+ st->m_frame_type = ZERO_FRAME;
+ }
+ ELSE IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) )
+ {
+ st->VAD = 0;
+ st->m_frame_type = SID_FRAME;
+ }
+ ELSE
+ {
+ st->VAD = 1;
+ st->m_frame_type = ACTIVE_FRAME;
+ }
+
+ move16();
+ move16();
+ /*switch on CNA on active frames*/
+ IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) )
+ {
+ st->flag_cna = 1;
+ move16();
+ }
+ ELSE IF( st->VAD || ( EQ_16( st->cng_type, FD_CNG ) && EQ_16( st->L_frame, L_FRAME16k ) ) )
+ {
+ st->flag_cna = 0;
+ move16();
+ }
+ }
+
+ if ( EQ_16( st->core, AMR_WB_CORE ) )
+ {
+ st->cng_type = LP_CNG;
+ move16();
+ }
+
+ /* Reconfigure CNG */
+ test();
+ test();
+ test();
+ test();
+ IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || ( st->ini_frame == 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) )
+ {
+ /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/
+ IF( NE_16( st->core, AMR_WB_CORE ) )
+ {
+ test();
+ IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) )
+ {
+ configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode );
+ }
+ ELSE
+ {
+ configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode );
+ }
+ }
+ ELSE
+ {
+ configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode );
+
+ if ( st->VAD )
+ {
+ st->hFdCngDec->hFdCngCom->CngBitrate = st->total_brate;
+ move32();
+ }
+ }
+ test();
+ test();
+ IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) )
+ {
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ {
+ lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame );
+ }
+
+ L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 );
+
+ test();
+ IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) )
+ {
+ L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth );
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ FOR( i = 0; i < ( st->L_frame * 2 ); i++ )
+ {
+ st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ );
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < ( st->L_frame * 2 ); i++ )
+ {
+ st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ );
+ move32();
+ }
+ }
+ }
+ }
+ }
+
+ return error;
+}
+/*---------------------------------------------------------------------*
+ * core_switching_hq_prepare_dec()
+ *
+ * Preprocessing in the first HQ frame after ACELP frame
+ * Modify bit allocation for HQ core by removing ACELP subframe budget
+ *---------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------*
+ * bandwidth_switching_detect()
+ *
+ * Classification for band-width switching
+ *---------------------------------------------------------------------*/
+
+void bandwidth_switching_detect_ivas_fx(
+ Decoder_State *st_fx /* i/o: encoder state structure */
+)
+{
+ test();
+ test();
+ IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ {
+ /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */
+ st_fx->prev_bws_cnt = 0;
+ st_fx->bws_cnt = 0;
+ st_fx->bws_cnt1 = 0;
+ move16();
+ move16();
+ move16();
+
+ return;
+ }
+ /* update band-width switching counter */
+ test();
+ test();
+ test();
+ test();
+ IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) )
+ {
+ st_fx->bws_cnt1 = 0;
+ move16();
+ }
+ ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) && ( st_fx->last_low_rate_mode == 0 ) )
+ {
+ st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 );
+ move16();
+ }
+ ELSE IF( st_fx->bws_cnt1 > 0 )
+ {
+ IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) )
+ {
+ st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 );
+ move16();
+ }
+ ELSE
+ {
+ st_fx->bws_cnt = 0;
+ move16();
+ }
+
+ IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) )
+ {
+ st_fx->bws_cnt1 = 0;
+ move16();
+ }
+ ELSE
+ {
+ IF( EQ_16( st_fx->bwidth, SWB ) )
+ {
+ st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 );
+ move16();
+ }
+ ELSE
+ {
+ st_fx->bws_cnt1 = 0;
+ move16();
+ }
+ }
+ }
+
+ /* update band-width switching counter */
+ test();
+ test();
+ test();
+ IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) )
+ {
+ st_fx->bws_cnt = 0;
+ move16();
+ }
+ ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) )
+ {
+ st_fx->bws_cnt = add( st_fx->bws_cnt, 1 );
+ move16();
+ }
+ ELSE IF( st_fx->bws_cnt > 0 )
+ {
+ IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) )
+ {
+ st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 );
+ move16();
+ }
+ ELSE
+ {
+ st_fx->bws_cnt1 = 0;
+ move16();
+ }
+
+ IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) )
+ {
+ st_fx->bws_cnt = 0;
+ move16();
+ }
+ ELSE
+ {
+ IF( EQ_16( st_fx->bwidth, WB ) )
+ {
+ st_fx->bws_cnt = add( st_fx->bws_cnt, 1 );
+ move16();
+ }
+ ELSE
+ {
+ st_fx->bws_cnt = 0;
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*---------------------------------------------------------------------*
+ * bw_switching_pre_proc()
+ *
+ * Band-width switching pre-processing
+ *---------------------------------------------------------------------*/
+void ivas_bw_switching_pre_proc_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ const Word16 nchan_out /* i : number of output channels */,
+ Word32 *old_syn_12k8_16k_fx,
+ Word16 Q,
+ Word16 Q_audio )
+{
+ Word16 i;
+ Word32 syn_dct_fx[L_FRAME];
+
+
+ Flag Overflow = 0;
+ move32();
+
+ IF( st->element_mode > EVS_MONO )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) )
+ {
+ /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */
+ Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k];
+ Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) );
+ st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16
+ move16();
+ }
+
+ return;
+ }
+
+
+ test();
+ test();
+ IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) )
+ {
+ /*----------------------------------------------------------------------*
+ * Calculate tilt of the ACELP core synthesis
+ *----------------------------------------------------------------------*/
+
+ st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame );
+ move16();
+ /*-------------------------------------------------------------------------------*
+ * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis
+ *-------------------------------------------------------------------------------*/
+ edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q );
+ Word64 W_tmp = 0;
+ move64();
+ Word32 tmp;
+ Word16 shift;
+ FOR( i = 0; i < L_FRAME / 2; i++ )
+ {
+ W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
+ }
+ shift = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, shift );
+ tmp = W_extract_h( W_tmp );
+ tmp = L_shr( tmp, 8 );
+
+ tmp = getSqrtWord32( tmp );
+ st->enerLL_fx = tmp;
+ move32();
+ st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
+ move16();
+ W_tmp = 0;
+ move64();
+ FOR( ; i < L_FRAME; i++ )
+ {
+ W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
+ }
+ shift = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, shift );
+ tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32
+ tmp = L_shr( tmp, 7 ); // divide by 128
+ tmp = getSqrtWord32( tmp );
+ st->enerLH_fx = tmp;
+ move32();
+ st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
+ move16();
+ }
+ ELSE
+ {
+ IF( st->hHQ_core->old_is_transient[0] )
+ {
+ Word32 tmp, L_tmp = 0;
+ move32();
+ FOR( i = 0; i < 32; i++ )
+ {
+ L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
+ }
+ tmp = L_shr( L_tmp, 5 ); // divide by 32
+ tmp = getSqrtWord32( tmp );
+ st->enerLL_fx = tmp;
+ move32();
+ st->enerLL_fx_Q = Q_audio;
+ move16();
+
+ L_tmp = 0;
+ move32();
+ FOR( ; i < 64; i++ )
+ {
+ L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
+ }
+
+ tmp = L_shr( L_tmp, 5 ); // divide by 32
+ tmp = getSqrtWord32( tmp );
+ st->enerLH_fx = tmp;
+ move32();
+ st->enerLH_fx_Q = Q_audio;
+ move16();
+ }
+ ELSE
+ {
+ Word32 tmp, L_tmp = 0;
+ move32();
+ FOR( i = 0; i < L_FRAME / 2; i++ )
+ {
+ L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
+ }
+ tmp = L_shr( L_tmp, 5 ); // divide by 32
+ tmp = getSqrtWord32( tmp );
+ st->enerLL_fx = tmp;
+ move32();
+ st->enerLL_fx_Q = Q_audio;
+ move16();
+
+ L_tmp = 0;
+ move32();
+ FOR( ; i < L_FRAME; i++ )
+ {
+ L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
+ }
+ tmp = L_shr( L_tmp, 5 ); // divide by 32
+ tmp = getSqrtWord32( tmp );
+ st->enerLL_fx = tmp;
+ move32();
+ st->enerLL_fx_Q = Q_audio;
+ move16();
+ }
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) )
+ {
+ st->prev_ener_shb_fx = 0;
+ move16();
+ IF( st->hBWE_FD != NULL )
+ {
+ set16_fx( st->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV );
+ }
+ }
+ ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) )
+ {
+ st->attenu_fx = 3277; // 0.1f in Q15
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) )
+ {
+ st->prev_fractive = 0;
+ move16();
+ }
+
+ return;
+}
diff --git a/lib_dec/d_gain2p.c b/lib_dec/d_gain2p.c
deleted file mode 100644
index cc19164cadaff8baea7c99cfc2735139b2d031cd..0000000000000000000000000000000000000000
--- a/lib_dec/d_gain2p.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec2t32.c b/lib_dec/dec2t32.c
deleted file mode 100644
index 13c9ebade9036711e8fa9972eb05ff7a7b058f51..0000000000000000000000000000000000000000
--- a/lib_dec/dec2t32.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*----------------------------------------------------------------------------------*
- * dec_acelp_2t32()
- *
- * 12 bits algebraic codebook decoder.
- * 2 track x 32 positions per track = 64 samples.
- *
- * 12 bits --> 2 pulses in a frame of 64 samples.
- *
- * All pulses can have two (2) possible amplitudes: +1 or -1.
- * Each pulse can have 32 possible positions.
- *
- * See cod2t32.c for more details of the algebraic code.
- *----------------------------------------------------------------------------------*/
diff --git a/lib_dec/dec4t64.c b/lib_dec/dec4t64.c
deleted file mode 100644
index d448123b1503d0c55106cdb4b6bd4ffc57130e2d..0000000000000000000000000000000000000000
--- a/lib_dec/dec4t64.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "ivas_prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c
index 58f9048c4c69194c0874af32fad1343b5a9bde92..ee6ef65a6ce3aa2b91e1020f51ad5f12405baa84 100644
--- a/lib_dec/dec4t64_fx.c
+++ b/lib_dec/dec4t64_fx.c
@@ -793,242 +793,7 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack
return;
}
-#ifdef IVAS_CODE_FCB
-/*-------------------------------------------------------*
- * dec_1p_N1()
- *
- * Decode 1 pulse with N+1 bits
- *-------------------------------------------------------*/
-
-static void dec_1p_N1_L_subfr(
- const int32_t index, /* i : quantization index */
- const int16_t nb_pos, /* i : number of positions */
- const int16_t N, /* i : nb. of bits */
- int16_t pos[] /* o : pulse position */
-)
-{
- int16_t i, pos1;
- int32_t mask;
-
- mask = ( ( 1 << N ) - 1 );
- pos1 = (int16_t) ( index & mask );
- i = (int16_t) ( index >> N ) & 1;
-
- if ( i == 1 )
- {
- pos1 += nb_pos;
- }
-
- pos[0] = pos1;
-
- return;
-}
-
-/*-------------------------------------------------------*
- * add_pulses()
- *
- * Add decoded pulses to the codeword
- *-------------------------------------------------------*/
-
-static void add_pulses_L_subfr(
- const int16_t nb_pos, /* i : number of positions */
- const int16_t pos[], /* i : pulse position */
- const int16_t nb_pulse, /* i : nb. of pulses */
- const int16_t track, /* i : no. of the tracks */
- float code[] /* i/o: decoded codevector */
-)
-{
- int16_t i, k;
-
- for ( k = 0; k < nb_pulse; k++ )
- {
- i = ( ( pos[k] & ( nb_pos - 1 ) ) * NB_TRACK_FCB_4T ) + track;
- if ( ( pos[k] & nb_pos ) == 0 )
- {
- code[i] += 1.0f;
- }
- else
- {
- code[i] -= 1.0f;
- }
- }
-
- return;
-}
-
-/*----------------------------------------------------------------------------------*
- * dec_acelp_fast()
- *
- * fast algebraic codebook decoder
- *----------------------------------------------------------------------------------*/
-
-void dec_acelp_fast(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t cdk_index, /* i : codebook index */
- float code[], /* o : algebraic (fixed) codebook excitation */
- const int16_t L_subfr /* i : subframe length */
-)
-{
- int16_t k, pos[7], skip_track;
- int32_t L_index;
- PulseConfig config;
-
- skip_track = -1;
- set_f( code, 0.0f, L_subfr );
-
- if ( L_subfr == L_SUBFR )
- {
- config = PulseConfTable[cdk_index];
-
- if ( cdk_index == 2 )
- {
- dec_acelp_2t32( st, code );
- }
- else if ( config.nb_pulse == 2 )
- {
- /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks) */
- for ( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 )
- {
- L_index = get_next_indice( st, 5 );
- dec_1p_N1( L_index, 4, 0, pos );
- add_pulses( pos, 1, k, code );
- }
- }
- else if ( config.nb_pulse == 3 )
- {
- if ( config.codetrackpos == TRACKPOS_FIXED_FIRST )
- {
- /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */
- for ( k = 0; k < NB_TRACK_FCB_4T - 1; k++ )
- {
- L_index = get_next_indice( st, 5 );
- dec_1p_N1( L_index, 4, 0, pos );
- add_pulses( pos, 1, k, code );
- }
- }
- else if ( config.codetrackpos == TRACKPOS_FREE_THREE )
- {
- /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */
- skip_track = get_next_indice( st, 2 );
- for ( k = 0; k < NB_TRACK_FCB_4T; k++ )
- {
- if ( k != skip_track )
- {
- L_index = get_next_indice( st, 5 );
- dec_1p_N1( L_index, 4, 0, pos );
- add_pulses( pos, 1, k, code );
- }
- }
- }
- }
- else
- {
- if ( config.bits == 20 )
- {
- skip_track = -1;
- }
- else if ( config.codetrackpos == TRACKPOS_FIXED_FIRST )
- {
- skip_track = 0;
- }
- else if ( config.codetrackpos == TRACKPOS_FREE_ONE )
- {
- skip_track = get_next_indice( st, 2 );
- }
-
- for ( k = 0; k < NB_TRACK_FCB_4T; k++ )
- {
- if ( k == skip_track )
- {
- L_index = get_next_indice( st, 9 );
- dec_2p_2N1( L_index, 4, 0, pos );
- add_pulses( pos, 2, k, code );
- }
- else
- {
- L_index = get_next_indice( st, 5 );
- dec_1p_N1( L_index, 4, 0, pos );
- add_pulses( pos, 1, k, code );
- }
- }
- }
- }
- else /* L_subfr == 2*L_SUBFR */
- {
- config.bits = cdk_index;
-
- if ( cdk_index == 14 )
- {
- /* 14 bits, 2 pulses, 2 tracks: 11 (used all tracks) */
- int16_t index, i0, i1;
-
- index = get_next_indice( st, 14 );
-
- i0 = ( ( index >> 7 ) & ( NB_POS_FCB_2T_128 - 1 ) ) * NB_TRACK_FCB_2T;
- i1 = ( ( index & ( NB_POS_FCB_2T_128 - 1 ) ) * NB_TRACK_FCB_2T ) + 1;
-
- code[i0] = -1.0f;
- if ( ( index & 0x2000 ) == 0 )
- {
- code[i0] = 1.0f;
- }
-
- code[i1] = -1.0f;
- if ( ( index & 0x40 ) == 0 )
- {
- code[i1] = 1.0f;
- }
- }
- else if ( cdk_index == 12 )
- {
- /* 12 bits, 2 pulses, 4 tracks: 1010 (used only even tracks) */
- for ( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 )
- {
- L_index = get_next_indice( st, 6 );
- dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos );
- add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code );
- }
- }
- else if ( cdk_index == 18 )
- {
- /* 18 bits, 3 pulses, 4 tracks: 1110 (used first three tracks) */
- for ( k = 0; k < NB_TRACK_FCB_4T - 1; k++ )
- {
- L_index = get_next_indice( st, 6 );
- dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos );
- add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code );
- }
- }
- else if ( cdk_index == 20 )
- {
- /* 20 bits, 3 pulses, 4 tracks (used all tracks): 1110, 1101, 1011, 0111 */
- skip_track = get_next_indice( st, 2 );
- for ( k = 0; k < NB_TRACK_FCB_4T; k++ )
- {
- if ( k != skip_track )
- {
- L_index = get_next_indice( st, 6 );
- dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos );
- add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code );
- }
- }
- }
- else if ( cdk_index == 24 )
- {
- /* 24 bits, 4 pulses, 4 tracks: 1111 */
- for ( k = 0; k < NB_TRACK_FCB_4T; k++ )
- {
- L_index = get_next_indice( st, 6 );
- dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos );
- add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code );
- }
- }
- }
-
- return;
-}
-#endif
/*-------------------------------------------------------*
* dec_1p_N1()
diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c
deleted file mode 100644
index 4c0b6a79adb77e503b2fab051ff4eae6d15a1ed2..0000000000000000000000000000000000000000
--- a/lib_dec/dec_LPD.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "rom_com.h"
-#include "cnst.h"
-#include "basop_proto_func.h"
-#include "stat_com.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-
-/*-------------------------------------------------------------------*
- * decoder_LPD()
- *
- * Core decoder MODE2
- *--------------------------------------------------------------------*/
diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index f3443349a1a542e0ff66f85b2ba1650107e1c2f8..d5294eb7a0a9eed009f3475c4f24be9270a76377 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -455,7 +455,7 @@ void decoder_LPD_fx(
}
if ( bfi )
{
- st->plcInfo.nbLostCmpt = add( st->plcInfo.nbLostCmpt, 1 );
+ st->hPlcInfo->nbLostCmpt = add( st->hPlcInfo->nbLostCmpt, 1 );
move16();
}
}
@@ -634,7 +634,7 @@ void decoder_LPD_fx(
/* PLC: [TCX: Tonal Concealment] */
/* Signal that this frame is not TCX */
- TonalMDCTConceal_UpdateState( &st->tonalMDCTconceal, 0, 0, 0, 0 );
+ TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, 0, 0, 0, 0 );
IF( bfi == 0 )
{
@@ -752,21 +752,18 @@ void decoder_LPD_fx(
EQ_16( st->last_codec_mode, MODE2 ) ) )
{
/* waveform adjustment */
+ concealment_signal_tuning_fx( st, bfi, synthFB, past_core_mode );
- concealment_signal_tuning_fx( bfi, st->core,
- synthFB, &st->plcInfo, st->nbLostCmpt, st->prev_bfi,
- st->tonalMDCTconceal.secondLastPcmOut,
- past_core_mode, st->tonalMDCTconceal.lastPcmOut, st );
test();
test();
test();
- IF( ( bfi || st->prev_bfi ) && st->plcInfo.Pitch_fx && ( ( st->plcInfo.concealment_method == TCX_NONTONAL ) ) )
+ IF( ( bfi || st->prev_bfi ) && st->hPlcInfo->Pitch_fx && ( ( st->hPlcInfo->concealment_method == TCX_NONTONAL ) ) )
{
lerp( synthFB, synth, L_frame, L_frameTCX );
test();
if ( !bfi && st->prev_bfi )
{
- st->plcInfo.Pitch_fx = 0;
+ st->hPlcInfo->Pitch_fx = 0;
move16();
}
}
@@ -774,7 +771,7 @@ void decoder_LPD_fx(
IF( !bfi )
{
- TonalMDCTConceal_SaveTimeSignal( &st->tonalMDCTconceal, synthFB, L_frameTCX );
+ TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX );
}
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
decoder_tcx_post_fx( st, synth, synthFB, Aq, bfi, 0 );
@@ -977,13 +974,13 @@ void decoder_LPD_fx(
{
if ( !bfi )
{
- st->plcInfo.nbLostCmpt = 0;
+ st->hPlcInfo->nbLostCmpt = 0;
move16();
}
IF( st->core == 0 )
{
- set_state( st->plcInfo.Transient, st->core, MAX_POST_LEN );
+ set_state( st->hPlcInfo->Transient, st->core, MAX_POST_LEN );
}
}
diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c
deleted file mode 100644
index 76754d2e63d89c341f5edc4c45829f7fb5622401..0000000000000000000000000000000000000000
--- a/lib_dec/dec_ace.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec_acelp.c b/lib_dec/dec_acelp.c
deleted file mode 100644
index 075822eb6512e0d5e8bba7db888b30f3676a419e..0000000000000000000000000000000000000000
--- a/lib_dec/dec_acelp.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local function prototypes
- *---------------------------------------------------------------------*/
diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c
deleted file mode 100644
index d8b8509d91a3370aef0dd7859b6472fa09e15833..0000000000000000000000000000000000000000
--- a/lib_dec/dec_acelp_tcx_main.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "prot.h"
-#include "rom_com.h"
-#include
-#include "options.h"
-#include "stat_dec.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c
index 7edd2354961721af2eb1ee3be18067cd3f76704f..04a41ed46c9a3ca1b4f0110d3eb3b60872886ffa 100644
--- a/lib_dec/dec_acelp_tcx_main_fx.c
+++ b/lib_dec/dec_acelp_tcx_main_fx.c
@@ -10,12 +10,7 @@
#include "stat_com.h"
#include "prot_fx.h"
#include "basop_util.h"
-static void decode_frame_type_fx( Decoder_State *st
-#ifdef IVAS_CODE_CNG
- ,
- STEREO_CNG_DEC_HANDLE hStereoCng
-#endif
-)
+static void decode_frame_type_fx( Decoder_State *st )
{
Word32 L_tmp;
Word16 num_bits;
@@ -259,9 +254,7 @@ static void decode_frame_type_fx( Decoder_State *st
IF( EQ_16( st->m_frame_type, SID_FRAME ) && NE_16( st->hFdCngDec->hFdCngCom->frame_type_previous, ACTIVE_FRAME ) )
{
lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, st->L_frame * 2, st->last_L_frame * 2 );
-#ifdef IVAS_CODE_CNG
- lerp( hStereoCng->olapBufferSynth22, hStereoCng->olapBufferSynth22, st->L_frame * 2, st->last_L_frame * 2 );
-#endif
+
IF( EQ_16( st->L_frame, L_FRAME ) )
{
FOR( n = 0; n < shl( st->L_frame, 1 ); n++ )
@@ -311,10 +304,6 @@ Word16 dec_acelp_tcx_frame_fx(
Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q0 */
Word16 *voice_factors, /* o : voicing factors Q15 */
Word16 pitch_buf[] /* o : floating pitch for each subframe Q6 */
-#ifdef IVAS_CODE_CNG
- ,
- STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */
-#endif
)
{
Word16 num_bits;
@@ -366,12 +355,7 @@ Word16 dec_acelp_tcx_frame_fx(
Word32 total_brate = st->last_total_brate;
move32();
- decode_frame_type_fx( st
-#ifdef IVAS_CODE_CNG
- ,
- hStereoCng
-#endif
- );
+ decode_frame_type_fx( st );
st->force_lpd_reset = 0;
move16();
diff --git a/lib_dec/dec_amr_wb.c b/lib_dec/dec_amr_wb.c
deleted file mode 100644
index 4cf26936b5bb2c1a19e507d12dc47124fac622be..0000000000000000000000000000000000000000
--- a/lib_dec/dec_amr_wb.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * decod_amr_wb()
- *
- * Decode excitation signal in AMR-WB IO mode
- *---------------------------------------------------------------------*/
diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c
index baea98a2c0883f936ad95cb0290a90234fdcadf6..415b4584e53c884068ce8f194e63305bc2ed8dd9 100644
--- a/lib_dec/dec_amr_wb_fx.c
+++ b/lib_dec/dec_amr_wb_fx.c
@@ -71,12 +71,8 @@ void decod_amr_wb_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR
-#ifdef ADD_LRTD
- ,
- 0, NULL
-#endif
- );
+ *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR );
+
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
*--------------------------------------------------------------*/
diff --git a/lib_dec/dec_gen_voic.c b/lib_dec/dec_gen_voic.c
deleted file mode 100644
index b25a46f03b521c59cfd2d349c3cd49bafb0b6183..0000000000000000000000000000000000000000
--- a/lib_dec/dec_gen_voic.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c
index bdfac224f45b0efbfee46ebfe92a8acf010a9f0f..325beb9f3b347fc5183cd875e42b633dd0075449 100644
--- a/lib_dec/dec_gen_voic_fx.c
+++ b/lib_dec/dec_gen_voic_fx.c
@@ -693,11 +693,7 @@ ivas_error decod_gen_voic_ivas_fx(
* Transform domain contribution decoding
*-----------------------------------------------------------------*/
test();
-#ifdef NONBE_FIX_GSC_BSTR
IF( !st_fx->inactive_coder_type_flag && st_fx->coder_type == INACTIVE )
-#else
- IF( GE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && ( st_fx->coder_type == INACTIVE ) )
-#endif
{
transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits );
}
diff --git a/lib_dec/dec_higher_acelp.c b/lib_dec/dec_higher_acelp.c
deleted file mode 100644
index 77bd8dd6dd528cd2e01de22be40d39cbd198b34b..0000000000000000000000000000000000000000
--- a/lib_dec/dec_higher_acelp.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-/*-----------------------------------------------------------------*
- * transf_cdbk_dec()
- *
- * Transform domain contribution decoding
- *-----------------------------------------------------------------*/
diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c
index b1cb2b5161aee7a69f1a9f8c2f141baeb6af73d3..aff7e56564e134e0492ba56f92bed3e6882af87b 100644
--- a/lib_dec/dec_higher_acelp_fx.c
+++ b/lib_dec/dec_higher_acelp_fx.c
@@ -8,7 +8,6 @@
#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Static table prototypes */
-#define IVAS_CODE
#define IVAS_CODE_AVQ
/*-----------------------------------------------------------------*
* transf_cdbk_dec()
@@ -36,7 +35,6 @@ void transf_cdbk_dec_fx(
Flag Overflow = 0;
move32();
#endif
-#ifdef IVAS_CODE
Word16 avq_bit_sFlag;
Word16 trgtSvPos;
Word16 Nsv;
@@ -50,7 +48,7 @@ void transf_cdbk_dec_fx(
move16();
avq_bit_sFlag = 1;
}
-#endif
+
/*--------------------------------------------------------------*
* Set bit-allocation
*--------------------------------------------------------------*/
@@ -112,7 +110,7 @@ void transf_cdbk_dec_fx(
*gain_preQ = round_fx( L_tmp ); /* Q2*/
move16();
}
-#ifdef IVAS_CODE
+
trgtSvPos = sub( Nsv, 1 );
test();
test();
@@ -126,7 +124,7 @@ void transf_cdbk_dec_fx(
move16();
move16();
}
-#endif
+
/*--------------------------------------------------------------*
* Demultiplex and decode subvectors from bit-stream
*--------------------------------------------------------------*/
diff --git a/lib_dec/dec_nelp.c b/lib_dec/dec_nelp.c
deleted file mode 100644
index 167c70dbfb92ffa66483e8fa575c5d73c71c6b0a..0000000000000000000000000000000000000000
--- a/lib_dec/dec_nelp.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec_pit_exc.c b/lib_dec/dec_pit_exc.c
deleted file mode 100644
index 5a894a39c64f8979fdbf07f62e9b2ce6108337f6..0000000000000000000000000000000000000000
--- a/lib_dec/dec_pit_exc.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * dec_pit_exc()
- *
- * Decode pitch-only contribution (used by the GSC technology)
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c
index 4e18eebce4bfc689e7c6fd9e9fc04aa1796636dd..746b668198d4c2d0a3ff030739b0d40d82b23952 100644
--- a/lib_dec/dec_pit_exc_fx.c
+++ b/lib_dec/dec_pit_exc_fx.c
@@ -41,11 +41,6 @@ void dec_pit_exc_fx(
const Word16 nb_subfr_fx /* i : Number of subframe considered */
,
Word16 *gain_buf /*Q14*/
-#ifdef ADD_LRTD
- ,
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-#endif
)
{
Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
@@ -179,12 +174,7 @@ void dec_pit_exc_fx(
/*----------------------------------------------------------------------*
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx
-#ifdef ADD_LRTD
- ,
- tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf
-#endif
- );
+ *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx );
move16();
/*--------------------------------------------------------------*
@@ -207,12 +197,7 @@ void dec_pit_exc_fx(
gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0
-#ifdef ADD_LRTD
- ,
- L_subfr_fx
-#endif
- );
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 );
move16();
}
ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */
@@ -225,12 +210,7 @@ void dec_pit_exc_fx(
gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0
-#ifdef ADD_LRTD
- ,
- L_subfr_fx
-#endif
- );
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 );
move16();
}
ELSE
@@ -457,22 +437,18 @@ void dec_pit_exc_fx(
/* _ None */
/*==========================================================================*/
void dec_pit_exc_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 coder_type, /* i : coding type */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */
- Word16 *code_fx, /* o : innovation */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- const Word16 nb_subfr_fx /* i : Number of subframe considered */
- ,
- Word16 *gain_buf /*Q14*/
-#if 1 // def ADD_LRTD
- ,
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */
+ Word16 *code_fx, /* o : innovation */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 nb_subfr_fx, /* i : Number of subframe considered */
+ Word16 *gain_buf, /*Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
-#endif
)
{
Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
@@ -591,9 +567,11 @@ void dec_pit_exc_ivas_fx(
set16_fx( st_fx->acelp_cfg.pitch_bits, 9, 4 );
set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, 5 );
}
+
/*------------------------------------------------------------------*
* ACELP subframe loop
*------------------------------------------------------------------*/
+
p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
pt_gain = gain_buf; /* pointer to the gain buffer */
@@ -602,12 +580,8 @@ void dec_pit_exc_ivas_fx(
/*----------------------------------------------------------------------*
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx
-#if 1 // def ADD_LRTD
- ,
- tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf
-#endif
- );
+
+ *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
move16();
/*--------------------------------------------------------------*
@@ -623,6 +597,7 @@ void dec_pit_exc_ivas_fx(
IF( EQ_16( use_fcb, 1 ) )
{
inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
+
/*--------------------------------------------------------------*
* Gain decoding
* Estimate spectrum tilt and voicing
@@ -630,18 +605,14 @@ void dec_pit_exc_ivas_fx(
gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0
-#if 1 // def ADD_LRTD
- ,
- L_subfr_fx, 0
-#endif
- );
+ st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 );
move16();
}
ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */
{
/*inov_decode_fx(st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx);*/
inov_decode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, 0, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
+
/*--------------------------------------------------------------*
* Gain decoding
* Estimate spectrum tilt and voicing
@@ -649,12 +620,7 @@ void dec_pit_exc_ivas_fx(
gain_dec_lbr_ivas_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0
-#if 1 // def ADD_LRTD
- ,
- L_subfr_fx, 0
-#endif
- );
+ st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 );
move16();
}
ELSE
diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c
deleted file mode 100644
index 5cb8114088dc5d6abcd144ce55c703781617b56f..0000000000000000000000000000000000000000
--- a/lib_dec/dec_post.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local constants
- *---------------------------------------------------------------------*/
-
-#define FORMAT_POST_FILT_G1 0.75f /*0.75f*/ /*denominator 0.9,0.75,0.15,0.9*/
-
-
-/*--------------------------------------------------------------------------
- * Local function prototypes
- *--------------------------------------------------------------------------*/
-
-
-/*--------------------------------------------------------------------------*
- * Function Init_post_filter_ivas()
- *
- * Post-filter initialization
- *--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------
- * nb_post_filt_ivas()
- *
- * Main routine to perform post filtering of NB signals
- *--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------
- * formant_post_filt_ivas:
- *
- * WB and SWB formant post-filtering
- *--------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
- * Dec_postfilt()
- *
- * Adaptive postfilter main function
- * Short-term postfilter :
- * Hst(z) = Hst0(z) Hst1(z)
- * Hst0(z) = 1/g0 A(gamma2)(z) / A(gamma1)(z)
- * if {hi} = i.r. filter A(gamma2)/A(gamma1) (truncated)
- * g0 = SUM(|hi|) if > 1
- * g0 = 1. else
- * Hst1(z) = 1/(1 - |mu|) (1 + mu z-1)
- * with mu = k1 * gamma3
- * k1 = 1st parcor calculated on {hi}
- * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0
- * Long-term postfilter :
- * harmonic postfilter : H0(z) = gl * (1 + b * z-p)
- * b = gamma_g * gain_ltp
- * gl = 1 / 1 + b
- * computation of delay p on A(gamma2)(z) s(z)
- * sub optimal search
- * 1. search around 1st subframe delay (3 integer values)
- * 2. search around best integer with fract. delays (1/8)
- *----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
- * Dec_formant_postfilt
- *
- * Post - adaptive postfilter main function
- * Short term postfilter :
- * Hst(z) = Hst0(z) Hst1(z)
- * Hst0(z) = 1/g0 A(gamma2)(z) / A(gamma1)(z)
- * if {hi} = i.r. filter A(gamma2)/A(gamma1) (truncated)
- * g0 = SUM(|hi|) if > 1
- * g0 = 1. else
- * Hst1(z) = 1/(1 - |mu|) (1 + mu z-1)
- * with mu = k1 * gamma3
- * k1 = 1st parcor calculated on {hi}
- * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0
- *----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
- * pst_ltp()
- *
- * Perform harmonic postfilter
- *----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
- * search_del()
- *
- * Computes best (shortest) integer LTP delay + fine search
- *---------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
- * filt_plt()
- *
- * Perform long term postfilter
- *----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
- * compute_ltp_l()
- *
- * compute delayed signal, num & den of gain for fractional delay
- * with long interpolation filter
- *----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
- * select_ltp()
- *
- * selects best of (gain1, gain2)
- * with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1
- * and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2
- *----------------------------------------------------------------------------*/
-
-/*! r: 1 = 1st gain, 2 = 2nd gain */
-
-
-/*------------------------------------------------------------------------------------
- * modify_pst_param()
- *
- * Modify gamma1 and gamma2 values in function of the long-term noise level
- *-----------------------------------------------------------------------------------*/
diff --git a/lib_dec/dec_ppp.c b/lib_dec/dec_ppp.c
deleted file mode 100644
index 167c70dbfb92ffa66483e8fa575c5d73c71c6b0a..0000000000000000000000000000000000000000
--- a/lib_dec/dec_ppp.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c
deleted file mode 100644
index 7b4567f7ad8bb192b6f6fa17cb60378fb9ea499e..0000000000000000000000000000000000000000
--- a/lib_dec/dec_prm.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * getTCXMode_ivas()
- *
- * get TCX mode
- *--------------------------------------------------------------------*/
-void getTCXMode_ivas_fx(
- Decoder_State *st, /* i/o: decoder memory state */
- Decoder_State *st0, /* i : bitstream */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-)
-{
- UWord16 ind;
-
- IF( st->tcxonly )
- {
- /* get core */
- ind = get_next_indice_fx( st0, 1 ); /* Store decoder memory of last_core */
- st->core = add( ind, TCX_20_CORE );
- move16();
- /* get class */
- ind = get_next_indice_fx( st0, 2 );
-
- st->clas_dec = ONSET;
- move16();
- IF( ind == 0 )
- {
- st->clas_dec = UNVOICED_CLAS;
- move16();
- }
- ELSE IF( EQ_16( ind, 1 ) )
- {
- IF( GE_16( st->last_good, VOICED_TRANSITION ) )
- {
- st->clas_dec = VOICED_TRANSITION;
- move16();
- }
- ELSE
- {
- st->clas_dec = UNVOICED_TRANSITION;
- move16();
- }
- }
- ELSE IF( EQ_16( ind, 2 ) )
- {
- st->clas_dec = VOICED_CLAS;
- move16();
- }
-
- st->coder_type = INACTIVE;
- move16();
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag )
- {
- st->VAD = get_next_indice_fx( st0, 1 );
- move16();
- }
- ELSE
- {
- st->VAD = 0;
- move16();
- }
- }
- ELSE
- {
- IF( EQ_16( st->mdct_sw, MODE1 ) )
- {
- /* 2 bits instead of 3 as TCX is already signaled */
- st->core = TCX_20_CORE;
- move16();
- st->hTcxCfg->coder_type = get_next_indice_fx( st0, 2 );
- move16();
- st->coder_type = st->hTcxCfg->coder_type;
- move16();
- }
- ELSE
- {
- IF( EQ_16( st->mdct_sw_enable, MODE2 ) )
- {
- IF( get_next_indice_1_fx( st0 ) )
- {
- ind = get_next_indice_fx( st0, 3 );
- assert( !( ind & 4 ) || !"HQ_CORE encountered in dec_prm_ivas" );
- st->core = TCX_20_CORE;
- move16();
- st->hTcxCfg->coder_type = ind;
- move16();
- st->coder_type = st->hTcxCfg->coder_type;
- move16();
- }
- ELSE /* ACELP */
- {
- st->core = ACELP_CORE;
- move16();
- st->coder_type = get_next_indice_fx( st0, 2 );
- move16();
- }
- }
- ELSE
- {
- IF( EQ_16( st->rf_flag, 1 ) )
- {
- IF( !st->use_partial_copy )
- {
- ind = get_next_indice_fx( st0, 1 );
- IF( ind == 0 )
- {
- st->core = ACELP_CORE;
- move16();
- }
- ELSE
- {
- st->core = TCX_20_CORE;
- move16();
- st->hTcxCfg->coder_type = st->coder_type;
- move16();
- }
- }
- }
- ELSE
- {
- ind = get_next_indice_fx( st, 3 );
- IF( LT_16( ind, ACELP_MODE_MAX ) )
- {
- st->core = ACELP_CORE;
- move16();
- st->coder_type = ind;
- move16();
- }
- ELSE
- {
- st->core = TCX_20_CORE;
- move16();
- st->hTcxCfg->coder_type = sub( ind, ACELP_MODE_MAX );
- move16();
- st->coder_type = st->hTcxCfg->coder_type;
- move16();
- }
- }
- }
- }
-
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- test();
- IF( st->igf && EQ_16( st->core, ACELP_CORE ) )
- {
- st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) );
- move16();
- }
-
- IF( st->rf_flag )
- {
- st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */
- move16();
- }
- }
-
- /* Inactive frame detection on non-DTX mode */
- IF( EQ_16( st->coder_type, INACTIVE ) )
- {
- st->VAD = 0;
- move16();
- }
- ELSE
- {
- st->VAD = 1;
- move16();
- }
- }
-
- /*Core extended mode mapping for correct PLC classification*/
- st->core_ext_mode = st->coder_type;
- move16();
- if ( EQ_16( st->coder_type, INACTIVE ) )
- {
- st->core_ext_mode = UNVOICED;
- move16();
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * getTCXWindowing_ivas()
- *
- * get TCX transform type for each subframe
- *--------------------------------------------------------------------*/
-void getTCXWindowing_ivas_fx(
- const Word16 core, /* i : current core */
- const Word16 last_core, /* i : last frame core */
- const Word16 element_mode, /* i : element mode */
- TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
- Decoder_State *st0 /* i : bitstream */
-)
-{
- Word16 overlap_code;
-
- /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */
- test();
- test();
- test();
- IF( EQ_16( last_core, ACELP_CORE ) || EQ_16( last_core, AMR_WB_CORE ) )
- {
- hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP;
- move16();
- }
- ELSE IF( EQ_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, ALDO_WINDOW ) )
- {
- hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP;
- move16();
- }
- ELSE IF( NE_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) )
- {
- hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
- move16();
- }
- ELSE
- {
- hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
- move16();
- }
-
- /* Set the current overlap mode based on the current frame type and coded overlap mode */
- hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
- move16();
-
- IF( NE_16( core, ACELP_CORE ) )
- {
- overlap_code = 0;
- move16();
- IF( get_next_indice_fx( st0, 1 ) )
- {
- overlap_code = add( 2, get_next_indice_fx( st0, 1 ) );
- }
-
- assert( MIN_OVERLAP == 2 && HALF_OVERLAP == 3 );
- hTcxCfg->tcx_curr_overlap_mode = overlap_code;
- move16();
- /*TCX10 : always symmetric windows*/
- test();
- test();
- test();
- IF( EQ_16( core, TCX_20_CORE ) && ( overlap_code == 0 ) && NE_16( last_core, ACELP_CORE ) && NE_16( last_core, AMR_WB_CORE ) )
- {
- hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
- move16();
- }
- }
-
- test();
- IF( NE_16( element_mode, EVS_MONO ) && EQ_16( core, TCX_10_CORE ) )
- {
- /* also read last overlap */
- overlap_code = 0;
- move16();
-
- IF( get_next_indice_fx( st0, 1 ) )
- {
- overlap_code = add( 2, get_next_indice_fx( st0, 1 ) );
- }
-
- hTcxCfg->tcx_last_overlap_mode = overlap_code;
- move16();
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * getLPCparam_ivas()
- *
- * get LPC parameters
- *--------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------*
- * Function dec_prm_ivas() *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- *
- * SQ is used for TCX modes
- *
- * decode parameters according to selected mode *
- *-----------------------------------------------------------------*/
diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c
index 73edd3b3b3c98d0a0018f9e206153a54254a3ec3..3d277807d2fed95764ba8e3c4992662fd26eac4b 100644
--- a/lib_dec/dec_prm_fx.c
+++ b/lib_dec/dec_prm_fx.c
@@ -1742,3 +1742,272 @@ void dec_prm_fx(
return;
}
+
+
+/*-------------------------------------------------------------------*
+ * getTCXMode_ivas()
+ *
+ * get TCX mode
+ *--------------------------------------------------------------------*/
+void getTCXMode_ivas_fx(
+ Decoder_State *st, /* i/o: decoder memory state */
+ Decoder_State *st0, /* i : bitstream */
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+)
+{
+ UWord16 ind;
+
+ IF( st->tcxonly )
+ {
+ /* get core */
+ ind = get_next_indice_fx( st0, 1 ); /* Store decoder memory of last_core */
+ st->core = add( ind, TCX_20_CORE );
+ move16();
+ /* get class */
+ ind = get_next_indice_fx( st0, 2 );
+
+ st->clas_dec = ONSET;
+ move16();
+ IF( ind == 0 )
+ {
+ st->clas_dec = UNVOICED_CLAS;
+ move16();
+ }
+ ELSE IF( EQ_16( ind, 1 ) )
+ {
+ IF( GE_16( st->last_good, VOICED_TRANSITION ) )
+ {
+ st->clas_dec = VOICED_TRANSITION;
+ move16();
+ }
+ ELSE
+ {
+ st->clas_dec = UNVOICED_TRANSITION;
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( ind, 2 ) )
+ {
+ st->clas_dec = VOICED_CLAS;
+ move16();
+ }
+
+ st->coder_type = INACTIVE;
+ move16();
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag )
+ {
+ st->VAD = get_next_indice_fx( st0, 1 );
+ move16();
+ }
+ ELSE
+ {
+ st->VAD = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( st->mdct_sw, MODE1 ) )
+ {
+ /* 2 bits instead of 3 as TCX is already signaled */
+ st->core = TCX_20_CORE;
+ move16();
+ st->hTcxCfg->coder_type = get_next_indice_fx( st0, 2 );
+ move16();
+ st->coder_type = st->hTcxCfg->coder_type;
+ move16();
+ }
+ ELSE
+ {
+ IF( EQ_16( st->mdct_sw_enable, MODE2 ) )
+ {
+ IF( get_next_indice_1_fx( st0 ) )
+ {
+ ind = get_next_indice_fx( st0, 3 );
+ assert( !( ind & 4 ) || !"HQ_CORE encountered in dec_prm_ivas" );
+ st->core = TCX_20_CORE;
+ move16();
+ st->hTcxCfg->coder_type = ind;
+ move16();
+ st->coder_type = st->hTcxCfg->coder_type;
+ move16();
+ }
+ ELSE /* ACELP */
+ {
+ st->core = ACELP_CORE;
+ move16();
+ st->coder_type = get_next_indice_fx( st0, 2 );
+ move16();
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( st->rf_flag, 1 ) )
+ {
+ IF( !st->use_partial_copy )
+ {
+ ind = get_next_indice_fx( st0, 1 );
+ IF( ind == 0 )
+ {
+ st->core = ACELP_CORE;
+ move16();
+ }
+ ELSE
+ {
+ st->core = TCX_20_CORE;
+ move16();
+ st->hTcxCfg->coder_type = st->coder_type;
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ ind = get_next_indice_fx( st, 3 );
+ IF( LT_16( ind, ACELP_MODE_MAX ) )
+ {
+ st->core = ACELP_CORE;
+ move16();
+ st->coder_type = ind;
+ move16();
+ }
+ ELSE
+ {
+ st->core = TCX_20_CORE;
+ move16();
+ st->hTcxCfg->coder_type = sub( ind, ACELP_MODE_MAX );
+ move16();
+ st->coder_type = st->hTcxCfg->coder_type;
+ move16();
+ }
+ }
+ }
+ }
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ test();
+ IF( st->igf && EQ_16( st->core, ACELP_CORE ) )
+ {
+ st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) );
+ move16();
+ }
+
+ IF( st->rf_flag )
+ {
+ st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */
+ move16();
+ }
+ }
+
+ /* Inactive frame detection on non-DTX mode */
+ IF( EQ_16( st->coder_type, INACTIVE ) )
+ {
+ st->VAD = 0;
+ move16();
+ }
+ ELSE
+ {
+ st->VAD = 1;
+ move16();
+ }
+ }
+
+ /*Core extended mode mapping for correct PLC classification*/
+ st->core_ext_mode = st->coder_type;
+ move16();
+ if ( EQ_16( st->coder_type, INACTIVE ) )
+ {
+ st->core_ext_mode = UNVOICED;
+ move16();
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * getTCXWindowing_ivas()
+ *
+ * get TCX transform type for each subframe
+ *--------------------------------------------------------------------*/
+void getTCXWindowing_ivas_fx(
+ const Word16 core, /* i : current core */
+ const Word16 last_core, /* i : last frame core */
+ const Word16 element_mode, /* i : element mode */
+ TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
+ Decoder_State *st0 /* i : bitstream */
+)
+{
+ Word16 overlap_code;
+
+ /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */
+ test();
+ test();
+ test();
+ IF( EQ_16( last_core, ACELP_CORE ) || EQ_16( last_core, AMR_WB_CORE ) )
+ {
+ hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP;
+ move16();
+ }
+ ELSE IF( EQ_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, ALDO_WINDOW ) )
+ {
+ hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP;
+ move16();
+ }
+ ELSE IF( NE_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) )
+ {
+ hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
+ move16();
+ }
+ ELSE
+ {
+ hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
+ move16();
+ }
+
+ /* Set the current overlap mode based on the current frame type and coded overlap mode */
+ hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
+ move16();
+
+ IF( NE_16( core, ACELP_CORE ) )
+ {
+ overlap_code = 0;
+ move16();
+ IF( get_next_indice_fx( st0, 1 ) )
+ {
+ overlap_code = add( 2, get_next_indice_fx( st0, 1 ) );
+ }
+
+ assert( MIN_OVERLAP == 2 && HALF_OVERLAP == 3 );
+ hTcxCfg->tcx_curr_overlap_mode = overlap_code;
+ move16();
+ /*TCX10 : always symmetric windows*/
+ test();
+ test();
+ test();
+ IF( EQ_16( core, TCX_20_CORE ) && ( overlap_code == 0 ) && NE_16( last_core, ACELP_CORE ) && NE_16( last_core, AMR_WB_CORE ) )
+ {
+ hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
+ move16();
+ }
+ }
+
+ test();
+ IF( NE_16( element_mode, EVS_MONO ) && EQ_16( core, TCX_10_CORE ) )
+ {
+ /* also read last overlap */
+ overlap_code = 0;
+ move16();
+
+ IF( get_next_indice_fx( st0, 1 ) )
+ {
+ overlap_code = add( 2, get_next_indice_fx( st0, 1 ) );
+ }
+
+ hTcxCfg->tcx_last_overlap_mode = overlap_code;
+ move16();
+ }
+
+ return;
+}
diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c
deleted file mode 100644
index aca84d9d9cb01237ba9c9d644a876986d3d6335e..0000000000000000000000000000000000000000
--- a/lib_dec/dec_tcx.c
+++ /dev/null
@@ -1,508 +0,0 @@
-
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "prot.h"
-#include "ivas_prot.h"
-#include "prot_fx.h"
-#include
-#include "options.h"
-#include
-#include "stat_com.h"
-#include "cnst.h"
-#include "wmc_auto.h"
-#include "ivas_rom_com.h"
-#include "ivas_prot_fx.h"
-#include "debug.h"
-
-/*-------------------------------------------------------------------*
- * decoder_tcx_post()
- *
- *
- *-------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------*
- * decoder_tcx_tns()
- *
- * TCX: TNS application
- *-------------------------------------------------------------------*/
-
-void decoder_tcx_tns_fx(
- Decoder_State *st, /* i/o: coder memory state */
- const Word16 L_frame_glob, /* i : frame length */
- const Word16 L_spec,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- Word32 x_fx[N_MAX], // Qx
- const Word16 fUseTns, /* i : flag that is set if TNS data is present */
- STnsData *tnsData,
- const Word16 bfi, /* i : Bad frame indicator */
- const Word16 frame_cnt, /* i : frame counter in the super frame */
- const Word16 whitenedDomain,
- Word16 *length )
-{
- Word16 index, isTCX5, L, tmp;
- TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg;
-
- index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */
- move16();
-
- isTCX5 = 0;
- move16();
- L = L_frameTCX;
- move16();
- tmp = L;
- move16();
-
- test();
- IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) )
- {
- test();
- test();
- IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) )
- {
- /* fix sub-window overlap */
- hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
- move16();
- }
-
- test();
- test();
- test();
- IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) )
- {
- L = L_spec;
- move16();
- tmp = L;
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) ||
- ( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) ||
- ( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) &&
- NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) )
- {
- isTCX5 = 1;
- move16();
-
- tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx );
- }
- }
-
- /*-----------------------------------------------------------*
- * Temporal Noise Shaping Synthesis *
- *-----------------------------------------------------------*/
-
-
- test();
- test();
- test();
- IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) )
- {
- /* Apply TNS to get the reconstructed signal */
- SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) );
-
- test();
- test();
- IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) )
- {
- tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx );
- }
-
- ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 );
-
- test();
- test();
- IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) )
- {
- test();
- IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */
- {
- tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC );
- tmp = L_frameTCX;
- move16();
- }
- ELSE
- {
- tcx5TnsUngrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC );
- }
- }
- }
- test();
- IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) )
- {
- tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx );
- }
-
- /* restore index */
- test();
- test();
- test();
- test();
- IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) )
- {
- /* restore sub-window overlap */
- hTcxCfg->tcx_last_overlap_mode = index;
- move16();
- }
-
- if ( length != NULL )
- {
- *length = tmp;
- move16();
- }
-
- return;
-}
-
-
-void decoder_tcx_imdct_fx(
- Decoder_State *st, /* i/o: coder memory state */
- const Word16 L_frame_glob, /* i : frame length */
- const Word16 L_frameTCX_glob,
- const Word16 L_spec,
- const Word16 tcx_offset,
- const Word16 tcx_offsetFB,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 left_rect,
- Word32 x_fx[N_MAX], // Q(11)
- Word16 q_x,
- Word16 xn_buf_fx[], // Q(-2)
- Word16 q_win,
- const UWord16 kernelType, /* i : TCX transform kernel type */
- const Word16 fUseTns, /* i : flag that is set if TNS data is present */
- Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */
- Word16 synthFB_fx[], // Q(-2)
- const Word16 bfi, /* i : Bad frame indicator */
- const Word16 frame_cnt, /* i : frame counter in the super frame */
- const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
-)
-{
- Word16 j, L, overlap, curr_order, startLine, endLine, isTCX5;
- Word16 overlapFB;
- Word32 x_tmp_fx[L_FRAME_PLUS];
- Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 };
- Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX];
- Word16 acelp_zir_fx[L_FRAME_MAX / 2];
- Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN];
- Word16 index, proc = 0;
- TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec;
- TCX_DEC_HANDLE hTcxDec = st->hTcxDec;
- TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg;
- Word16 predictionGain_fx;
- Word16 A_itf_fx[ITF_MAX_FILTER_ORDER + 1]; // q_a_itf
- Word16 q_a_itf = 15;
- Word16 x_e = sub( 31, q_x );
- move16();
- Word16 shift_q = sub( q_x, q_win );
-
- /*-----------------------------------------------------------------*
- * Initializations
- *-----------------------------------------------------------------*/
-
- /* Init lengths */
- overlap = hTcxCfg->tcx_mdct_window_length;
- move16();
- overlapFB = hTcxCfg->tcx_mdct_window_lengthFB;
- move16();
-
- index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */
- move16();
- test();
- test();
- test();
- test();
- IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly != 0 ) && ( frame_cnt != 0 ) && ( bfi == 0 ) && ( st->last_core != ACELP_CORE ) )
- {
- /* fix sub-window overlap */
- hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
- move16();
- }
-
- IF( st->igf != 0 )
- {
- proc = st->hIGFDec->flatteningTrigger;
- move16();
-
- test();
- IF( proc && fUseTns != 0 )
- {
- proc = 0;
- move16();
- }
-
- IF( proc )
- {
-
- startLine = st->hIGFDec->infoIGFStartLine;
- move16();
- endLine = st->hIGFDec->infoIGFStopLine;
- move16();
- curr_order = 0;
- move16();
- predictionGain_fx = 0;
- move16();
- L = L_frameTCX;
- move16();
- isTCX5 = 0;
- move16();
-
- /* interleave again for ITF */
- test();
- IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly )
- {
- test();
- test();
- test();
- IF( ( hTcxCfg->fIsTNSAllowed && ( fUseTns != 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) )
- {
- L = L_spec;
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) ||
- ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) ||
- ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) &&
- ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) )
- {
- isTCX5 = 1;
- move16();
-
- tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx );
- }
- }
-
- FOR( j = startLine; j < endLine; j++ )
- {
- IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) )
- {
- x_itf_fx[j - IGF_START_MN] = x_fx[j]; // q_x
- move32();
- x_fx[j] = st->hIGFDec->virtualSpec_fx[j - IGF_START_MN];
- move32();
- }
- }
-
- ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) );
-
- ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order );
-
- FOR( j = startLine; j < endLine; j++ )
- {
- IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) )
- {
- x_fx[j] = x_itf_fx[j - IGF_START_MN]; // q_x
- move32();
- }
- }
-
- /* deinterleave */
- IF( NE_16( isTCX5, 0 ) )
- {
- tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx );
- }
- }
- }
-
- /*-----------------------------------------------------------*
- * Prepare OLA buffer after waveadjustment. *
- * Compute inverse MDCT of x[]. *
- *-----------------------------------------------------------*/
-
-
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) );
- set32_fx( x_tmp_fx, 0, L_FRAME_PLUS );
- Copy32( x_fx, x_tmp_fx, copy_len ); // q_x
- Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x
- }
- ELSE IF( ( st->element_mode == EVS_MONO ) )
- {
- Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x
- }
- ELSE
- {
- Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) );
- Copy32( x_fx, x_tmp_fx, copy_len ); // q_x
- Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x
- }
-
- IF( ( st->igf != 0 ) )
- {
- set32_fx( xn_bufFB_fx + st->hIGFDec->infoIGFStartLine, 0, L_frameTCX - st->hIGFDec->infoIGFStartLine );
- }
-
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag )
- {
-
- IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2,
- hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index,
- kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win );
- }
-
- /* Generate additional comfort noise to mask potential coding artefacts */
- test();
- test();
- test();
- IF( ( st->flag_cna != 0 ) && NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->cna_dirac_flag == 0 ) )
- {
- generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom );
- FOR( Word16 ind = 0; ind < L_frame; ind++ )
- {
- x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x
- }
- }
-
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) )
- {
- Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x
-
- IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index,
- kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win );
- }
-
- FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
- {
- xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x
- move16();
- }
-
- Word16 ratio_e;
- Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9)
- ratio = shr( ratio, sub( 6, ratio_e ) );
-
- IF( st->element_mode != EVS_MONO )
- {
- IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB,
- hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
- kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
- }
- ELSE
- {
-
- IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
- kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
- }
- FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
- {
- xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x
- }
-
- IF( ( bfi == 0 ) )
- {
- Word16 res_m, res_e = 0;
- move16();
- st->second_last_tns_active = st->last_tns_active;
- move16();
- st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns;
- move16();
- hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch;
- move32();
- hTcxDec->tcxltp_second_last_pitch = st->old_fpitch;
- move32();
- res_m = BASOP_Util_Divide1616_Scale( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max, &res_e );
- st->old_fpitch = L_add( L_shl( hTcxLtpDec->tcxltp_pitch_int, 16 ), L_shl( res_m, add( res_e, 1 ) ) );
-
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- // Using sat as a single instruction shifts and extracts
- st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8
- move32();
- }
-
- IF( GT_16( st->element_mode, EVS_MONO ) )
- {
- res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e );
- st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
- move32();
- }
- ELSE
- {
- res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e );
- st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
- move32();
- }
- }
-
- /* Update old_syn_overl */
- IF( hTcxCfg->last_aldo == 0 )
- {
- Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2)
- FOR( Word16 ind = 0; ind < overlapFB; ind++ )
- {
- hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x
- }
- }
-
- /* Output */
- Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2)
- FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ )
- {
- synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x
- }
-
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * init_tcx_info()
- *
- * Initialize lengths for TCX processing, update IGF subframe info
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c
index a0556437dbdba05954c2ae8cef80c71761abf197..af80ee1f54e8672c19b05e6c29432d91639ccd3f 100644
--- a/lib_dec/dec_tcx_fx.c
+++ b/lib_dec/dec_tcx_fx.c
@@ -9,9 +9,7 @@
#include "basop_util.h"
#include "stl.h"
#include "options.h"
-#include "prot.h"
#include "math.h"
-#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
@@ -155,7 +153,7 @@ void decoder_tcx_fx(
L_frameTCX = st->L_frameTCX_past;
move16();
- left_rect = st->prev_widow_left_rect;
+ left_rect = hTcxDec->prev_widow_left_rect;
move16();
IF( left_rect != 0 )
@@ -192,7 +190,7 @@ void decoder_tcx_fx(
move16();
left_rect = 1;
move16();
- st->prev_widow_left_rect = 1;
+ hTcxDec->prev_widow_left_rect = 1;
move16();
}
ELSE
@@ -204,7 +202,7 @@ void decoder_tcx_fx(
move16();
left_rect = 0;
move16();
- st->prev_widow_left_rect = 0;
+ hTcxDec->prev_widow_left_rect = 0;
move16();
}
@@ -765,42 +763,42 @@ void decoder_tcx_fx(
{
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
- st->plcInfo.concealment_method = TCX_NONTONAL;
+ st->hPlcInfo->concealment_method = TCX_NONTONAL;
move16();
/* tonal/non-tonal decision */
test();
test();
- IF( EQ_16( st->plcInfo.Transient[0], 1 ) && EQ_16( st->plcInfo.Transient[1], 1 ) && EQ_16( st->plcInfo.Transient[2], 1 ) )
+ IF( EQ_16( st->hPlcInfo->Transient[0], 1 ) && EQ_16( st->hPlcInfo->Transient[1], 1 ) && EQ_16( st->hPlcInfo->Transient[2], 1 ) )
{
Word16 sum_word16 = 0;
move16();
FOR( i = 9; i >= 0; i-- )
{
- sum_word16 = add( sum_word16, st->plcInfo.TCX_Tonality[i] );
+ sum_word16 = add( sum_word16, st->hPlcInfo->TCX_Tonality[i] );
}
if ( GE_16( sum_word16, 6 ) )
{
- st->plcInfo.concealment_method = TCX_TONAL;
+ st->hPlcInfo->concealment_method = TCX_TONAL;
move16();
}
}
if ( st->tonal_mdct_plc_active )
{
- st->plcInfo.concealment_method = TCX_TONAL;
+ st->hPlcInfo->concealment_method = TCX_TONAL;
move16();
}
}
if ( GT_16( L_frameTCX, hTcxDec->L_frameTCX ) )
{
- st->plcInfo.concealment_method = TCX_TONAL;
+ st->hPlcInfo->concealment_method = TCX_TONAL;
move16();
}
- temp_concealment_method = st->plcInfo.concealment_method;
+ temp_concealment_method = st->hPlcInfo->concealment_method;
move16();
if ( EQ_16( st->core, TCX_10_CORE ) )
@@ -812,7 +810,7 @@ void decoder_tcx_fx(
/* get the starting location of the subframe in the frame */
IF( EQ_16( st->core, TCX_10_CORE ) )
{
- st->plcInfo.subframe_fx = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) );
+ st->hPlcInfo->subframe_fx = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) );
move16();
}
}
@@ -823,8 +821,7 @@ void decoder_tcx_fx(
IF( bfi == 0 )
{
- TonalMDCTConceal_SaveFreqSignal( &st->tonalMDCTconceal, x, x_e, L_frameTCX,
- L_frame, gainlpc2, gainlpc2_e, gain_tcx_e );
+ TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x, x_e, L_frameTCX, L_frame, gainlpc2, gainlpc2_e, gain_tcx_e );
}
ELSE
{
@@ -854,8 +851,8 @@ void decoder_tcx_fx(
Word16 exp1, exp2;
Word32 E_2ndlast, E_last;
- E_2ndlast = CalculateAbsEnergy_fx( 1, &( st->tonalMDCTconceal.lastBlockData.spectralData[0] ), infoIGFStartLine, &exp2 );
- E_last = CalculateAbsEnergy_fx( 1, &( st->tonalMDCTconceal.lastBlockData.spectralData[1] ), infoIGFStartLine, &exp1 );
+ E_2ndlast = CalculateAbsEnergy_fx( 1, &( st->hTonalMDCTConc->lastBlockData.spectralData[0] ), infoIGFStartLine, &exp2 );
+ E_last = CalculateAbsEnergy_fx( 1, &( st->hTonalMDCTConc->lastBlockData.spectralData[1] ), infoIGFStartLine, &exp1 );
BASOP_Util_Divide_MantExp( extract_h( E_2ndlast ), exp2, extract_h( E_last ), exp1, &tmp1, &tmp2 );
@@ -867,7 +864,7 @@ void decoder_tcx_fx(
FOR( i = 0; i < infoIGFStartLine; i += 2 )
{
move32();
- st->tonalMDCTconceal.lastBlockData.spectralData[i] = st->tonalMDCTconceal.lastBlockData.spectralData[i + 1];
+ st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
}
}
ELSE IF( LT_16( tmp1, 4096 /*0.5 in Q13*/ ) )
@@ -875,7 +872,7 @@ void decoder_tcx_fx(
FOR( i = 0; i < infoIGFStartLine; i += 2 )
{
move32();
- st->tonalMDCTconceal.lastBlockData.spectralData[i + 1] = st->tonalMDCTconceal.lastBlockData.spectralData[i];
+ st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i];
}
}
}
@@ -894,7 +891,7 @@ void decoder_tcx_fx(
tcxGetNoiseFillingTilt( A, M, L_frame, tmp, &noiseTiltFactor );
- TonalMDCTConceal_InsertNoise( &st->tonalMDCTconceal, x, &x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc,
+ TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, &x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc,
noiseTiltFactor, f,
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
concealment_noise,
@@ -982,7 +979,7 @@ void decoder_tcx_fx(
test();
IF( bfi && st->tonal_mdct_plc_active )
{
- TonalMDCTConceal_Apply( &st->tonalMDCTconceal, x, &x_e );
+ TonalMDCTConceal_Apply( st->hTonalMDCTConc, x, &x_e );
}
tmp32 = L_deposit_h( 0 );
@@ -998,11 +995,8 @@ void decoder_tcx_fx(
tmp8 = 1;
move16();
}
- TonalMDCTConceal_UpdateState( &st->tonalMDCTconceal,
- L_frameTCX,
- tmp32,
- bfi,
- tmp8 );
+
+ TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX, tmp32, bfi, tmp8 );
IF( st->enablePlcWaveadjust )
{
@@ -1013,10 +1007,11 @@ void decoder_tcx_fx(
IF( bfi && ( EQ_16( temp_concealment_method, TCX_NONTONAL ) ) )
{
/* x_e =31-x_scale; */
- concealment_decode_fix( core, x, &x_e, &st->plcInfo );
+ concealment_decode_fix( core, x, &x_e, st->hPlcInfo );
}
+
/* update spectrum buffer, tonality flag, etc. */
- concealment_update_x( bfi, core, st->tonality_flag, x, &x_e, &st->plcInfo );
+ concealment_update_x( bfi, core, st->tonality_flag, x, &x_e, st->hPlcInfo );
}
/*-----------------------------------------------------------*
@@ -1307,7 +1302,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx,
{
test();
/* run lpc gain compensation not for waveform adjustment */
- IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->plcInfo.concealment_method, TCX_TONAL ) )
+ IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->hPlcInfo->concealment_method, TCX_TONAL ) )
{
UWord32 dmy;
tmp32_1 /*gainHelperFB*/ = L_shl_r( L_deposit_h( hTcxDec->gainHelper ), sub( hTcxDec->gainHelper_e, 31 - 28 ) ); /*Q28*/
@@ -1477,20 +1472,19 @@ void decoder_tcx_post_fx( Decoder_State *st_fx,
move16();
/* run lpc gain compensation not for waveform adjustment */
test();
- IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->plcInfo.concealment_method, TCX_TONAL ) )
+ IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->hPlcInfo->concealment_method, TCX_TONAL ) )
{
- st_fx->plcInfo.recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB,
- st_fx->last_concealed_gain_syn_deemph ),
- st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/
+ st_fx->hPlcInfo->recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB,
+ st_fx->last_concealed_gain_syn_deemph ),
+ st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/
move16();
}
ELSE
{
- st_fx->plcInfo.recovery_gain = extract_h( conceal_eof_gainFB ); /*Q14*/
+ st_fx->hPlcInfo->recovery_gain = extract_h( conceal_eof_gainFB ); /*Q14*/
move16();
}
- st_fx->plcInfo.step_concealgain_fx =
- round_fx_sat( L_shl_sat( L_mult0( round_fx_sat( step ), round_fx_sat( L_shl_sat( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 3 ) ); /*Q15*/
+ st_fx->hPlcInfo->step_concealgain_fx = round_fx_sat( L_shl_sat( L_mult0( round_fx_sat( step ), round_fx_sat( L_shl_sat( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 3 ) ); /*Q15*/
move16();
}
@@ -1587,7 +1581,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx,
test();
test();
/* run lpc gain compensation not for waveform adjustment */
- IF( 0 == st_fx->enablePlcWaveadjust || ( st_fx->hPlcInfo != NULL && EQ_16( st_fx->plcInfo.concealment_method, TCX_TONAL ) ) )
+ IF( 0 == st_fx->enablePlcWaveadjust || ( st_fx->hPlcInfo != NULL && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_TONAL ) ) )
{
UWord32 dmy;
tmp32_1 /*gainHelperFB*/ = L_shl_r( L_deposit_h( hTcxDec->gainHelper ), sub( hTcxDec->gainHelper_e, 31 - 28 ) ); /*Q28*/
@@ -1806,22 +1800,22 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx,
}
/* run lpc gain compensation not for waveform adjustment */
- test();
- IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->plcInfo.concealment_method, TCX_TONAL ) )
- {
- st_fx->plcInfo.recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB,
- st_fx->last_concealed_gain_syn_deemph ),
- st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/
- move16();
- }
- ELSE
+ IF( st_fx->hPlcInfo != NULL )
{
- st_fx->plcInfo.recovery_gain = extract_h( conceal_eof_gainFB ); /*Q14*/
+ test();
+ IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->hPlcInfo->concealment_method, TCX_TONAL ) )
+ {
+ st_fx->hPlcInfo->recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/
+ move16();
+ }
+ ELSE
+ {
+ st_fx->hPlcInfo->recovery_gain = extract_h( conceal_eof_gainFB ); /*Q14*/
+ move16();
+ }
+ st_fx->hPlcInfo->step_concealgain_fx = round_fx_sat( L_shl_sat( L_mult0( round_fx_sat( L_shr_sat( step, sub( 1, step_e ) ) ), round_fx_sat( L_shl_sat( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 4 ) ); /*Q15*/
move16();
}
- st_fx->plcInfo.step_concealgain_fx =
- round_fx_sat( L_shl_sat( L_mult0( round_fx_sat( L_shr_sat( step, sub( 1, step_e ) ) ), round_fx_sat( L_shl_sat( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 4 ) ); /*Q15*/
- move16();
}
/*-----------------------------------------------------------*
@@ -2642,10 +2636,10 @@ void IMDCT_ivas_fx(
{
Word32 fac;
// fac = shl_sat( mult_r( extract_h( L_shr_sat( hTcxDec->conceal_eof_gain32, sub( 1, hTcxDec->conceal_eof_gain_e ) ) ), st->last_concealed_gain_syn_deemph ), 1 );
- fac = Mpy_32_16_1( hTcxDec->conceal_eof_gain32, st->last_concealed_gain_syn_deemph ); // q = 31 - hTcxDec->conceal_eof_gain_e
+ fac = Mpy_32_16_1( hTcxDec->conceal_eof_gain32, st->last_concealed_gain_syn_deemph ); // q = 31 - hTcxDec->conceal_eof_gain_e - last_concealed_gain_syn_deemph_e
FOR( Word16 ind = 0; ind < overlap; ind++ )
{
- old_syn_overl_fx[ind] = extract_l( L_shl_sat( Mpy_32_32( old_syn_overl_fx[ind], fac ), hTcxDec->conceal_eof_gain_e ) ); // Q(-2)
+ old_syn_overl_fx[ind] = extract_h( L_shl_sat( Mpy_32_16_1( fac, old_syn_overl_fx[ind] ), add( hTcxDec->conceal_eof_gain_e, st->last_concealed_gain_syn_deemph_e ) ) ); // Q(-2)
move16();
}
}
@@ -2688,7 +2682,7 @@ void IMDCT_ivas_fx(
}
move16();
- set16_fx( win_fx, 0, shr( add( L_FRAME_PLUS, L_MDCT_OVLP_MAX ), 1 ) );
+ set16_fx( win_fx, 0, ( L_FRAME_PLUS + L_MDCT_OVLP_MAX ) >> 1 );
Word16 tcx_offset_tmp = add( tcx_offset, shr( L_ola, 1 ) );
set16_fx( xn_buf_fx, 0, tcx_offset_tmp ); /* zero left end of buffer */
@@ -2867,9 +2861,10 @@ void IMDCT_ivas_fx(
q_tmp_fx_32 = q_xn_buf_fx_32;
move16();
+ Word16 diff = sub( q_tmp_fx_32, q_win );
FOR( Word16 ind = 0; ind < L_frame; ind++ )
{
- old_out_fx_32[ind] = L_shl( old_out_fx[ind], sub( q_tmp_fx_32, q_win ) );
+ old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff );
move32();
}
@@ -2877,8 +2872,8 @@ void IMDCT_ivas_fx(
FOR( Word16 ind = 0; ind < L_frame; ind++ )
{
- old_out_fx[ind] = (Word16) L_shr( old_out_fx_32[ind], sub( q_tmp_fx_32, q_win ) );
- xn_buf_fx[ind] = (Word16) L_shr( xn_buf_fx_32[ind], sub( q_tmp_fx_32, q_win ) );
+ old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) );
+ xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) );
move16();
move16();
}
@@ -2902,19 +2897,23 @@ void IMDCT_ivas_fx(
q_tmp_fx_32 = sub( q_xn_buf_fx_32, res_e );
// v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame );
+ Word16 q_diff = sub( q_xn_buf_fx_32, q_win );
FOR( Word16 ind = 0; ind < L_frame; ind++ )
{
- xn_buf_fx[( ind + ( overlap / 2 ) ) + nz] = (Word16) L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], sub( q_xn_buf_fx_32, q_win ) );
+ xn_buf_fx[( ind + ( overlap / 2 ) ) + nz] = extract_l( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) );
move16();
}
window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, &q_old_out, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL );
+ q_diff = sub( q_old_out, q_win );
+
+ Word16 diff = sub( q_tmp_fx_32, q_win );
FOR( Word16 ind = 0; ind < L_frame; ind++ )
{
- old_out_fx[ind] = shr_sat( old_out_fx[ind], sub( q_old_out, q_win ) );
+ old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff );
move16();
- xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], sub( q_tmp_fx_32, q_win ) );
+ xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff );
move16();
}
}
@@ -3610,7 +3609,8 @@ void decoder_tcx_ivas_fx(
st->hHQ_core->Q_old_wtda_LB = 0;
move16();
- Scale_sig( st->hTcxDec->old_syn_Overl, 320, 1 ); // Scaling to Q_syn
+ Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn
+ st->hTcxDec->Q_old_syn_Overl = st->Q_syn;
Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) );
Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn
@@ -3627,7 +3627,8 @@ void decoder_tcx_ivas_fx(
// Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) );
st->hHQ_core->Q_old_wtda_LB = st->Q_syn;
// Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) );
- Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 + st->Q_syn ) ); // Scaling to Q-2
+ Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2
+ st->hTcxDec->Q_old_syn_Overl = -2;
}
/*-------------------------------------------------------------------*
@@ -3808,7 +3809,7 @@ void decoder_tcx_invQ_fx(
FOR( i = 0; i < noiseFillingSize; ++i )
{
tmp32 = L_shr( x[i], sub( 31, *x_e ) );
- *nf_seed = add_o( *nf_seed, (Word16) abs( tmp32 ) * i * 2, &Overflow );
+ *nf_seed = add_o( *nf_seed, extract_l( L_shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ) ), &Overflow ); // abs( tmp32 ) * i * 2
move16();
}
}
@@ -3876,7 +3877,8 @@ void decoder_tcx_invQ_fx(
test();
IF( !st->tcxonly || ( hTcxCfg->resq && hTcxDec->tcx_lpc_shaped_ari ) )
{
- FOR( i = 0; i < max( L_spec, L_frameTCX ); i++ )
+ Word16 len = s_max( L_spec, L_frameTCX );
+ FOR( i = 0; i < len; i++ )
{
xn_buf[i] = ONE_IN_Q14;
move16();
@@ -4409,7 +4411,7 @@ void decoder_tcx_noisefilling_fx(
/* get the starting location of the subframe in the frame */
IF( EQ_16( st->core, TCX_10_CORE ) )
{
- st->hPlcInfo->subframe = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) );
+ st->hPlcInfo->subframe_fx = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) );
move16();
}
}
@@ -4800,11 +4802,11 @@ void decoder_tcx_noiseshaping_igf_fx(
/* spectrum concealment */
IF( bfi && EQ_16( *temp_concealment_method, TCX_NONTONAL ) )
{
- concealment_decode_fix( st->core, x_fx, x_e, &st->hPlcInfo );
+ concealment_decode_fix( st->core, x_fx, x_e, st->hPlcInfo );
}
/* update spectrum buffer, tonality flag, etc. */
- concealment_update_x( bfi, st->core, st->tonality_flag, x_fx, x_e, &st->hPlcInfo );
+ concealment_update_x( bfi, st->core, st->tonality_flag, x_fx, x_e, st->hPlcInfo );
*x_len = s_max( *x_len, st->hPlcInfo->L_frameTCX );
move16();
@@ -4856,3 +4858,449 @@ void decoder_tcx_noiseshaping_igf_fx(
return;
}
+
+
+/*-------------------------------------------------------------------*
+ * decoder_tcx_tns()
+ *
+ * TCX: TNS application
+ *-------------------------------------------------------------------*/
+
+void decoder_tcx_tns_fx(
+ Decoder_State *st, /* i/o: coder memory state */
+ const Word16 L_frame_glob, /* i : frame length */
+ const Word16 L_spec,
+ const Word16 L_frame,
+ const Word16 L_frameTCX,
+ Word32 x_fx[N_MAX], // Qx
+ const Word16 fUseTns, /* i : flag that is set if TNS data is present */
+ STnsData *tnsData,
+ const Word16 bfi, /* i : Bad frame indicator */
+ const Word16 frame_cnt, /* i : frame counter in the super frame */
+ const Word16 whitenedDomain,
+ Word16 *length )
+{
+ Word16 index, isTCX5, L, tmp;
+ TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg;
+
+ index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */
+ move16();
+
+ isTCX5 = 0;
+ move16();
+ L = L_frameTCX;
+ move16();
+ tmp = L;
+ move16();
+
+ test();
+ IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 )
+ {
+ test();
+ test();
+ IF( frame_cnt != 0 && bfi == 0 && st->last_core != ACELP_CORE )
+ {
+ /* fix sub-window overlap */
+ hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) )
+ {
+ L = L_spec;
+ move16();
+ tmp = L;
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) ||
+ ( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) ||
+ ( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) &&
+ NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) )
+ {
+ isTCX5 = 1;
+ move16();
+
+ tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx );
+ }
+ }
+
+ /*-----------------------------------------------------------*
+ * Temporal Noise Shaping Synthesis *
+ *-----------------------------------------------------------*/
+
+
+ test();
+ test();
+ test();
+ IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && fUseTns != 0 && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) )
+ {
+ /* Apply TNS to get the reconstructed signal */
+ SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) );
+
+ test();
+ test();
+ IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 )
+ {
+ tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx );
+ }
+
+ ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 );
+
+ test();
+ test();
+ IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 )
+ {
+ test();
+ IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */
+ {
+ tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC );
+ tmp = L_frameTCX;
+ move16();
+ }
+ ELSE
+ {
+ tcx5TnsUngrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC );
+ }
+ }
+ }
+ test();
+ IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) )
+ {
+ tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx );
+ }
+
+ /* restore index */
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) )
+ {
+ /* restore sub-window overlap */
+ hTcxCfg->tcx_last_overlap_mode = index;
+ move16();
+ }
+
+ if ( length != NULL )
+ {
+ *length = tmp;
+ move16();
+ }
+
+ return;
+}
+
+
+void decoder_tcx_imdct_fx(
+ Decoder_State *st, /* i/o: coder memory state */
+ const Word16 L_frame_glob, /* i : frame length */
+ const Word16 L_frameTCX_glob,
+ const Word16 L_spec,
+ const Word16 tcx_offset,
+ const Word16 tcx_offsetFB,
+ const Word16 L_frame,
+ const Word16 L_frameTCX,
+ const Word16 left_rect,
+ Word32 x_fx[N_MAX], // Q(11)
+ Word16 q_x,
+ Word16 xn_buf_fx[], // Q(-2)
+ Word16 q_win,
+ const UWord16 kernelType, /* i : TCX transform kernel type */
+ const Word16 fUseTns, /* i : flag that is set if TNS data is present */
+ Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */
+ Word16 synthFB_fx[], // Q(-2)
+ const Word16 bfi, /* i : Bad frame indicator */
+ const Word16 frame_cnt, /* i : frame counter in the super frame */
+ const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
+)
+{
+ Word16 j, L, overlap, curr_order, startLine, endLine, isTCX5;
+ Word16 overlapFB;
+ Word32 x_tmp_fx[L_FRAME_PLUS];
+ Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 };
+ Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX];
+ Word16 acelp_zir_fx[L_FRAME_MAX / 2];
+ Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN];
+ Word16 index, proc = 0;
+ TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec;
+ TCX_DEC_HANDLE hTcxDec = st->hTcxDec;
+ TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg;
+ Word16 predictionGain_fx;
+ Word16 A_itf_fx[ITF_MAX_FILTER_ORDER + 1]; // q_a_itf
+ Word16 q_a_itf = 15;
+ Word16 x_e = sub( 31, q_x );
+ move16();
+ Word16 shift_q = sub( q_x, q_win );
+
+ /*-----------------------------------------------------------------*
+ * Initializations
+ *-----------------------------------------------------------------*/
+
+ /* Init lengths */
+ overlap = hTcxCfg->tcx_mdct_window_length;
+ move16();
+ overlapFB = hTcxCfg->tcx_mdct_window_lengthFB;
+ move16();
+
+ index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */
+ move16();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly != 0 ) && ( frame_cnt != 0 ) && ( bfi == 0 ) && ( st->last_core != ACELP_CORE ) )
+ {
+ /* fix sub-window overlap */
+ hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
+ move16();
+ }
+
+ IF( st->igf != 0 )
+ {
+ proc = st->hIGFDec->flatteningTrigger;
+ move16();
+
+ test();
+ IF( proc && fUseTns != 0 )
+ {
+ proc = 0;
+ move16();
+ }
+
+ IF( proc )
+ {
+
+ startLine = st->hIGFDec->infoIGFStartLine;
+ move16();
+ endLine = st->hIGFDec->infoIGFStopLine;
+ move16();
+ curr_order = 0;
+ move16();
+ predictionGain_fx = 0;
+ move16();
+ L = L_frameTCX;
+ move16();
+ isTCX5 = 0;
+ move16();
+
+ /* interleave again for ITF */
+ test();
+ IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly )
+ {
+ test();
+ test();
+ test();
+ IF( ( hTcxCfg->fIsTNSAllowed && ( fUseTns != 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) )
+ {
+ L = L_spec;
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) ||
+ ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) ||
+ ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) &&
+ ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) )
+ {
+ isTCX5 = 1;
+ move16();
+
+ tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx );
+ }
+ }
+
+ FOR( j = startLine; j < endLine; j++ )
+ {
+ IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) )
+ {
+ x_itf_fx[j - IGF_START_MN] = x_fx[j]; // q_x
+ move32();
+ x_fx[j] = st->hIGFDec->virtualSpec_fx[j - IGF_START_MN];
+ move32();
+ }
+ }
+
+ ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) );
+
+ ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order );
+
+ FOR( j = startLine; j < endLine; j++ )
+ {
+ IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) )
+ {
+ x_fx[j] = x_itf_fx[j - IGF_START_MN]; // q_x
+ move32();
+ }
+ }
+
+ /* deinterleave */
+ IF( NE_16( isTCX5, 0 ) )
+ {
+ tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx );
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------*
+ * Prepare OLA buffer after waveadjustment. *
+ * Compute inverse MDCT of x[]. *
+ *-----------------------------------------------------------*/
+
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) );
+ set32_fx( x_tmp_fx, 0, L_FRAME_PLUS );
+ Copy32( x_fx, x_tmp_fx, copy_len ); // q_x
+ Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x
+ }
+ ELSE IF( ( st->element_mode == EVS_MONO ) )
+ {
+ Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x
+ }
+ ELSE
+ {
+ Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) );
+ Copy32( x_fx, x_tmp_fx, copy_len ); // q_x
+ Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x
+ }
+
+ IF( ( st->igf != 0 ) )
+ {
+ set32_fx( xn_bufFB_fx + st->hIGFDec->infoIGFStartLine, 0, L_frameTCX - st->hIGFDec->infoIGFStartLine );
+ }
+
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag )
+ {
+
+ IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2,
+ hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index,
+ kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win );
+ }
+
+ /* Generate additional comfort noise to mask potential coding artefacts */
+ test();
+ test();
+ test();
+ IF( ( st->flag_cna != 0 ) && NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->cna_dirac_flag == 0 ) )
+ {
+ generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom );
+ FOR( Word16 ind = 0; ind < L_frame; ind++ )
+ {
+ x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x
+ }
+ }
+
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) )
+ {
+ Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x
+
+ IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index,
+ kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win );
+ }
+
+ FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
+ {
+ xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x
+ move16();
+ }
+
+ Word16 ratio_e;
+ Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9)
+ ratio = shr( ratio, sub( 6, ratio_e ) );
+
+ IF( st->element_mode != EVS_MONO )
+ {
+ IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB,
+ hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
+ kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
+ }
+ ELSE
+ {
+
+ IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
+ kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
+ }
+ FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
+ {
+ xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x
+ }
+
+ IF( ( bfi == 0 ) )
+ {
+ Word16 res_m, res_e = 0;
+ move16();
+ st->second_last_tns_active = st->last_tns_active;
+ move16();
+ st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns;
+ move16();
+ hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch;
+ move32();
+ hTcxDec->tcxltp_second_last_pitch = st->old_fpitch;
+ move32();
+ res_m = BASOP_Util_Divide1616_Scale( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max, &res_e );
+ st->old_fpitch = L_add( L_shl( hTcxLtpDec->tcxltp_pitch_int, 16 ), L_shl( res_m, add( res_e, 1 ) ) );
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ // Using sat as a single instruction shifts and extracts
+ st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8
+ move32();
+ }
+
+ IF( GT_16( st->element_mode, EVS_MONO ) )
+ {
+ res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e );
+ st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
+ move32();
+ }
+ ELSE
+ {
+ res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e );
+ st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
+ move32();
+ }
+ }
+
+ /* Update old_syn_overl */
+ IF( hTcxCfg->last_aldo == 0 )
+ {
+ Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2)
+ FOR( Word16 ind = 0; ind < overlapFB; ind++ )
+ {
+ hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x
+ }
+ }
+
+ /* Output */
+ Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2)
+ FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ )
+ {
+ synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x
+ }
+
+
+ return;
+}
diff --git a/lib_dec/dec_tran.c b/lib_dec/dec_tran.c
deleted file mode 100644
index 3522990d9e7512fb3e374e685f2eeaf783c9c42f..0000000000000000000000000000000000000000
--- a/lib_dec/dec_tran.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * decod_tran()
- *
- * Decode transition (TC) frames
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/dec_uv.c b/lib_dec/dec_uv.c
deleted file mode 100644
index 9e7ce955844554794434881de1f04317bb321cd3..0000000000000000000000000000000000000000
--- a/lib_dec/dec_uv.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c
index aa898956a106198302bdc046458327e8f84766cf..42f3250fb4595c517537e9e69c54924266a89711 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -114,17 +114,17 @@ void decod_unvoiced_fx(
*-------------------------------------------------------------------*/
void decod_unvoiced_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 coder_type, /* Q0 i : coding type */
- Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */
- Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/
- Word16 *voice_factors_fx, /* Q15 o : voicing factors */
- Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
- Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
+ const Word16 coder_type, /* Q0 i : coding type */
+ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */
+ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/
+ Word16 *voice_factors_fx, /* Q15 o : voicing factors */
+ Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
+ Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
Word16 *gain_buf )
{
Word16 gain_pit_fx; /* Quantized pitch gain */
diff --git a/lib_dec/decision_matrix_dec.c b/lib_dec/decision_matrix_dec.c
deleted file mode 100644
index 9ee7741c0c4a198a48aa0530e4a1ea5eedbc65a7..0000000000000000000000000000000000000000
--- a/lib_dec/decision_matrix_dec.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "stat_dec.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-----------------------------------------------------------------*
- * decision_matrix_dec()
- *
- * ACELP/HQ core selection
- * Read ACELP signaling bits from the bitstream
- * Set extension layers
- *-----------------------------------------------------------------*/
diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c
index a83de038afe2e1fa2a92923f65ca270fec68b461..0bc7794dc7b8322b5e9f670b889945c80aebebdf 100644
--- a/lib_dec/decision_matrix_dec_fx.c
+++ b/lib_dec/decision_matrix_dec_fx.c
@@ -681,12 +681,12 @@ void decision_matrix_dec_fx(
st->nb_subfr = NB_SUBFR16k;
move16();
}
-#if 1 // def ADD_IVAS_BWE 0> NEEDED for IO with conf_acelp1
+
st->extl_orig = st->extl;
move16();
st->extl_brate_orig = st->extl_brate;
move32();
-#endif
+
test();
IF( EQ_32( st->output_Fs, 8000 ) )
{
@@ -713,7 +713,6 @@ void decision_matrix_dec_fx(
move16();
}
-#ifdef NONBE_FIX_GSC_BSTR
/*-----------------------------------------------------------------*
* set inactive coder_type flag in ACELP core
*-----------------------------------------------------------------*/
@@ -727,6 +726,5 @@ void decision_matrix_dec_fx(
move16();
}
-#endif
return;
}
diff --git a/lib_dec/dlpc_avq.c b/lib_dec/dlpc_avq.c
deleted file mode 100644
index 7485444239852003f0b18ae4335fbef950df42cb..0000000000000000000000000000000000000000
--- a/lib_dec/dlpc_avq.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "ivas_prot.h"
-#include "wmc_auto.h"
-
-/*------------------------------------------------------------------*
- * dlpc_avq()
- *
- * Variable bitrate multiple LPC un-quantizer
- *------------------------------------------------------------------*/
diff --git a/lib_dec/dlpc_stoch.c b/lib_dec/dlpc_stoch.c
deleted file mode 100644
index 5645c9462ce135cc2ce17e028132cfccc1c11bac..0000000000000000000000000000000000000000
--- a/lib_dec/dlpc_stoch.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "basop_proto_func.h"
-#include "wmc_auto.h"
-
-/*------------------------------------------------------------------*
- * lpc_unquantize()
- *
- *
- *------------------------------------------------------------------*/
diff --git a/lib_dec/er_dec_acelp.c b/lib_dec/er_dec_acelp.c
deleted file mode 100644
index 047de37fb6036683429cf89828fc94962c92abd6..0000000000000000000000000000000000000000
--- a/lib_dec/er_dec_acelp.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c
index 7c3ecaa0a96c3bec1e70c9ddfea1a4d8891862dd..e30553d388e32c0a53b2b903aa763b120af22ab0 100644
--- a/lib_dec/er_dec_acelp_fx.c
+++ b/lib_dec/er_dec_acelp_fx.c
@@ -446,7 +446,7 @@ void con_acelp_fx(
ELSE
{
/* No harmonic part */
- assert( (int) ( sizeof( buf ) / sizeof( buf[0] ) ) - M - L_EXC_MEM_DEC >= st->L_frame + st->L_frame / 2 );
+ assert( (Word32) ( sizeof( buf ) / sizeof( buf[0] ) ) - M - L_EXC_MEM_DEC >= st->L_frame + st->L_frame / 2 );
set16_fx( &exc[0], 0, add( st->L_frame, shr( st->L_frame, 1 ) ) );
FOR( i = 0; i < st->nb_subfr; i++ )
diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c
deleted file mode 100644
index f2bd702473e2082273549259f57100af6cfdf5c4..0000000000000000000000000000000000000000
--- a/lib_dec/er_dec_tcx.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include "cnst.h"
-#include "ivas_cnst.h"
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "rom_dec.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c
index 8c10e5f810542410d079e27227e72046a05c7921..e804d200927334135725f05bc7294f3e4da06dce 100644
--- a/lib_dec/er_dec_tcx_fx.c
+++ b/lib_dec/er_dec_tcx_fx.c
@@ -1168,7 +1168,7 @@ void con_tcx_ivas_fx(
/* apply pre-emphasis to the signal */
mem = synth[( -( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) - 1 )]; /*Q0*/
move16();
- Q_exc = E_UTIL_f_preemph3_ivas_fx( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 );
+ Q_exc = E_UTIL_f_preemph3_ivas_fx( &( synth[-( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 );
st->Mode2_lp_gainc = L_deposit_l( 0 );
st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) );
@@ -2036,6 +2036,7 @@ void con_tcx_ivas_fx(
st->Q_syn = Q_syn;
move16();
Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/
+ st->hTcxDec->Q_old_syn_Overl = -1;
lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) );
lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) );
hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB;
diff --git a/lib_dec/er_scale_syn.c b/lib_dec/er_scale_syn.c
deleted file mode 100644
index eea698fa6e907be9b333232cf4432772ca777147..0000000000000000000000000000000000000000
--- a/lib_dec/er_scale_syn.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "cnst.h"
-#include "wmc_auto.h"
-
-
-/*----------------------------------------------------------------------------------*
- * Damping_fact_flt()
- *
- * Estimate damping factor
- *----------------------------------------------------------------------------------*/
diff --git a/lib_dec/er_sync_exc.c b/lib_dec/er_sync_exc.c
deleted file mode 100644
index 05720aca8834fe14b074f199d3fc336b361403cc..0000000000000000000000000000000000000000
--- a/lib_dec/er_sync_exc.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "cnst.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c
deleted file mode 100644
index 9cd1332e6ae6cb5131b98ce75c73f777806fef13..0000000000000000000000000000000000000000
--- a/lib_dec/er_util.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "cnst.h"
-#include "stat_com.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c
index 8c94ecf987e1152e94d8c19b63da37c8bdaee5cf..9735129ec14bc56a1aed50c894ac3cf27a087b6a 100644
--- a/lib_dec/er_util_fx.c
+++ b/lib_dec/er_util_fx.c
@@ -439,8 +439,6 @@ Word16 GetPLCModeDecision_ivas_fx(
test();
test();
test();
- // PMT("handle to tonalMDCTconceal is missing")
- //#ifdef ADD_IVAS_HTONALMDCTCONC
IF( ( st->hTonalMDCTConc != NULL && EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) )
/* it is fine to call the detection even if no ltp information
is available, meaning that st->old_fpitch ==
@@ -454,12 +452,8 @@ Word16 GetPLCModeDecision_ivas_fx(
{
pitch = L_add( st->old_fpitch, 0 ); /*Q16*/
}
- // TonalMDCTConceal_Detect_ivas_fx(&st->tonalMDCTconceal, pitch, &numIndices
- // , (st->element_mode == IVAS_CPE_MDCT ? &(st->hTcxCfg->psychParamsTCX20) : st->hTcxCfg->psychParamsCurrent)
- //);
- TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ),
- st->element_mode );
+ TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode );
test();
test();
@@ -554,6 +548,7 @@ Word16 GetPLCModeDecision_fx(
core = st->last_core_bfi;
move16();
}
+
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
st->tonal_mdct_plc_active = 0;
@@ -569,9 +564,7 @@ Word16 GetPLCModeDecision_fx(
test();
test();
test();
- // PMT("handle to tonalMDCTconceal is missing")
- //#ifdef ADD_IVAS_HTONALMDCTCONC
- IF( ( /*st->ADD_IVAS_HTONALMDCTCONC != NULL &&*/ EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) )
+ IF( ( st->hTonalMDCTConc != NULL && EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) )
/* it is fine to call the detection even if no ltp information
is available, meaning that st->old_fpitch ==
st->tcxltp_second_last_pitch == st->L_frame */
@@ -585,24 +578,13 @@ Word16 GetPLCModeDecision_fx(
{
pitch = L_add( st->old_fpitch, 0 ); /*Q16*/
}
- IF( st->element_mode == EVS_MONO )
- {
- TonalMDCTConceal_Detect( &st->tonalMDCTconceal, pitch, &numIndices, st->element_mode
-#ifdef ADD_IVAS_HTONALMDCTCONC
- ,
- ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent )
-#endif
- );
- }
- ELSE
- {
- TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode
-#ifdef ADD_IVAS_HTONALMDCTCONC
- ,
- ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent )
+
+ TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode
+#ifdef IVAS_CODE_MDCT_GSHAPE
+ ,
+ ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent )
#endif
- );
- }
+ );
test();
test();
diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c
deleted file mode 100644
index 47e1f0be1a2a79b57dd772f7d1e5b59af4112750..0000000000000000000000000000000000000000
--- a/lib_dec/evs_dec.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c
index de644843362064518ad334eee93afa097fb7a7f3..74340b530f6fe9cc1c2733664b854cc317f057cf 100644
--- a/lib_dec/evs_dec_fx.c
+++ b/lib_dec/evs_dec_fx.c
@@ -16,9 +16,9 @@
*--------------------------------------------------------------------------*/
ivas_error evs_dec_fx(
- Decoder_State *st_fx, /* i/o : Decoder state structure */
- Word16 output_sp[], /* o : output synthesis signal Q0*/
- frameMode_fx frameMode /* i : Decoder frame mode */
+ Decoder_State *st_fx, /* i/o : Decoder state structure */
+ Word16 output_sp[], /* o : output synthesis signal Q0*/
+ FRAME_MODE frameMode /* i : Decoder frame mode */
)
{
Word16 i, j, output_frame;
@@ -27,7 +27,6 @@ ivas_error evs_dec_fx(
Word16 core_switching_flag;
Word16 unbits;
Word16 hq_core_type;
- Word16 post_hq_delay;
Word32 bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET];
Word16 voice_factors_fx[NB_SUBFR16k];
Word16 hb_synth_fx[L_FRAME48k];
@@ -36,11 +35,7 @@ ivas_error evs_dec_fx(
Word16 exp, fra;
Word16 tmp_buffer_fx[L_FRAME48k];
Word16 tmp16, tmp16_2;
-#ifdef IVAS_CODE
Word16 synth_fx[L_FRAME48k];
-#else
- Word16 synth_fx[L_FRAME48k + HQ_DELTA_MAX * HQ_DELAY_COMP];
-#endif
Word16 fb_exc_fx[L_FRAME16k];
Word16 pitch_buf_fx[NB_SUBFR16k] = { 0 };
Word16 Q_fb_exc;
@@ -58,8 +53,6 @@ ivas_error evs_dec_fx(
Word16 Q_synth;
Word16 Qpostd_prev;
- Word32 *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX];
- Word32 realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word16 timeIn_e;
TD_BWE_DEC_HANDLE hBWE_TD;
HQ_DEC_HANDLE hHQ_core;
@@ -102,15 +95,6 @@ ivas_error evs_dec_fx(
move32();
st_fx->flag_ACELP16k = set_ACELP_flag( EVS_MONO, -1, st_fx->total_brate, 0, 0, -1, -1 );
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer[i] = realBufferTmp[i];
- move32();
- imagBuffer[i] = imagBufferTmp[i];
- move32();
- }
if ( st_fx->bfi == 0 )
{
st_fx->extl = -1;
@@ -159,16 +143,15 @@ ivas_error evs_dec_fx(
test();
IF( !st_fx->bfi && st_fx->prev_bfi && ( EQ_16( st_fx->last_codec_mode, MODE2 ) ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) )
{
- /* v_multc(st_fx->old_out_fx, st_fx->plcInfo.recovery_gain, */
- /* st_fx->old_out_fx, st_fx->L_frameTCX); */
+ /* v_multc(st_fx->old_out_fx, st_fx->hPlcInfo.recovery_gain, st_fx->old_out_fx, st_fx->L_frameTCX); */
FOR( i = 0; i < hTcxDec->L_frameTCX; i++ )
{
- hHQ_core->old_out_fx[i] = shl_sat( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); /*hHQ_core->exp_old_out*/
+ hHQ_core->old_out_fx[i] = shl_sat( mult_r( hHQ_core->old_out_fx[i], st_fx->hPlcInfo->recovery_gain ), 1 ); /*hHQ_core->exp_old_out*/
move16();
}
FOR( i = 0; i < st_fx->L_frame; i++ )
{
- hHQ_core->old_out_LB_fx[i] = shl_sat( mult_r( hHQ_core->old_out_LB_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); /*hHQ_core->exp_old_out*/
+ hHQ_core->old_out_LB_fx[i] = shl_sat( mult_r( hHQ_core->old_out_LB_fx[i], st_fx->hPlcInfo->recovery_gain ), 1 ); /*hHQ_core->exp_old_out*/
move16();
}
/* attenuate PLC buffers, if no aldo window
@@ -283,6 +266,7 @@ ivas_error evs_dec_fx(
/*------------------------------------------------------------------*
* Decoding
*-----------------------------------------------------------------*/
+
IF( EQ_16( st_fx->codec_mode, MODE1 ) )
{
/*------------------------------------------------------------------*
@@ -306,6 +290,7 @@ ivas_error evs_dec_fx(
}
}
}
+
IF( EQ_16( st_fx->codec_mode, MODE1 ) )
{
/*------------------------------------------------------------------*
@@ -333,7 +318,7 @@ ivas_error evs_dec_fx(
/*---------------------------------------------------------------------*
* Preprocessing (preparing) for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- // PMT("core_switching_pre_dec_fx missign args")
+
IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK )
{
return error;
@@ -343,10 +328,10 @@ ivas_error evs_dec_fx(
* ACELP core decoding
* HQ core decoding
*---------------------------------------------------------------------*/
+
IF( EQ_16( st_fx->core, ACELP_CORE ) )
{
/* ACELP core decoder */
-
IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK )
{
return error;
@@ -356,33 +341,24 @@ ivas_error evs_dec_fx(
}
ELSE
{
- // PMT("HQ core missing args")
-
hq_core_dec_fx( st_fx, synth_fx, &Q_synth, output_frame, hq_core_type, core_switching_flag );
Qpostd = Q_synth;
move16();
}
+
/*---------------------------------------------------------------------*
* Postprocessing for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx,
-#ifdef IVAS_CODE_SWITCHING
- output, output_mem[], IVAS_FORMAT ivas_format, use_cldfb_for_dft,
-#endif
- output_frame, core_switching_flag,
-#ifdef IVAS_CODE_SWITCHING
- sba_dirac_stereo_flag, nchan_out,
-#endif
- st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK )
+ if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK )
{
return error;
}
+
/*---------------------------------------------------------------------*
* Pre-processing for bandwidth switching
*---------------------------------------------------------------------*/
- /// PMT("bw_switching_pre_proc_fx missing args")
bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx );
/*---------------------------------------------------------------------*
@@ -398,15 +374,7 @@ ivas_error evs_dec_fx(
ELSE IF( EQ_16( st_fx->extl, WB_BWE ) && st_fx->bws_cnt == 0 )
{
/* WB BWE decoder */
- hb_synth_fx_exp = wb_bwe_dec_fx(
-#ifdef ADD_IVAS_BWE
- NULL,
-#endif
- synth_fx, hb_synth_fx,
-#ifdef ADD_IVAS_BWE
- 0,
-#endif
- output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/
+ hb_synth_fx_exp = wb_bwe_dec_fx( synth_fx, hb_synth_fx, output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/
}
/*---------------------------------------------------------------------*
@@ -436,9 +404,11 @@ ivas_error evs_dec_fx(
test();
IF( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || ( NE_16( st_fx->coder_type, AUDIO ) && NE_16( st_fx->coder_type, INACTIVE ) && GT_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->core, ACELP_CORE ) && GE_32( st_fx->output_Fs, 32000 ) && GT_16( st_fx->bwidth, NB ) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec && !( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) )
{
+ /* SWB TBE decoder */
swb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx,
old_syn_12k8_16k_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, &hb_synth_fx_exp, pitch_buf_fx );
- /* FB TBE decoder/synthesis */
+
+ /* FB TBE decoder */
test();
IF( EQ_16( output_frame, L_FRAME48k ) && EQ_16( st_fx->extl, FB_TBE ) )
{
@@ -449,15 +419,7 @@ ivas_error evs_dec_fx(
( GE_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->core, ACELP_CORE ) && GT_16( st_fx->bwidth, NB ) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec && !( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) )
{
/* SWB BWE decoder */
- hb_synth_fx_exp = swb_bwe_dec_fx(
-#ifdef ADD_IVAS_BWE
- NULL,
-#endif
- st_fx, synth_fx, hb_synth_fx,
-#ifdef ADD_IVAS_BWE
- 0,
-#endif
- output_frame, &Qpostd ); /*Q0*/
+ hb_synth_fx_exp = swb_bwe_dec_fx( st_fx, synth_fx, hb_synth_fx, output_frame, &Qpostd ); /*Q0*/
}
ELSE IF( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || EQ_16( st_fx->extl, FB_BWE_HIGHRATE ) )
{
@@ -495,6 +457,7 @@ ivas_error evs_dec_fx(
/*---------------------------------------------------------------------*
* SWB CNG
*---------------------------------------------------------------------*/
+
IF( GE_16( output_frame, L_FRAME32k ) )
{
/* SHB CNG decoder */
@@ -523,10 +486,7 @@ ivas_error evs_dec_fx(
Scale_sig( st_fx->prev_synth_buffer_fx, tmps, sub( exp, st_fx->Qprev_synth_buffer_fx ) ); /*exp*/
st_fx->Qprev_synth_buffer_fx = exp;
move16();
- Copy( synth_fx, tmp_buffer_fx, output_frame ); /*exp*/
- Copy( st_fx->prev_synth_buffer_fx, synth_fx, tmps ); /*st_fx->Qprev_synth_buffer_fx*/
- Copy( tmp_buffer_fx, synth_fx + tmps, output_frame - tmps ); /*exp*/
- Copy( tmp_buffer_fx + output_frame - tmps, st_fx->prev_synth_buffer_fx, tmps ); /*exp*/
+ delay_signal_fx( synth_fx, output_frame, st_fx->prev_synth_buffer_fx, tmps ); /*exp, t_fx->Qprev_synth_buffer_fx*/
}
ELSE
{
@@ -546,7 +506,7 @@ ivas_error evs_dec_fx(
test();
test();
test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) )
+ IF( EQ_16( st_fx->core, ACELP_CORE ) && !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) )
{
tmps = 0;
move16();
@@ -555,20 +515,8 @@ ivas_error evs_dec_fx(
tmps = NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ); /*Q0*/
}
- waveform_adj2_fix( st_fx->tonalMDCTconceal.secondLastPcmOut,
- synth_fx + tmps,
- st_fx->plcInfo.data_noise,
- &st_fx->plcInfo.outx_new_n1_fx,
- &st_fx->plcInfo.nsapp_gain_fx,
- &st_fx->plcInfo.nsapp_gain_n_fx,
- &st_fx->plcInfo.recovery_gain,
- st_fx->plcInfo.step_concealgain_fx,
- st_fx->plcInfo.Pitch_fx,
- st_fx->plcInfo.FrameSize,
- tmps,
- add( extract_l( st_fx->plcInfo.nbLostCmpt ), 1 ),
- st_fx->bfi );
- st_fx->plcInfo.Pitch_fx = 0;
+ waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth_fx + tmps, tmps, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
+ st_fx->hPlcInfo->Pitch_fx = 0;
move16();
}
@@ -665,16 +613,14 @@ ivas_error evs_dec_fx(
Copy( tmp_buffer_fx, st_fx->hb_prev_synth_buffer_fx, tmps ); /*Q15 - hBWE_TD->prev_hb_synth_fx_exp*/
}
+
/* Delay hb_synth */
tmp16 = sub( hb_synth_fx_exp, hBWE_TD->prev_hb_synth_fx_exp );
IF( tmp16 != 0 )
{
Scale_sig( st_fx->hb_prev_synth_buffer_fx, tmps, tmp16 ); /*Q15 - hb_synth_fx_exp*/
}
- Copy( hb_synth_fx, tmp_buffer_fx, output_frame ); /*Q15 - hb_synth_fx_exp*/
- Copy( st_fx->hb_prev_synth_buffer_fx, hb_synth_fx, tmps ); /*Q15 - hb_synth_fx_exp*/
- Copy( tmp_buffer_fx, hb_synth_fx + tmps, sub( output_frame, tmps ) ); /*Q15 - hb_synth_fx_exp*/
- Copy( tmp_buffer_fx + sub( output_frame, tmps ), st_fx->hb_prev_synth_buffer_fx, tmps ); /*Q15 - hb_synth_fx_exp*/
+ delay_signal_fx( hb_synth_fx, output_frame, st_fx->hb_prev_synth_buffer_fx, tmps ); /*Q15 - hb_synth_fx_exp, Q15 - hb_synth_fx_exp*/
st_fx->old_bwe_delay = tmps;
move16();
@@ -737,7 +683,7 @@ ivas_error evs_dec_fx(
fra = Log2_norm_lc( L_shl( L_tmp, exp ) );
exp = sub( sub( 30, shl( hb_synth_fx_exp, 1 ) ), exp );
L_tmp = Mpy_32_16( exp, fra, LG10 );
- st_fx->last_shb_ener_fx = round_fx_sat( L_shl_sat( L_tmp, 10 ) ); /*Q8*/
+ st_fx->hTdCngDec->last_shb_ener_fx = round_fx_sat( L_shl_sat( L_tmp, 10 ) ); /*Q8*/
}
}
hBWE_TD->prev_hb_synth_fx_exp = hb_synth_fx_exp;
@@ -747,17 +693,16 @@ ivas_error evs_dec_fx(
delta = NS2SA_FX2( st_fx->output_Fs, TCXLTP_DELAY_NS ); /*Q0*/
Scale_sig( hTcxLtpDec->tcxltp_mem_in, delta, sub( Qpostd, Qpostd_prev ) ); /*Qpostd*/
Scale_sig( hTcxLtpDec->tcxltp_mem_out, output_frame, sub( Qpostd, Qpostd_prev ) ); /*Qpostd*/
- tcx_ltp_post( st_fx, hTcxLtpDec, ACELP_CORE, output_frame, 0, synth_fx, NULL );
-
+ tcx_ltp_post_fx( st_fx, hTcxLtpDec, ACELP_CORE, output_frame, 0, synth_fx, NULL );
/* final output of synthesis signal */
Copy( synth_fx, output_sp, output_frame ); /*Qpostd*/
}
- ELSE /* MODE2 PART */
+ ELSE /* Mode 2 */
{
/* -------------------------------------------------------------- */
- /* CONCEALMENT */
+ /* Mode 2 concealment */
/* -------------------------------------------------------------- */
concealWholeFrame = 0;
@@ -797,11 +742,10 @@ ivas_error evs_dec_fx(
/* -------------------------------------------------------------- */
- /* DECODE CORE */
+ /* Decode core */
/* -------------------------------------------------------------- */
- dec_acelp_tcx_frame_fx( st_fx, &concealWholeFrame, output_sp,
- st_fx->p_bpf_noise_buf, pcmbufFB, bwe_exc_extended_fx, voice_factors_fx, pitch_buf_fx );
+ dec_acelp_tcx_frame_fx( st_fx, &concealWholeFrame, output_sp, st_fx->p_bpf_noise_buf, pcmbufFB, bwe_exc_extended_fx, voice_factors_fx, pitch_buf_fx );
concealWholeFrameTmp = concealWholeFrame; /*Q0*/
move16();
@@ -810,10 +754,10 @@ ivas_error evs_dec_fx(
frameMode = FRAMEMODE_MISSING;
move32();
}
+
IF( st_fx->igf )
{
-
- /* TBE interface */
+ /* TBE for Mode 2 interface */
test();
test();
IF( ( st_fx->bfi == 0 || st_fx->last_core == ACELP_CORE ) && st_fx->core == ACELP_CORE )
@@ -919,29 +863,26 @@ ivas_error evs_dec_fx(
IF( ( EQ_16( st_fx->bwidth, SWB ) || EQ_16( st_fx->bwidth, FB ) ) &&
( ( EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
{
- GenTransition_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx,
- hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx,
- hBWE_TD->mem_resamp_HB_32k_fx,
- &( hBWE_TD->syn_dm_phase ), st_fx->output_Fs, hBWE_TD->int_3_over_2_tbemem_dec_fx, st_fx->rf_flag, st_fx->total_brate );
+ GenTransition_fx( hBWE_TD, hb_synth_fx, st_fx->output_Fs, st_fx->rf_flag, st_fx->total_brate );
- hb_synth_fx_exp = st_fx->prev_Q_bwe_syn2;
+ hb_synth_fx_exp = hBWE_TD->prev_Q_bwe_syn2;
move16();
}
ELSE IF( EQ_16( st_fx->bwidth, WB ) && EQ_16( st_fx->last_extl, WB_TBE ) )
{
- GenTransition_WB_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, st_fx->prev_Qx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx,
- hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, st_fx->output_Fs, hBWE_TD->mem_resamp_HB_fx );
+ GenTransition_WB_fx( hBWE_TD, hb_synth_fx, st_fx->output_Fs );
- hb_synth_fx_exp = st_fx->prev_Qx;
+ hb_synth_fx_exp = hBWE_TD->prev_Qx;
move16();
}
- TBEreset_dec_fx( st_fx, st_fx->bwidth );
+ TBEreset_dec_fx( st_fx );
}
ELSE IF( EQ_16( st_fx->last_codec_mode, MODE1 ) )
{
swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );
+
IF( EQ_16( st_fx->extl, FB_TBE ) )
{
set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
@@ -949,7 +890,8 @@ ivas_error evs_dec_fx(
move16();
fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx );
}
- swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx );
+
+ swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );
}
}
}
@@ -963,10 +905,23 @@ ivas_error evs_dec_fx(
}
/* -------------------------------------------------------------- */
- /* APPLY POSTPROC */
+ /* Postprocessing */
/* -------------------------------------------------------------- */
{
+ Word32 *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX];
+ Word32 realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
+ realBuffer[i] = realBufferTmp[i];
+ move32();
+ imagBuffer[i] = imagBufferTmp[i];
+ move32();
+ }
+
nab = s_min( st_fx->cldfbAna->no_channels, st_fx->cldfbSyn->no_channels ); /*Q0*/
st_fx->cldfbSyn->lsb = s_min( st_fx->cldfbAna->no_channels, st_fx->cldfbSyn->no_channels ); /*Q0*/
st_fx->cldfbSyn->usb = st_fx->cldfbSyn->no_channels; /*Q0*/
@@ -982,11 +937,12 @@ ivas_error evs_dec_fx(
test();
IF( st_fx->hFdCngDec != NULL && ( EQ_32( st_fx->sr_core, 8000 ) || EQ_32( st_fx->sr_core, INT_FS_12k8 ) || EQ_32( st_fx->sr_core, INT_FS_16k ) ) && LE_32( st_fx->total_brate, ACELP_32k ) )
{
- /***************************************
- In CLDFB domain:
- - perform noise estimation during active frames
- - do CNG during inactive frames
- ****************************************/
+ /* -------------------------------------------------------------- *
+ * In CLDFB domain:
+ * - perform noise estimation during active frames
+ * - do CNG during inactive frames
+ * -------------------------------------------------------------- */
+
HANDLE_FD_CNG_DEC hFdCngDec = st_fx->hFdCngDec;
noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD && EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ), output_sp, 0 );
@@ -1034,7 +990,7 @@ ivas_error evs_dec_fx(
}
Scale_sig( output_sp, st_fx->L_frame, timeIn_e ); /*timeIn_e*/
timeIn_e = negate( timeIn_e );
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &st_fx->scaleFactor, output_sp, timeIn_e, CLDFB_NO_COL_MAX, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &st_fx->scaleFactor, output_sp, timeIn_e, CLDFB_NO_COL_MAX, workBuffer );
st_fx->scaleFactor.hb_scale = st_fx->scaleFactor.lb_scale;
move16();
}
@@ -1047,6 +1003,7 @@ ivas_error evs_dec_fx(
Copy( st_fx->hFdCngDec->hFdCngCom->A_cng, A, M + 1 ); /*Q12*/
update_decoder_LPD_cng( st_fx, st_fx->coder_type, timeDomainBuffer, A, st_fx->p_bpf_noise_buf );
+
/* Generate additional comfort noise to mask potential coding artefacts */
test();
test();
@@ -1065,6 +1022,7 @@ ivas_error evs_dec_fx(
move16();
}
}
+
/* check if the CLDFB works on the right sample rate */
IF( NE_16( i_mult( st_fx->cldfbAna->no_channels, st_fx->cldfbAna->no_col ), st_fx->L_frame ) )
{
@@ -1095,7 +1053,7 @@ ivas_error evs_dec_fx(
}
timeIn_e = negate( timeIn_e );
- cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &st_fx->scaleFactor, timeDomainBuffer, timeIn_e, CLDFB_NO_COL_MAX, workBuffer );
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &st_fx->scaleFactor, timeDomainBuffer, timeIn_e, CLDFB_NO_COL_MAX, workBuffer );
}
IF( st_fx->flag_cna == 0 )
@@ -1145,8 +1103,7 @@ ivas_error evs_dec_fx(
}
timeIn_e = s_min( 0, add( timeIn_e, 2 ) );
- cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &st_fx->scaleFactor, output_sp, timeIn_e, CLDFB_NO_COL_MAX, workBuffer );
- /*CLDFB output always in timeIn_e*/
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &st_fx->scaleFactor, output_sp, timeIn_e, CLDFB_NO_COL_MAX, workBuffer ); /*CLDFB output always in timeIn_e*/
/* MODE1 MDCT to ACELP 2 transition */
delay_comp = NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS );
@@ -1234,10 +1191,9 @@ ivas_error evs_dec_fx(
/* Delay compensation for TD-BWE*/
IF( GE_16( output_frame, L_FRAME16k ) )
{
- Copy( output_sp, tmp_buffer_fx, output_frame ); /*timeIn_e*/
- Copy_Scale_sig( st_fx->prev_synth_buffer_fx, output_sp, delay_tdbwe, negate( timeIn_e ) ); /*st_fx->q_prev_synth_buffer_fx*/
- Copy( tmp_buffer_fx, output_sp + delay_tdbwe, sub( output_frame, delay_tdbwe ) ); /*timeIn_e*/
- Copy_Scale_sig( tmp_buffer_fx + sub( output_frame, delay_tdbwe ), st_fx->prev_synth_buffer_fx, delay_tdbwe, timeIn_e ); /*timeIn_e*/
+ Scale_sig( st_fx->prev_synth_buffer_fx, delay_tdbwe, negate( timeIn_e ) );
+ delay_signal_fx( output_sp, output_frame, st_fx->prev_synth_buffer_fx, delay_tdbwe ); /*timeIn_e, st_fx->q_prev_synth_buffer_fx*/
+ Scale_sig( st_fx->prev_synth_buffer_fx, delay_tdbwe, timeIn_e );
}
test();
@@ -1271,11 +1227,11 @@ ivas_error evs_dec_fx(
( ( EQ_16( st_fx->last_core, ACELP_CORE ) ) && ( NE_16( st_fx->bwidth, NB ) && EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) ) &&
( GT_32( st_fx->output_Fs, 8000 ) ) )
{
+ /* Add the delayed hb_synth component to the delayed core synthesis */
add_vec_fx( output_sp, negate( timeIn_e ), hb_synth_fx, hb_synth_fx_exp, output_sp, negate( timeIn_e ), output_frame );
}
}
-
IF( EQ_32( st_fx->output_Fs, 8000 ) )
{
tmps = NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ); /*Q0*/
@@ -1289,19 +1245,23 @@ ivas_error evs_dec_fx(
test();
test();
test();
+ /* TCX/ACELP/HQ-CORE->TCX */
IF( ( st_fx->bfi && GT_16( st_fx->last_core, ACELP_CORE ) ) || GT_16( st_fx->core, ACELP_CORE ) )
{
test();
test();
test();
test();
+ /* TCX / HQ-CORE / TD-TCX-PLC -> TCX / TD-TCX-PLC */
IF( GT_16( st_fx->last_core_bfi, ACELP_CORE ) || ( st_fx->bfi && st_fx->last_core > ACELP_CORE ) || ( st_fx->prev_bfi && st_fx->last_con_tcx ) )
{
Copy_Scale_sig( hTcxDec->FBTCXdelayBuf, output_sp, tmps, negate( timeIn_e ) ); /*Q0*/
Copy_Scale_sig( pcmbufFB, output_sp + tmps, sub( hTcxDec->L_frameTCX, tmps ), negate( timeIn_e ) ); /*Q0*/
}
+ /* ACELP -> TCX */
ELSE
{
+ /*cross-fading between LB-TCX and FB-TCX over 2.3125ms*/
Word16 step, alpha;
i = 15;
@@ -1327,15 +1287,16 @@ ivas_error evs_dec_fx(
{
IF( EQ_32( st_fx->output_Fs, 8000 ) )
{
- Copy( hTcxDec->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*st_fx->q_prev_synth_buffer_fx*/
+ Copy( hTcxDec->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*st_fx->q_prev_synth_buffer_fx*/
}
ELSE
{
- Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /*st_fx->Qprev_synth_buffer_fx*/
- Copy( hTcxDec->FBTCXdelayBuf + NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st_fx->delay_buf_out_fx, NS2SA( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*Q0*/
+ Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /*st_fx->Qprev_synth_buffer_fx*/
+ Copy( hTcxDec->FBTCXdelayBuf + NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st_fx->delay_buf_out_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*Q0*/
}
}
}
+ /* TCX/TD TCX PLC->ACELP */
ELSE IF( ( EQ_16( st_fx->last_codec_mode, MODE2 ) ) && ( GT_16( st_fx->last_core, ACELP_CORE ) ) )
{
Word16 step, alpha;
@@ -1362,46 +1323,18 @@ ivas_error evs_dec_fx(
Scale_sig( output_sp, output_frame, timeIn_e ); /*timeIn_e*/
- tcx_ltp_post( st_fx, hTcxLtpDec, st_fx->core, output_frame /*hTcxDec->L_frameTCX*/, NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS ) + tmps,
- output_sp, hTcxDec->FBTCXdelayBuf );
+ tcx_ltp_post_fx( st_fx, hTcxLtpDec, st_fx->core, output_frame /*hTcxDec->L_frameTCX*/, add( NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS ), tmps ), output_sp, hTcxDec->FBTCXdelayBuf );
Copy( output_sp, synth_fx, output_frame ); /*timeIn_e*/
- } /* end of MODE2 */
+ } /* end of Mode 2 */
/*----------------------------------------------------------------*
* Save synthesis for HQ FEC
*----------------------------------------------------------------*/
- // PMT("The code below could be move to save_synthesis_hq_fec")
- post_hq_delay = NS2SA_FX2( st_fx->output_Fs, POST_HQ_DELAY_NS );
- IF( EQ_16( st_fx->codec_mode, MODE1 ) )
- {
- Copy( hTcxDec->synth_history_fx + output_frame, hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ) ) ); /*hTcxDec->q_synth_history_fx*/
- Copy_Scale_sig( synth_fx, hTcxDec->old_synthFB_fx + sub( output_frame, post_hq_delay ), output_frame, negate( Qpostd ) ); /* output_sp not initialized yet */
- /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill
- this buffer are not available for all cases, the impact on the output is limited */
- set16_fx( hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay );
+ save_synthesis_hq_fec_fx( st_fx, synth_fx, NULL, output_frame, Qpostd, NULL );
- IF( GE_16( output_frame, L_FRAME16k ) )
- {
- Copy_Scale_sig( st_fx->prev_synth_buffer_fx, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( st_fx->Qprev_synth_buffer_fx ) ); /*Q0*/
- }
- IF( NE_16( st_fx->core, ACELP_CORE ) )
- {
- IF( GE_16( output_frame, L_FRAME16k ) )
- {
- Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/
- Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/
- }
- ELSE
- {
-
- Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/
- Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ) - NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/
- }
- }
- }
/*----------------------------------------------------------------*
* HP filtering
*----------------------------------------------------------------*/
diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c
deleted file mode 100644
index dd3adb2470ab33c3b0d5da3f21bad0e8c9cb366b..0000000000000000000000000000000000000000
--- a/lib_dec/fd_cng_dec.c
+++ /dev/null
@@ -1,1393 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "ivas_prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h"
-#include "ivas_rom_dec.h"
-#include "ivas_rom_com_fx.h"
-#include "prot_fx.h"
-#include "ivas_prot_fx.h"
-#include "basop_util.h"
-#include "rom_basop_util.h"
-
-/*-------------------------------------------------------------------
- * Local constants
- *-------------------------------------------------------------------*/
-
-#define DELTA_MASKING_NOISE_Q15 0
-#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */
-#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */
-#define LOG_10_BASE_2 1783446566 /* Q29 */
-#define GAIN_Q_OFFSET_IVAS_FX 45
-#define LOG_10_BASE_2_BY_10_Q31 713378606
-#define TWO_BY_THREE_Q31 1431655765
-#define ONE_BY_FRAMES_PER_SEC_Q15 656
-#define NB_LAST_BAND_SCALE_Q31 1717986918
-#define SWB_13k2_LAST_BAND_SCALE_Q31 1717986918
-
-/*-------------------------------------------------------------------
- * Local fucntions declarations
- *-------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------
- * createFdCngDec()
- *
- * Create an instance of type FD_CNG
- *-------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------
- * initFdCngDec()
- *
- * Initialize an instance of type FD_CNG
- *-------------------------------------------------------------------*/
-void configureFdCngDec_ivas_fx(
- HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
- const Word16 bwidth, /*Q0*/
- const Word32 total_brate, /*Q0*/
- const Word16 L_frame, /*Q0*/
- const Word16 last_L_frame, /*Q0*/
- const Word16 element_mode /*Q0*/ )
-{
- Word16 j, stopBandFR;
- HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom;
-
- hsCom->CngBandwidth = bwidth; /*Q0*/
- move16();
- if ( EQ_16( hsCom->CngBandwidth, FB ) )
- {
- hsCom->CngBandwidth = SWB;
- move16();
- }
- test();
- IF( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) )
- {
- hsCom->CngBitrate = total_brate; /*Q0*/
- move32();
- }
- ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) )
- {
- /* set minimum active CBR bitrate IF CngBitrate is uninitialized */
- IF( element_mode > EVS_MONO )
- {
- hsCom->CngBitrate = IVAS_13k2;
- move32();
- }
- ELSE
- {
- hsCom->CngBitrate = ACELP_7k20;
- move32();
- }
- }
-
- /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */
- /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */
- if ( EQ_16( element_mode, IVAS_CPE_MDCT ) )
- {
- hsCom->CngBitrate = IVAS_48k;
- move32();
- }
- hsCom->numSlots = 16;
- move32();
-
- /* NB configuration */
- IF( EQ_16( bwidth, NB ) )
- {
- hsCom->FdCngSetup = FdCngSetup_nb;
- hsCom->numCoreBands = 16;
- move16();
- hsCom->regularStopBand = 16;
- move16();
- }
-
- /* WB configuration */
- ELSE IF( EQ_16( bwidth, WB ) )
- {
- /* FFT 6.4kHz, no CLDFB */
- test();
- test();
- IF( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) )
- {
- hsCom->FdCngSetup = FdCngSetup_wb1;
- hsCom->numCoreBands = 16;
- move16();
- hsCom->regularStopBand = 16;
- move16();
- }
- /* FFT 6.4kHz, CLDFB 8.0kHz */
- ELSE IF( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) )
- {
- hsCom->FdCngSetup = FdCngSetup_wb2;
- hsCom->numCoreBands = 16;
- move16();
- hsCom->regularStopBand = 20;
- move16();
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- hsCom->FdCngSetup = FdCngSetup_wb2;
- hsCom->numCoreBands = 20;
- move16();
- hsCom->regularStopBand = 20;
- move16();
- hsCom->FdCngSetup.fftlen = 640;
- move16();
- hsCom->FdCngSetup.stopFFTbin = 256;
- move16();
- }
- }
- /* FFT 8.0kHz, no CLDFB */
- ELSE
- {
- hsCom->FdCngSetup = FdCngSetup_wb3;
- hsCom->numCoreBands = 20;
- move16();
- hsCom->regularStopBand = 20;
- move16();
- }
- }
-
- /* SWB/FB configuration */
- ELSE
- {
- /* FFT 6.4kHz, CLDFB 14kHz */
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- hsCom->FdCngSetup = FdCngSetup_swb1;
- hsCom->numCoreBands = 16;
- move16();
- hsCom->regularStopBand = 35;
- move16();
- }
- /* FFT 8.0kHz, CLDFB 16kHz */
- ELSE
- {
- hsCom->FdCngSetup = FdCngSetup_swb2;
- hsCom->numCoreBands = 20;
- move16();
- hsCom->regularStopBand = 40;
- move16();
- test();
- if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) )
- {
- hsCom->regularStopBand = 35;
- move16();
- }
- }
- }
-
-
- hsCom->fftlen = hsCom->FdCngSetup.fftlen;
- move16();
- hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin;
- move16();
-
- /* Configure the SID quantizer and the Comfort Noise Generator */
-
- hsCom->startBand = 2;
- move16();
- hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/
- initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 );
-
- IF( EQ_16( hsCom->stopFFTbin, 160 ) )
- {
- hsCom->nFFTpart = 17;
- move16();
- }
- ELSE IF( EQ_16( hsCom->stopFFTbin, 256 ) )
- {
- hsCom->nFFTpart = 20;
- move16();
- }
- ELSE
- {
- hsCom->nFFTpart = 21;
- move16();
- }
- hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /*Q0*/
- move16();
- FOR( j = 0; j < hsCom->nCLDFBpart; j++ )
- {
- hsCom->CLDFBpart[j] = sub( hsCom->part[( j + hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); /*Q0*/
- move16();
- hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )];
- move16();
- }
-
- stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/);
- move16();
- if ( GT_16( stopBandFR, hsCom->stopFFTbin ) )
- {
- stopBandFR = hsCom->stopFFTbin; /*Q0*/
- move16();
- }
-
- initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR );
-
- hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/
- move16();
-
- BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) );
- BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) );
-
- SWITCH( hsCom->fftlen )
- {
- case 512:
- hsCom->olapWinAna_fx = olapWinAna512_fx; /*Q30*/
- hsCom->fftSineTab_fx = NULL;
- hsCom->olapWinSyn_fx = olapWinSyn256_fx; /*Q15*/
- hsCom->fftlenShift = 8;
- move16();
- hsCom->fftlenFac = 32767 /*1.0 Q15*/;
- move16();
- BREAK;
- case 640:
- hsCom->olapWinAna_fx = olapWinAna640_fx; /*Q30*/
- hsCom->fftSineTab_fx = fftSineTab640_fx; /*Q15*/
- hsCom->olapWinSyn_fx = olapWinSyn320_fx; /*Q15*/
- hsCom->fftlenShift = 9;
- move16();
- hsCom->fftlenFac = 20480 /*0.625 Q15*/;
- move16();
- BREAK;
- default:
- assert( !"Unsupported FFT length for FD-based CNG" );
- BREAK;
- }
- BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) );
- BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) );
- hsCom->frameSize = shr( hsCom->fftlen, 1 );
-
- return;
-}
-
-/*-------------------------------------------------------------------
- * deleteFdCngDec()
- *
- * Delete the instance of type FD_CNG
- *-------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------
- * ApplyFdCng()
- *
- * Apply the CLDFB-based CNG at the decoder
- *-------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------
- * FdCng_decodeSID()
- *
- * Decode the FD-CNG bitstream
- *-------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------
- * FdCng_decodeSID_ivas_fx()
- *
- * Decode the FD-CNG bitstream
- *-------------------------------------------------------------------*/
-
-void FdCng_decodeSID_ivas_fx(
- Decoder_State *st /* i/o: decoder state structure */
-)
-{
- Word16 N;
- Word32 *sidNoiseEst;
- Word32 gain;
- Word16 i, index;
- Word32 v[32];
- Word16 indices[32];
- HANDLE_FD_CNG_COM hFdCngCom;
- Word32 *invTrfMatrix_fx;
- Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC];
- Word16 tmp16;
-
- IF( st->element_mode == EVS_MONO )
- {
- tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0;
- move16();
- }
- ELSE
- {
- tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0;
- move16();
- }
-
- const Word16 gain_q_offset = tmp16; /* Q0 */
- move16();
-
- invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/
-
- hFdCngCom = ( st->hFdCngDec )->hFdCngCom;
-
- sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q16*/
-
- N = hFdCngCom->npart; /*Q0*/
- move16();
- gain = 0;
- move32();
- hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 );
- move16();
-
- /* Read bitstream */
- FOR( i = 0; i < FD_CNG_stages_37bits; i++ )
- {
- indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/
- move16();
- }
-
- index = get_next_indice_fx( st, 7 );
-
- /* MSVQ decoder */
-
- IF( st->element_mode != EVS_MONO )
- {
- create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC );
- msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 );
- }
- ELSE
- { /* Legacy EVS_MONO MSVQ tables */
- msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 );
- }
-
-
- /* Decode gain */
- // gain = ((float)index - gain_q_offset) / 1.5f;
- gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15
-
- /* Apply gain and undo log */
- Word16 res_exp[NPART];
- Word16 max_res_exp = 0;
- move16();
- FOR( i = 0; i < N; i++ )
- {
- sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/
- move32();
- if ( LT_16( max_res_exp, res_exp[i] ) )
- {
- max_res_exp = res_exp[i];
- move16();
- }
- }
-
- FOR( i = 0; i < N; i++ )
- {
- sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); /*Q31 - max_res_exp*/
- move32();
- }
-
- hFdCngCom->sidNoiseEstExp = max_res_exp;
- move16();
-
- /* NB last band energy compensation */
-
- IF( hFdCngCom->CngBandwidth == NB )
- {
- sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/
- move32();
- }
-
- test();
- IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
- {
- sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/
- move32();
- }
-
- scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 );
- hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp;
- move16();
-
- lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac );
-
- return;
-}
-
-/*-------------------------------------------------------------------
- * noisy_speech_detection()
- *
- *
- *-------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------
- * generate_comfort_noise_dec()
- *
- * Generate the comfort noise based on the target noise level
- *-------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------
- * generate_masking_noise()
- *
- * Generate additional comfort noise (kind of noise filling)
- *-------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------
- * generate_masking_noise_ivas_fx()
- *
- * Generate additional comfort noise (kind of noise filling)
- *-------------------------------------------------------------------*/
-
-void generate_masking_noise_ivas_fx(
- Word32 *timeDomainBuffer, /* i/o: time-domain signal Q31 - *exp_out*/
- Word16 *exp_out, /* o : time-domain signal exp */
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const Word16 length, /* i : frame size Q0*/
- const Word16 core, /* i : core Q0*/
- const Word16 return_noise, /* i : noise is returned instead of added Q0*/
- const Word16 secondary, /* i : flag to indicate secondary noise generation Q0*/
- const Word16 element_mode, /* i : element mode Q0*/
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 nchan_out /* i : number of output channels Q0*/
-)
-{
- Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel;
- Word32 *ptr_level_fx = cngNoiseLevel_fx;
- Word32 *fftBuffer_fx = hFdCngCom->fftBuffer;
- Word16 i;
- Word32 maskingNoise_fx[L_FRAME16k];
- Word32 *ptr_r_fx;
- Word32 *ptr_i_fx;
- Word16 startBand;
- Word16 *seed = &( hFdCngCom->seed );
- Word32 scale_fx;
- Word16 shift;
- scale_fx = 0x40000000; // 1.0 in Q30
- move32();
- startBand = hFdCngCom->startBand; /*Q0*/
- move16();
- shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); /*Q0*/
- }
- scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); /*hFdCngCom->cngNoiseLevelExp*/
- hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift );
- move16();
-
- /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
- *exp_out = Q15;
- move16();
- IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) )
- {
- IF( NE_16( core, AMR_WB_CORE ) )
- {
- /* Compute additional CN level */
- FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ )
- {
- test();
- test();
- if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) &&
- GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) &&
- LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) )
- {
- BREAK;
- }
- }
-
- scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */
- }
- ELSE
- {
- /* Compute additional CN level */
- FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ )
- {
- if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) )
- {
- BREAK;
- }
- }
-
- IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) )
- {
- scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */
- }
- ELSE
- {
- scale_fx = 0;
- move32();
- }
- }
-
- /* Exclude clean speech */
- scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); // Q30
-
- /* Generate Gaussian random noise in real and imaginary parts of the FFT bins
- Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */
- IF( startBand == 0 )
- {
- rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15
- ptr_r_fx = fftBuffer_fx + 2; /*Q31 - hFdCngCom->fftBuffer_exp*/
- Word16 exp1;
- exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 );
- Word32 mpy1;
- mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); /*Q31 - exp1*/
- mpy1 = L_shl( mpy1, exp1 ); // Q31
- fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15
- ptr_level_fx++;
- }
- ELSE
- {
- fftBuffer_fx[0] = 0;
- move32();
- set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) );
- ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); /*Q31 - hFdCngCom->fftBuffer_exp*/
- }
- ptr_i_fx = ptr_r_fx + 1;
- FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ )
- {
- /* Real part in FFT bins */
- rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15
- Word16 exp2;
- exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 );
- Word32 mpy2;
- mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); /*Q31 - exp2*/
- ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15
- move32();
- ptr_r_fx += 2;
-
- /* Imaginary part in FFT bins */
- rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15
- ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15
- ptr_i_fx += 2;
- }
-
- /* Remaining FFT bins are set to zero */
- set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) );
- /* Nyquist frequency is discarded */
- fftBuffer_fx[1] = 0;
- move32();
- }
- ELSE
- {
- /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */
- generate_masking_noise_update_seed_fx( hFdCngCom );
-
- set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen );
- }
-
- /* Perform STFT synthesis */
- IF( secondary )
- {
- SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
- }
- ELSE
- {
- SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
- }
- *exp_out = sub( *exp_out, Q9 );
- move16();
-
- /* Add some comfort noise on top of decoded signal */
- IF( return_noise )
- {
- Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/
- }
- ELSE
- {
- v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------
- * generate_masking_noise_update_seed()
- *
- * Update seed for scenarios where generate_masking_noise() is
- * not called based on signal statistics
- *-------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------
- * generate_stereo_masking_noise_fx()
- *
- * Generate additional comfort noise (kind of noise filling)
- *-------------------------------------------------------------------*/
-
-void generate_stereo_masking_noise_fx(
- Word16 *syn, /* i/o: time-domain signal Q_syn*/
- Word16 Q_syn,
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/
- const Word16 fadeOut, /* i : only fade out of previous state Q0*/
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
- const Word16 nchan_out /* i : number of output channels Q0*/
-)
-{
- HANDLE_FD_CNG_COM hFdCngCom;
- Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/;
- Word32 Np_fx[L_FRAME16k];
- Word32 Ns_fx[L_FRAME16k];
- Word32 N1_fx[L_FRAME16k];
- Word32 N2_fx[L_FRAME16k];
- Word16 N1_fx_exp, N2_fx_exp;
- Word16 i;
-
- IF( st->idchan == 0 )
- {
- hFdCngCom = st->hFdCngDec->hFdCngCom;
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/
-#else
- Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/
-#endif
- Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/
-
- set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) );
- set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) );
-
- IF( !fadeOut )
- {
-#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/
-#else
- Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/
-#endif
- generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6
- /* Generate masking noise for secondary channel */
- IF( flag_sec_CNA )
- {
- generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6
- gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); /*Q30*/
- scale_fx = ONE_IN_Q30;
- move32();
- IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) )
- {
- Word16 exp_gamma;
- exp_gamma = 0;
- move16();
- Word16 divisor1;
- divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma
- gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30
- Word16 exp_gamma1, exp_gamma2, exp_gamma3;
- exp_gamma1 = Q1;
- exp_gamma2 = Q1;
- exp_gamma3 = Q1;
- move16();
- move16();
- move16();
- gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); /*Q31 - exp_gamma1*/
- Word32 temp;
- temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1
- gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1
- gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30
- Word32 divisor2;
- divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3
- scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30
- }
- ELSE
- {
- gamma_fx = 0;
- move16();
- }
-
- FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ )
- {
- Np_fx[i] = L_add( Np_fx[i],
- Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6
- move32();
- Word32 add2;
- add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6
- if ( hStereoCng->c_PS_LT_fx < 0 )
- {
- add2 = L_negate( add2 ); /*Q6*/
- }
- Ns_fx[i] = L_add( Ns_fx[i], add2 ); /*Q6*/
- move32();
- }
- FOR( ; i < hFdCngCom->frameSize; i++ )
- {
- Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6
- move32();
- Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6
- move32();
- IF( hStereoCng->c_PS_LT_fx < 0 )
- {
- Ns_fx[i] = L_negate( Ns_fx[i] );
- move32();
- }
- }
- /* Below code to be converted */
- Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21
- FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ )
- {
- hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp,
- L_add( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ),
- Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ),
- Q14 ); // Q_olap
- move16();
- hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp,
- L_sub( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ),
- Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ),
- Q14 ); // Q_olap
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ )
- {
- Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6
- move32();
- }
- Copy32( &N1_fx[( hFdCngCom->frameSize / 2 )], &Np_fx[( hFdCngCom->frameSize / 2 )], shr( hFdCngCom->frameSize, 1 ) ); /*Q6*/
- scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21
- FOR( i = 0; i < hFdCngCom->frameSize; i++ )
- {
- hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ), Q6 ); // Q_olap
- move16();
- }
- }
-
- Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); /*st->Q_syn*/
- }
- ELSE
- {
- set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) );
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) );
- }
- IF( flag_sec_CNA )
- {
- Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6
- hStereoCng->enableSecCNA = 1;
- move16();
- }
- ELSE
- {
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize );
- }
-
- /* add masking noise */
- FOR( i = 0; i < hFdCngCom->frameSize; i++ )
- {
- syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn
- move16();
- }
- }
- ELSE IF( hStereoCng->enableSecCNA )
- {
- Word16 SP_ratio_fx;
- SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis Q15*/
- Word16 prevSP_ratio_fx;
- prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis Q15*/
- move16();
- /* scale and add masking noise */
- FOR( i = 0; i < shr( *hStereoCng->frameSize, 2 ); i++ )
- {
- Word16 s;
- Word16 scale_fx_tmp;
- scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15
- scale_fx_tmp = shl( scale_fx_tmp, s );
- syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/
- move16();
- }
- FOR( ; i < *hStereoCng->frameSize / 2; i++ )
- {
- syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/
- move16();
- }
- FOR( ; i < *hStereoCng->frameSize; i++ )
- {
- syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/
- move16();
- }
- hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /*Q15*/
- move16();
- }
-
- return;
-}
-void generate_masking_noise_lb_dirac_fx(
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- Word32 *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA Q11*/
- const Word16 nCldfbTs, /* i : number of CLDFB slots that will be rendered Q0*/
- const Word16 cna_flag /* i : CNA flag for LB and HB Q0*/
-)
-{
- Word16 i;
- Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/
- Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/
- Word32 *ptr_r;
- Word32 *ptr_i;
- Word32 *ptr_level;
- Word16 *seed = &( hFdCngCom->seed );
- Word32 scale;
- Word16 n_samples_out, n_samples_start, n_samples_out_loop;
-
- push_wmops( "fd_cng_dirac" );
-
- /* Init */
- scale = 0;
- move32();
- n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs );
- n_samples_start = 0;
- move16();
- Word16 exp_out = Q11;
- move16();
- /*LB CLDFB - CNA from STFT*/
- IF( cna_flag )
- {
- /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
- IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) )
- {
- /* Compute additional CN level */
- FOR( i = 0; i < 15; i++ )
- {
- test();
- test();
- if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) &&
- GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) &&
- LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) )
- {
- BREAK;
- }
- }
-
- scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */
- scale = Mpy_32_16_1( scale, hFdCngCom->likelihood_noisy_speech ); /* Q30 */
- }
- }
-
- /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/
- test();
- IF( cna_flag && tdBuffer != NULL )
- {
- WHILE( n_samples_out > 0 )
- {
- n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out );
- IF( scale != 0 )
- {
- /*Generate LF comfort noise only at first slot, for the whole frame*/
- ptr_level = cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/
-
- /* Generate Gaussian random noise in real and imaginary parts of the FFT bins
- Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */
- IF( EQ_16( hFdCngCom->startBand, 0 ) )
- {
- rand_gauss_fx( &fftBuffer[0], seed, exp_out );
- ptr_r = fftBuffer + 2; /*hFdCngCom->fftBuffer_exp*/
-
- Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp );
- Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT Q31 - exp2*/
- sqr = L_shl( sqr, exp2 ); /*Q31*/
- fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT Q31 - hFdCngCom->fftBuffer_exp*/
- move32();
- ptr_level++;
- }
- ELSE
- {
- fftBuffer[0] = 0;
- move32();
- set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) );
- ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); /*hFdCngCom->fftBuffer_exp*/
- }
- ptr_i = ptr_r + 1; /*hFdCngCom->fftBuffer_exp*/
-
- FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ )
- {
- rand_gauss_fx( ptr_r, seed, exp_out );
- Word16 exp2 = hFdCngCom->cngNoiseLevelExp;
- Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); /*Q31 - exp2*/
- ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/
- move32();
- ptr_r += 2;
-
- /* Imaginary part in FFT bins */
- rand_gauss_fx( ptr_i, seed, exp_out );
- ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/
- move32();
- ptr_i += 2;
- }
- /* Remaining FFT bins are set to zero */
- set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) );
- /* Nyquist frequency is discarded */
- fftBuffer[1] = 0;
- move32();
-
- /* Perform STFT synthesis */
- SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom );
- scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11
- }
-
- ELSE
- {
- /* very low level case - update random seeds */
- generate_masking_noise_update_seed_fx( hFdCngCom );
-
- set32_fx( fftBuffer, 0, hFdCngCom->fftlen );
- /* Perform STFT synthesis */
- SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom );
- }
- hFdCngCom->fftBuffer_exp = 31 - 11;
- move16();
- n_samples_out = sub( n_samples_out, hFdCngCom->frameSize );
- n_samples_start = add( n_samples_start, hFdCngCom->frameSize );
- }
- }
-
- pop_wmops();
-
- return;
-}
-void generate_masking_noise_dirac_ivas_fx(
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
- Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA q_input*/
- Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer q_cldfb*/
- Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer q_cldfb*/
- const Word16 slot_index, /* i : CLDFB slot index Q0*/
- const Word16 cna_flag, /* i : CNA flag for LB and HB Q0*/
- const Word16 fd_cng_flag, /* i : FD-CNG flag for HB Q0*/
- Word16 q_input,
- Word16 *q_cldfb )
-{
- Word16 i;
- Word32 *ptr_level_fx;
- Word16 *seed = &( hFdCngCom->seed );
- Word32 scale_fx;
- Word16 q_scale, q_shift, q_ptr_level;
-
- push_wmops( "fd_cng_dirac" );
-
- /* Init */
- scale_fx = 0;
- move32();
-
- /* Resample CLDFB memories if necessary*/
- IF( NE_16( i_mult( h_cldfb->no_channels, h_cldfb->no_col ), hFdCngCom->frameSize ) )
- {
- resampleCldfb_ivas_fx( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC );
- }
-
- set32_fx( Cldfb_RealBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX );
-
- /*LB CLDFB - CNA from STFT*/
- IF( cna_flag != 0 )
- {
- /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
- IF( hFdCngCom->likelihood_noisy_speech > 0 )
- {
- /* Compute additional CN level */
- FOR( i = 0; i < 15; i++ )
- {
- test();
- test();
- if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) &&
- ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) &&
- ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) )
- {
- BREAK;
- }
- }
-
- scale_fx = L_shr( L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ), Q3 ); /* Q27 */
- scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech );
- }
- }
- /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/
- IF( cna_flag && tdBuffer_fx != NULL )
- {
- *q_cldfb = q_input;
- move16();
- IF( scale_fx != 0 )
- {
- /* LF CLDFB*/
- cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb );
- }
- ELSE
- {
- /* LB ana CLDFB*/
- cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb );
- }
- }
-
- /*HF CLDFB - CNA and/or FD-CNG*/
- if ( fd_cng_flag )
- {
- scale_fx = L_add( scale_fx, ONE_IN_Q27 ); // 1 in Q27
- }
- IF( scale_fx != 0 )
- {
- q_scale = 27;
- move16();
- q_shift = norm_l( scale_fx );
- scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/
- q_scale = add( q_scale, q_shift );
- scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34
- q_scale = sub( add( q_scale, 2 * Q8 ), 31 );
- ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/
- q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp );
-
- FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ )
- {
- Word32 num;
- Word16 exp, q_num;
- q_shift = norm_l( scale_fx );
- scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/
- q_scale = add( q_scale, q_shift );
- num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/
- q_num = sub( add( q_scale, q_ptr_level ), 31 );
- exp = sub( 31, q_num );
- num = Sqrt32( num, &exp ); /*Q31 - exp*/
- /* Real part in CLDFB band */
- rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb );
- Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp );
- move32();
- /* Imaginary part in CLDFB band */
- rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb );
- Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp );
- move32();
-
- ptr_level_fx++;
- }
- }
-
- pop_wmops();
-
- return;
-}
-
-
-/*-------------------------------------------------------------------
- * FdCngDecodeMDCTStereoSID()
- *
- * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream
- *
- *-------------------------------------------------------------------*/
-
-void FdCngDecodeMDCTStereoSID_fx(
- CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */
-)
-{
- DEC_CORE_HANDLE sts[CPE_CHANNELS];
- HANDLE_FD_CNG_COM hFdCngCom;
- Word32 *ms_ptr_fx[CPE_CHANNELS];
- Word32 *lr_ptr_fx[CPE_CHANNELS];
- Word32 logNoiseEst_fx[CPE_CHANNELS][NPART];
- Word32 gain_fx[CPE_CHANNELS];
- Word16 indices[FD_CNG_stages_37bits];
- Word16 N, i, ch, p, stages;
- Word16 is_out_ms;
- Word32 *invTrfMatrix_fx;
- Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC];
- Word16 shift, exp_diff, max_exp_idx;
- Word16 exp_arr[NPART];
- Word32 tmp32, tmp32_arr[NPART];
-
- invTrfMatrix_fx = (Word32 *) tmpRAM_fx;
- create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31
-
- is_out_ms = 0;
- move16();
- if ( hCPE->hCoreCoder[0]->cng_sba_flag )
- {
- is_out_ms = 1;
- move16();
- }
-
- N = 0; /* to avoid compilation warning */
- move16();
-
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- sts[ch] = hCPE->hCoreCoder[ch];
- ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/
- lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q18*/
- }
-
- /* decode noise shapes and gains */
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- sts[ch] = hCPE->hCoreCoder[ch];
- hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom;
- N = hFdCngCom->npart;
- move16();
- hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /*Q0*/
- move16();
-
- IF( ch )
- {
- stages = FD_CNG_JOINT_stages_25bits;
- move16();
- }
- ELSE
- {
- stages = FD_CNG_stages_37bits;
- move16();
- }
-
- /* read bitstream */
- FOR( i = 0; i < stages; i++ )
- {
- indices[i] = get_next_indice_fx( sts[ch], bits_37bits[i] ); /*Q0*/
- move16();
- }
- {
- gain_fx[ch] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[ch], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20
- move32();
- }
-
- /* MSVQ decoder */
- shift = find_guarded_bits_fx( N );
- msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); // Q20 - shift
-
- Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20
- }
-
- dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) );
-
- IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag )
- {
- set32_fx( ms_ptr_fx[1], 0, NPART );
- }
-
- IF( EQ_16( is_out_ms, 0 ) )
- {
- inverseMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 );
- }
-
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- max_exp_idx = 0;
- move16();
- hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom;
- FOR( p = 0; p < N; p++ )
- {
- tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20
- tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/
- move32();
- if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) )
- {
- max_exp_idx = p; /*Q0*/
- move16();
- }
- }
-
- // Bringing in same exponent
- FOR( p = 0; p < N; p++ )
- {
- lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q31 - exp_arr[max_exp_idx]*/
- move32();
- }
-
- hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx];
- move16();
-
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 );
-
- hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp;
- move16();
-
- lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac );
- }
-
- test();
- IF( EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) )
- {
- /* create proper M noise shape in channel zero after gains have been applied */
- exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp );
- move16();
- FOR( p = 0; p < N; p++ )
- {
- IF( GT_16( exp_diff, 0 ) )
- {
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/
- move32();
- }
- ELSE
- {
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/
- move32();
- }
- }
- IF( LT_16( exp_diff, 0 ) )
- {
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) );
- move16();
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------
- * FdCngDecodeDiracMDCTStereoSID_fx()
- *
- * Decode FD-CNG parameters for CNG in 2TC DirAC mode from the bitstream
- *-------------------------------------------------------------------*/
-
-void FdCngDecodeDiracMDCTStereoSID_fx(
- CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */
-)
-{
- DEC_CORE_HANDLE sts[CPE_CHANNELS];
- HANDLE_FD_CNG_COM hFdCngCom;
- Word32 *ms_ptr_fx[CPE_CHANNELS];
- Word32 *lr_ptr_fx[CPE_CHANNELS];
- Word32 logNoiseEst_fx[CPE_CHANNELS][NPART];
- Word32 gain_fx[CPE_CHANNELS];
- Word16 indices[FD_CNG_stages_37bits];
- Word16 N, i, ch, p;
- Word32 *invTrfMatrix_fx;
- Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC];
- Word16 shift, exp_diff, max_exp_idx;
- Word16 exp_arr[NPART];
- Word32 tmp32, tmp32_arr[NPART];
-
- invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */
- create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31
-
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- sts[ch] = hCPE->hCoreCoder[ch];
- ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/
- lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q20*/
- ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; /*Q18*/
- }
-
- /* decode noise shapes and gains */
- hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom;
- N = hFdCngCom->npart; /*Q0*/
- move16();
-
- /* read bitstream */
- FOR( i = 0; i < FD_CNG_stages_37bits; i++ )
- {
- indices[i] = get_next_indice_fx( sts[0], bits_37bits[i] ); /*Q0*/
- move16();
- }
- gain_fx[0] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[0], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20
- move32();
-
- gain_fx[1] = gain_fx[0]; /*Q20*/
- move32();
-
- /* MSVQ decoder */
- shift = find_guarded_bits_fx( N );
- msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); // Q20 - shift
-
- Scale_sig32( ms_ptr_fx[0], N, shift ); // Q20
-
- Copy32( ms_ptr_fx[0], ms_ptr_fx[1], N ); /*Q20*/
-
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- max_exp_idx = 0;
- move16();
- hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom;
-
- FOR( p = 0; p < N; p++ )
- {
- tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20
- tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/
- move32();
- if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) )
- {
- max_exp_idx = p; /*Q0*/
- move16();
- }
- }
-
- // Bringing in same exponent
- FOR( p = 0; p < N; p++ )
- {
- lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q20*/
- move32();
- }
-
- hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; /*Q0*/
- move16();
-
- /* NB last band energy compensation */
- test();
- IF( hFdCngCom->CngBandwidth == NB )
- {
- lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], NB_LAST_BAND_SCALE_Q31 ); /*Q20*/
- move32();
- }
- ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
- {
- lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); /*Q20*/
- move32();
- }
-
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 );
-
- hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp;
- move16();
-
- lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac );
- }
- sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0;
- move16();
- sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0;
- move16();
-
- IF( EQ_16( hCPE->nchan_out, 1 ) )
- {
- /* create proper M noise shape in channel zero after gains have been applied */
- exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp );
- FOR( p = 0; p < N; p++ )
- {
- IF( exp_diff > 0 )
- {
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/
- move32();
- }
- ELSE
- {
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/
- move32();
- }
- }
- IF( exp_diff < 0 )
- {
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) );
- move16();
- }
- }
-
- return;
-}
diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c
index fa7e602a54da5179a26696905633c5077bfef264..4c42a795997fa4bcc4b1372ce91ec35361e16bb3 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -20,10 +20,18 @@
#endif
-#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */
-#define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */
-#define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */
-#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */
+#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */
+#define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */
+#define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */
+#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */
+#define DELTA_MASKING_NOISE_Q15 0
+#define LOG_10_BASE_2 1783446566 /* Q29 */
+#define GAIN_Q_OFFSET_IVAS_FX 45
+#define LOG_10_BASE_2_BY_10_Q31 713378606
+#define TWO_BY_THREE_Q31 1431655765
+#define ONE_BY_FRAMES_PER_SEC_Q15 656
+#define NB_LAST_BAND_SCALE_Q31 1717986918
+#define SWB_13k2_LAST_BAND_SCALE_Q31 1717986918
/********************************
* External tables *
@@ -179,9 +187,7 @@ void initFdCngDec_ivas_fx(
st->CNG_mode = -1;
move16();
Copy( st->lsp_old_fx, st->lspCNG_fx, M ); /*Q15*/
-#ifdef MSAN_FIX
hFdCngDec->hFdCngCom->sid_frame_counter = 0;
-#endif
return;
}
@@ -271,30 +277,6 @@ void initFdCngDec_fx(
hFdCngDec->smoothed_psd_exp = 0;
move16();
-#ifdef IVAS_CODE_CNG
- set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp, 0.0f, NPART );
-
- set_f( hFdCngDec->smoothed_psd, 0.0f, L_FRAME16k );
- set_f( hFdCngDec->msPeriodog_ST, 0.0f, NPART_SHAPING );
-
- hFdCngDec->ms_last_inactive_bwidth = NB;
- hFdCngDec->ms_cnt_bw_up = 0;
-
- hFdCngDec->cna_LR_LT = 0.5f;
- hFdCngDec->cna_ILD_LT = 0.0f;
- hFdCngDec->first_cna_noise_updated = 0;
- hFdCngDec->first_cna_noise_update_cnt = 0;
- hFdCngDec->cna_nbands = 6;
- mvs2s( cna_init_bands, hFdCngDec->cna_band_limits, MAX_CNA_NBANDS + 1 );
- hFdCngDec->cna_act_fact = 1.0f;
- hFdCngDec->cna_rescale_fact = 0.0f;
- hFdCngDec->cna_seed = 5687;
- set_zero( hFdCngDec->cna_cm, STEREO_DFT_BAND_MAX );
- set_zero( hFdCngDec->cna_g_state, STEREO_DFT_BAND_MAX );
-
- st->CNG_mode = -1;
- mvr2r( st->lsp_old, st->lspCNG, M );
-#endif
return;
}
/*
@@ -1024,12 +1006,6 @@ Word16 ApplyFdCng_fx(
hFdCngCom->psize_inv,
hFdCngDec->partNoiseShape,
&hFdCngDec->partNoiseShape_exp );
-#ifdef IVAS_CODE_CNG
- IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- Copy( hFdCngDec->hFdCngCom->sidNoiseEst, hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
- }
-#endif
}
IF( EQ_16( st->m_frame_type, SID_FRAME ) )
@@ -1046,11 +1022,8 @@ Word16 ApplyFdCng_fx(
{
if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
-#ifdef IVAS_CODE_CNG
- sidNoiseEst = hFdCngCom->sidNoiseEstLp;
- move16();
-#endif
}
+
/* Interpolate the CLDFB band levels from the SID (partition) levels */
IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) )
{
@@ -1128,24 +1101,7 @@ Word16 ApplyFdCng_fx(
move16();
}
}
-#ifdef IVAS_CODE_CNG
- else if ( st->element_mode == IVAS_CPE_DFT )
- {
- if ( !( hFdCngCom->msFrCnt_init_counter < hFdCngCom->msFrCnt_init_thresh ) )
- {
- sidNoiseEst = hFdCngCom->sidNoiseEstLp;
- j = 0;
- for ( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape[k] + DELTA );
- for ( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = hFdCngDec->bandNoiseShape[j] * factor;
- }
- }
- }
- }
-#endif
+
IF( EQ_16( st->codec_mode, MODE2 ) )
{
/* Generate comfort noise during SID or zero frames */
@@ -1362,13 +1318,10 @@ Word16 ApplyFdCng_ivas_fx(
e_shift = sub( s, q_norm );
}
}
- FOR( ; k < hFdCngCom->npart; k++ )
+ FOR( ; j < FFTCLDFBLEN; j++ )
{
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], sub( s, e_shift ) ); /*Q: s*/
- move32();
- }
+ cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], sub( s, e_shift ) ); /*Q: s*/
+ move32();
}
*cngNoiseLevel_exp = add( add( hFdCngDec->bandNoiseShape_exp, s2 ), e_shift );
@@ -1578,7 +1531,15 @@ Word16 ApplyFdCng_ivas_fx(
move16();
/* This sets the new CNG levels until a SID update overwrites it */
Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
+
+ Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
+ Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) );
+ Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) );
+
+ scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), shift ) );
+ scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( sub( *cngNoiseLevel_exp, shift2 ), shift ) );
+
+ *cngNoiseLevel_exp = shift;
move16();
/*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
@@ -1729,14 +1690,13 @@ Word16 ApplyFdCng_ivas_fx(
}
/* adapt scaling for rest of the buffer */
s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; k < hFdCngCom->npart; k++ )
+
+ FOR( ; j < FFTCLDFBLEN; j++ )
{
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- move32();
- }
+ cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
+ move32();
}
+
*cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
move16();
}
@@ -1803,19 +1763,15 @@ Word16 ApplyFdCng_ivas_fx(
}
/* adapt scaling for rest of the buffer */
s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; k < hFdCngCom->npart; k++ )
+
+ FOR( ; j < FFTCLDFBLEN; j++ )
{
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
-#ifdef FIX_ISSUE_1218
- /* NOTE: saturation is added here as part of issue 1218 fix. after rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */
- cngNoiseLevel[j] = L_shl_sat( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
-#else
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
-#endif
- move32();
- }
+ /* NOTE: saturation is added here as part of issue 1218 fix. after rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */
+ cngNoiseLevel[j] = L_shl_sat( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
+ move32();
}
+
+
*cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
move16();
}
@@ -1858,15 +1814,6 @@ void perform_noise_estimation_dec_fx(
float *power_spectrum,
#endif
HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */
-#ifdef IVAS_CODE_CNG
- ,
- const int16_t element_mode, /* i : element mode */
- const int16_t bwidth, /* i : audio bandwidth */
- const int16_t L_frame, /* i : frame length at internal Fs */
- const int16_t last_L_frame, /* i : frame length of the last frame at internal Fs */
- const int32_t last_core_brate, /* i : previous frame core bitrate */
- const int16_t VAD /* i : VAD flag in the decoder */
-#endif
)
{
Word16 i, tmp_r, tmp_i, fac, fftBuffer_exp;
@@ -1875,10 +1822,6 @@ void perform_noise_estimation_dec_fx(
Word16 *part, *psize_inv, *psize_norm;
Word32 tmp, *fftBuffer, *periodog, *ptr_per, *ptr_r, *ptr_i;
-#ifdef IVAS_CODE_CNG
- PMT( "lots of code related to IVAS needs to be done " )
-#endif
-
/* pointer initialization */
periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/
@@ -1911,238 +1854,7 @@ void perform_noise_estimation_dec_fx(
AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom );
#endif
fftBuffer_exp = add( fftBuffer_exp, WORD16_BITS - 1 );
-#ifdef IVAS_CODE_CNG
- if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT )
- {
- /* Calculate periodogram (squared magnitude in each FFT bin) */
- if ( startBand == 0 )
- {
- ( *ptr_per ) = fftBuffer[0] * fftBuffer[0];
- ptr_per++;
- ptr_r = fftBuffer + 2;
- }
- else
- {
- ptr_r = fftBuffer + 2 * startBand;
- }
-
- ptr_i = ptr_r + 1;
-
- for ( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ )
- {
- ( *ptr_per ) = ( *ptr_r ) * ( *ptr_r ) + ( *ptr_i ) * ( *ptr_i );
- ptr_r += 2;
- ptr_i += 2;
- }
-
- /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/
- v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand );
-
- /* Combine bins of power spectrum into partitions */
- i = 0;
- for ( p = 0; p < npart; p++ )
- {
-
- /* calculate mean over all bins in power partition */
- temp = 0;
- for ( ; i <= part[p]; i++ )
- {
- temp += periodog[i];
- }
- msPeriodog[p] = temp * psize_inv[p];
- }
-
- /* compensate for the loss of variance - don't do when first noise update is not completed yet due to risk of msPeriodog[p] < 0 */
- if ( hFdCngDec->first_cna_noise_updated )
- {
- i = 0;
- for ( p = 0; p < npart; p++ )
- {
- /* calculate variance over all bins in power partition */
- temp = 0;
- for ( ; i <= part[p]; i++ )
- {
- delta = periodog[i] - msPeriodog[p];
- temp += delta * delta;
- }
- temp *= psize_inv[p];
-
- /* compensate for the loss of variance */
- msPeriodog[p] = (float) ( msPeriodog[p] + sqrt( temp ) * rand_gauss( &ftemp, &hFdCngDec->cna_seed ) );
-
- if ( msPeriodog[p] < 1e-5f )
- {
- msPeriodog[p] = 1e-5f;
- }
- }
- }
-
- /* calculate total energy (short-term and long-term) */
- enr_tot = sum_f( msPeriodog, npart ) + EPSILON;
- enr_tot0 = sum_f( msNoiseEst, npart ) + EPSILON;
-
- /* update short-term periodogram on larger partitions */
- for ( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ )
- {
- if ( L_frame != last_L_frame || last_core_brate <= SID_2k40 )
- {
- /* core Fs has changed or last frame was SID/NO_DATA -> re-initialize short-term periodogram */
- hFdCngDec->msPeriodog_ST[p] = msPeriodog[p];
- }
- else
- {
- hFdCngDec->msPeriodog_ST[p] = (float) ( ST_PERIODOG_FACT * hFdCngDec->msPeriodog_ST[p] + ( 1 - ST_PERIODOG_FACT ) * msPeriodog[p] );
- }
- }
-
- /* core Fs has changed -> partitions have changed -> re-calculate long-term periodogram */
- /* part L_FRAME16k L_FRAME */
- /* ... */
- /* [55] 146 146 */
- /* [56] 174 160 */
- /* [57] 210 174 */
- /* [58] 254 190 */
- /* [59] 306 210 */
- /* [60] 317 230 */
- /* [61] 253 */
-
- if ( last_L_frame == L_FRAME16k && L_frame == L_FRAME )
- {
- msNoiseEst[61] = msNoiseEst[58];
- msNoiseEst[60] = min( msNoiseEst[58], msNoiseEst[57] );
- msNoiseEst[59] = msNoiseEst[57];
- msNoiseEst[58] = msNoiseEst[56];
- msNoiseEst[57] = msNoiseEst[56];
- msNoiseEst[56] = min( msNoiseEst[56], msNoiseEst[55] );
- }
- else if ( last_L_frame == L_FRAME && L_frame == L_FRAME16k )
- {
- msNoiseEst[56] = min( msNoiseEst[56], msNoiseEst[57] );
- msNoiseEst[57] = min( msNoiseEst[58], msNoiseEst[59] );
- msNoiseEst[58] = min( msNoiseEst[60], msNoiseEst[61] );
- msNoiseEst[59] = 0.0f;
- msNoiseEst[60] = 0.0f;
- msNoiseEst[61] = 0.0f;
-
- hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES;
- }
-
- /* Smooth with IIR filter */
- if ( !hFdCngDec->first_cna_noise_updated )
- {
- if ( !VAD )
- {
- /* background noise update with moving average */
- alpha = 1.0f / ( hFdCngDec->first_cna_noise_update_cnt + 1 );
- for ( p = 0; p < npart; p++ )
- {
- msNoiseEst[p] = ( 1 - alpha ) * msNoiseEst[p] + alpha * msPeriodog[p];
- }
-
- /* check, if we reached the required number of first CNA noise update frames */
- if ( hFdCngDec->first_cna_noise_update_cnt < FIRST_CNA_NOISE_UPD_FRAMES - 1 )
- {
- hFdCngDec->first_cna_noise_update_cnt++;
- }
- else
- {
- hFdCngDec->first_cna_noise_updated = 1;
- if ( hFdCngDec->hFdCngCom->msFrCnt_init_counter == 0 )
- {
- hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1;
- }
- }
- }
- else
- {
- hFdCngDec->first_cna_noise_update_cnt = 0;
- }
- }
- else
- {
- hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1;
- if ( VAD )
- {
- /* no updates during active frames except for significant energy drops */
- enr_ratio = enr_tot / enr_tot0;
- if ( enr_ratio < 0.5f )
- {
- /* total energy significantly decreases during active frames -> downward update */
- wght = lin_interp( enr_ratio, 0.0f, 0.8f, 0.5f, 0.95f, 1 );
- for ( p = 0; p < npart; p++ )
- {
- if ( msPeriodog[p] < msNoiseEst[p] )
- {
- msNoiseEst[p] = wght * msNoiseEst[p] + ( 1 - wght ) * msPeriodog[p];
- }
- }
- }
- else
- {
- /* energy significantly decreases in one of the larger partitions during active frames -> downward update */
- for ( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ )
- {
- if ( hFdCngDec->msPeriodog_ST[p] < msNoiseEst[p] )
- {
- msNoiseEst[p] = (float) ( CNA_ACT_DN_FACT * msNoiseEst[p] + ( 1 - CNA_ACT_DN_FACT ) * hFdCngDec->msPeriodog_ST[p] );
- }
- }
- }
- }
- else
- {
-
- if ( bwidth >= WB && hFdCngDec->ms_last_inactive_bwidth == NB )
- {
- /* bandwidth increased -> set counter for fast initilization */
- hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES;
- }
- hFdCngDec->ms_last_inactive_bwidth = bwidth;
- /* update background noise during inactive frames */
- ptr_per = msNoiseEst;
- for ( p = 0; p < npart; p++ )
- {
- enr = msPeriodog[p];
- alpha = 0.95f;
- /* bandwidth increased -> do fast re-initilization */
- if ( hFdCngDec->ms_cnt_bw_up > 0 && p > 55 )
- {
- alpha = 1.0f / ( hFdCngDec->ms_cnt_bw_up + 1 );
- }
- else if ( enr < *ptr_per && part[p] == 1 )
- {
- /* faster downward update for single-bin partitions */
- alpha = 0.8f;
- }
- else if ( enr > 2.0f * ( *ptr_per ) )
- {
- /* prevent abrupt upward updates */
- enr = 2.0f * ( *ptr_per );
- }
-
- /* IIR smoothing */
- *ptr_per *= alpha;
- *ptr_per += ( 1 - alpha ) * enr;
- ptr_per++;
- }
-
- if ( hFdCngDec->ms_cnt_bw_up > 0 )
- {
- hFdCngDec->ms_cnt_bw_up--;
- }
- }
- }
-
- mvr2r( msNoiseEst, hFdCngDec->msPsd, npart );
-
- /* Expand partitions into bins of power spectrum */
- scalebands( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, stopFFTbin - startBand, hFdCngDec->bandNoiseShape, 1 );
- mvr2r( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd[startBand], stopFFTbin - startBand );
- set_zero( &hFdCngDec->smoothed_psd[stopFFTbin], L_FRAME16k - stopFFTbin );
- }
- else
-#endif
{
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
if ( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL )
@@ -2294,12 +2006,7 @@ void perform_noise_estimation_dec_fx(
hFdCngDec->msNewMinFlag,
hFdCngDec->msPeriodogBuf,
&( hFdCngDec->msPeriodogBufPtr ),
- hFdCngDec->hFdCngCom
-#ifdef IVAS_CODE_CNG
- ,
- DEC, element_mode
-#endif
- );
+ hFdCngDec->hFdCngCom );
/* Expand MS outputs */
expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart );
@@ -2339,10 +2046,6 @@ void perform_noise_estimation_dec_ivas_fx(
Word16 q_shift;
Word32 max_l;
Word16 norm_shift;
-#ifdef IVAS_CODE_CNG
- PMT( "lots of code related to IVAS needs to be done " )
-#endif
-
/* pointer initialization */
periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/
@@ -3621,9 +3324,9 @@ void generate_comfort_noise_dec_fx(
IF( st->hTcxCfg->last_aldo != 0 )
{
- FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ )
+ FOR( i = 0; i < hFdCngCom->frameSize - NS2SA( st->sr_core, N_ZERO_MDCT_NS ); i++ )
{
- timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/
+ timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/
move16();
}
}
@@ -4160,9 +3863,9 @@ void generate_comfort_noise_dec_ivas_fx(
IF( st->hTcxCfg->last_aldo != 0 )
{
- FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ )
+ FOR( i = 0; i < hFdCngCom->frameSize - NS2SA( st->sr_core, N_ZERO_MDCT_NS ); i++ )
{
- timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/
+ timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/
move16();
}
}
@@ -5025,318 +4728,968 @@ void generate_masking_noise_mdct_ivas_fx(
return;
}
-#ifdef IVAS_CODE_CNG
/*-------------------------------------------------------------------
- * generate_stereo_masking_noise()
+ * initFdCngDec()
*
- * Generate additional comfort noise (kind of noise filling)
+ * Initialize an instance of type FD_CNG
*-------------------------------------------------------------------*/
-
-void generate_stereo_masking_noise(
- float *syn, /* i/o: time-domain signal */
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t fadeOut, /* i : only fade out of previous state */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
- const int16_t nchan_out /* i : number of output channels */
-)
+void configureFdCngDec_ivas_fx(
+ HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
+ const Word16 bwidth, /*Q0*/
+ const Word32 total_brate, /*Q0*/
+ const Word16 L_frame, /*Q0*/
+ const Word16 last_L_frame, /*Q0*/
+ const Word16 element_mode /*Q0*/ )
{
- HANDLE_FD_CNG_COM hFdCngCom;
- float gamma, scale, SP_ratio;
- float Np[L_FRAME16k];
- float Ns[L_FRAME16k];
- float N1[L_FRAME16k];
- float N2[L_FRAME16k];
- int16_t i;
-
- if ( st->idchan == 0 )
- {
- hFdCngCom = st->hFdCngDec->hFdCngCom;
- mvr2r( hFdCngCom->olapBufferSynth2, Np, hFdCngCom->frameSize / 2 );
- mvr2r( hStereoCng->olapBufferSynth22, Ns, hFdCngCom->frameSize / 2 );
- set_f( &Np[hFdCngCom->frameSize / 2], 0.0f, hFdCngCom->frameSize / 2 );
- set_f( &Ns[hFdCngCom->frameSize / 2], 0.0f, hFdCngCom->frameSize / 2 );
+ Word16 j, stopBandFR;
+ HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom;
- if ( !fadeOut )
+ hsCom->CngBandwidth = bwidth; /*Q0*/
+ move16();
+ if ( EQ_16( hsCom->CngBandwidth, FB ) )
+ {
+ hsCom->CngBandwidth = SWB;
+ move16();
+ }
+ test();
+ IF( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) )
+ {
+ hsCom->CngBitrate = total_brate; /*Q0*/
+ move32();
+ }
+ ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) )
+ {
+ /* set minimum active CBR bitrate IF CngBitrate is uninitialized */
+ IF( element_mode > EVS_MONO )
{
- generate_masking_noise_fx( N1, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out );
- /* Generate masking noise for secondary channel */
- if ( flag_sec_CNA )
- {
- generate_masking_noise_fx( N2, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out );
- gamma = hStereoCng->c_PS_LT * hStereoCng->c_PS_LT;
- scale = 1.0f;
- if ( gamma < 0.9f )
- {
- gamma = gamma / ( 1 - gamma );
- gamma = (float) sqrt( gamma + 1 ) - (float) sqrt( gamma );
- scale = 1.0f / (float) sqrt( 1 + gamma * gamma );
- }
- else
- {
- gamma = 0.0f;
- }
-
- for ( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ )
- {
- Np[i] += scale * ( N1[i] + gamma * N2[i] );
- Ns[i] += scale * sign( hStereoCng->c_PS_LT ) * ( N1[i] - gamma * N2[i] );
- }
- for ( ; i < hFdCngCom->frameSize; i++ )
- {
- Np[i] = scale * ( N1[i] + gamma * N2[i] );
- Ns[i] = scale * sign( hStereoCng->c_PS_LT ) * ( N1[i] - gamma * N2[i] );
- }
- scale *= (float) ( hFdCngCom->fftlen / 2 );
- for ( i = 0; i < hFdCngCom->frameSize / 2; i++ )
- {
- hFdCngCom->olapBufferSynth2[i] = scale * ( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] + gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] );
- hStereoCng->olapBufferSynth22[i] = sign( hStereoCng->c_PS_LT ) * scale * ( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] - gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] );
+ hsCom->CngBitrate = IVAS_13k2;
+ move32();
+ }
+ ELSE
+ {
+ hsCom->CngBitrate = ACELP_7k20;
+ move32();
+ }
+ }
+
+ /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */
+ /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */
+ if ( EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ hsCom->CngBitrate = IVAS_48k;
+ move32();
+ }
+ hsCom->numSlots = 16;
+ move32();
+
+ /* NB configuration */
+ IF( EQ_16( bwidth, NB ) )
+ {
+ hsCom->FdCngSetup = FdCngSetup_nb;
+ hsCom->numCoreBands = 16;
+ move16();
+ hsCom->regularStopBand = 16;
+ move16();
+ }
+
+ /* WB configuration */
+ ELSE IF( EQ_16( bwidth, WB ) )
+ {
+ /* FFT 6.4kHz, no CLDFB */
+ test();
+ test();
+ IF( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) )
+ {
+ hsCom->FdCngSetup = FdCngSetup_wb1;
+ hsCom->numCoreBands = 16;
+ move16();
+ hsCom->regularStopBand = 16;
+ move16();
+ }
+ /* FFT 6.4kHz, CLDFB 8.0kHz */
+ ELSE IF( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) )
+ {
+ hsCom->FdCngSetup = FdCngSetup_wb2;
+ hsCom->numCoreBands = 16;
+ move16();
+ hsCom->regularStopBand = 20;
+ move16();
+ IF( EQ_16( L_frame, L_FRAME16k ) )
+ {
+ hsCom->FdCngSetup = FdCngSetup_wb2;
+ hsCom->numCoreBands = 20;
+ move16();
+ hsCom->regularStopBand = 20;
+ move16();
+ hsCom->FdCngSetup.fftlen = 640;
+ move16();
+ hsCom->FdCngSetup.stopFFTbin = 256;
+ move16();
+ }
+ }
+ /* FFT 8.0kHz, no CLDFB */
+ ELSE
+ {
+ hsCom->FdCngSetup = FdCngSetup_wb3;
+ hsCom->numCoreBands = 20;
+ move16();
+ hsCom->regularStopBand = 20;
+ move16();
+ }
+ }
+
+ /* SWB/FB configuration */
+ ELSE
+ {
+ /* FFT 6.4kHz, CLDFB 14kHz */
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ hsCom->FdCngSetup = FdCngSetup_swb1;
+ hsCom->numCoreBands = 16;
+ move16();
+ hsCom->regularStopBand = 35;
+ move16();
+ }
+ /* FFT 8.0kHz, CLDFB 16kHz */
+ ELSE
+ {
+ hsCom->FdCngSetup = FdCngSetup_swb2;
+ hsCom->numCoreBands = 20;
+ move16();
+ hsCom->regularStopBand = 40;
+ move16();
+ test();
+ if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) )
+ {
+ hsCom->regularStopBand = 35;
+ move16();
+ }
+ }
+ }
+
+
+ hsCom->fftlen = hsCom->FdCngSetup.fftlen;
+ move16();
+ hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin;
+ move16();
+
+ /* Configure the SID quantizer and the Comfort Noise Generator */
+
+ hsCom->startBand = 2;
+ move16();
+ hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/
+ initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 );
+
+ IF( EQ_16( hsCom->stopFFTbin, 160 ) )
+ {
+ hsCom->nFFTpart = 17;
+ move16();
+ }
+ ELSE IF( EQ_16( hsCom->stopFFTbin, 256 ) )
+ {
+ hsCom->nFFTpart = 20;
+ move16();
+ }
+ ELSE
+ {
+ hsCom->nFFTpart = 21;
+ move16();
+ }
+ hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /*Q0*/
+ move16();
+ FOR( j = 0; j < hsCom->nCLDFBpart; j++ )
+ {
+ hsCom->CLDFBpart[j] = sub( hsCom->part[( j + hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); /*Q0*/
+ move16();
+ hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )];
+ move16();
+ }
+
+ stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/);
+ move16();
+ if ( GT_16( stopBandFR, hsCom->stopFFTbin ) )
+ {
+ stopBandFR = hsCom->stopFFTbin; /*Q0*/
+ move16();
+ }
+
+ initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR );
+
+ hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/
+ move16();
+
+ BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) );
+ BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) );
+
+ SWITCH( hsCom->fftlen )
+ {
+ case 512:
+ hsCom->olapWinAna_fx = olapWinAna512_fx; /*Q30*/
+ hsCom->fftSineTab_fx = NULL;
+ hsCom->olapWinSyn_fx = olapWinSyn256_fx; /*Q15*/
+ hsCom->fftlenShift = 8;
+ move16();
+ hsCom->fftlenFac = 32767 /*1.0 Q15*/;
+ move16();
+ BREAK;
+ case 640:
+ hsCom->olapWinAna_fx = olapWinAna640_fx; /*Q30*/
+ hsCom->fftSineTab_fx = fftSineTab640_fx; /*Q15*/
+ hsCom->olapWinSyn_fx = olapWinSyn320_fx; /*Q15*/
+ hsCom->fftlenShift = 9;
+ move16();
+ hsCom->fftlenFac = 20480 /*0.625 Q15*/;
+ move16();
+ BREAK;
+ default:
+ assert( !"Unsupported FFT length for FD-based CNG" );
+ BREAK;
+ }
+ BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) );
+ BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) );
+ hsCom->frameSize = shr( hsCom->fftlen, 1 );
+
+ return;
+}
+
+/*-------------------------------------------------------------------
+ * FdCng_decodeSID_ivas_fx()
+ *
+ * Decode the FD-CNG bitstream
+ *-------------------------------------------------------------------*/
+
+void FdCng_decodeSID_ivas_fx(
+ Decoder_State *st /* i/o: decoder state structure */
+)
+{
+ Word16 N;
+ Word32 *sidNoiseEst;
+ Word32 gain;
+ Word16 i, index;
+ Word32 v[32];
+ Word16 indices[32];
+ HANDLE_FD_CNG_COM hFdCngCom;
+ Word32 *invTrfMatrix_fx;
+ Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC];
+ Word16 tmp16;
+
+ IF( st->element_mode == EVS_MONO )
+ {
+ tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0;
+ move16();
+ }
+ ELSE
+ {
+ tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0;
+ move16();
+ }
+
+ const Word16 gain_q_offset = tmp16; /* Q0 */
+ move16();
+
+ invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/
+
+ hFdCngCom = ( st->hFdCngDec )->hFdCngCom;
+
+ sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q16*/
+
+ N = hFdCngCom->npart; /*Q0*/
+ move16();
+ gain = 0;
+ move32();
+ hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 );
+ move16();
+
+ /* Read bitstream */
+ FOR( i = 0; i < FD_CNG_stages_37bits; i++ )
+ {
+ indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/
+ move16();
+ }
+
+ index = get_next_indice_fx( st, 7 );
+
+ /* MSVQ decoder */
+
+ IF( st->element_mode != EVS_MONO )
+ {
+ create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC );
+ msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 );
+ }
+ ELSE
+ { /* Legacy EVS_MONO MSVQ tables */
+ msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 );
+ }
+
+
+ /* Decode gain */
+ // gain = ((float)index - gain_q_offset) / 1.5f;
+ gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15
+
+ /* Apply gain and undo log */
+ Word16 res_exp[NPART];
+ Word16 max_res_exp = 0;
+ move16();
+ FOR( i = 0; i < N; i++ )
+ {
+ sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/
+ move32();
+ if ( LT_16( max_res_exp, res_exp[i] ) )
+ {
+ max_res_exp = res_exp[i];
+ move16();
+ }
+ }
+
+ FOR( i = 0; i < N; i++ )
+ {
+ sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); /*Q31 - max_res_exp*/
+ move32();
+ }
+
+ hFdCngCom->sidNoiseEstExp = max_res_exp;
+ move16();
+
+ /* NB last band energy compensation */
+
+ IF( hFdCngCom->CngBandwidth == NB )
+ {
+ sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/
+ move32();
+ }
+
+ test();
+ IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
+ {
+ sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/
+ move32();
+ }
+
+ scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 );
+ Word16 shift1 = L_norm_arr( hFdCngCom->cngNoiseLevel, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) );
+ Word16 shift2 = L_norm_arr( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ) );
+ Word16 shift = s_max( sub( hFdCngCom->sidNoiseEstExp, shift1 ), sub( hFdCngCom->cngNoiseLevelExp, shift2 ) );
+
+ scale_sig32( hFdCngCom->cngNoiseLevel, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( sub( hFdCngCom->sidNoiseEstExp, shift1 ), shift ) );
+ scale_sig32( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ), sub( sub( hFdCngCom->cngNoiseLevelExp, shift2 ), shift ) );
+
+ hFdCngCom->cngNoiseLevelExp = shift;
+ move16();
+
+ lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac );
+
+ return;
+}
+
+/*-------------------------------------------------------------------
+ * generate_masking_noise_ivas_fx()
+ *
+ * Generate additional comfort noise (kind of noise filling)
+ *-------------------------------------------------------------------*/
+
+void generate_masking_noise_ivas_fx(
+ Word32 *timeDomainBuffer, /* i/o: time-domain signal Q31 - *exp_out*/
+ Word16 *exp_out, /* o : time-domain signal exp */
+ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
+ const Word16 length, /* i : frame size Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 return_noise, /* i : noise is returned instead of added Q0*/
+ const Word16 secondary, /* i : flag to indicate secondary noise generation Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
+ const Word16 nchan_out /* i : number of output channels Q0*/
+)
+{
+ Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel;
+ Word32 *ptr_level_fx = cngNoiseLevel_fx;
+ Word32 *fftBuffer_fx = hFdCngCom->fftBuffer;
+ Word16 i;
+ Word32 maskingNoise_fx[L_FRAME16k];
+ Word32 *ptr_r_fx;
+ Word32 *ptr_i_fx;
+ Word16 startBand;
+ Word16 *seed = &( hFdCngCom->seed );
+ Word32 scale_fx;
+ Word16 shift;
+ scale_fx = 0x40000000; // 1.0 in Q30
+ move32();
+ startBand = hFdCngCom->startBand; /*Q0*/
+ move16();
+ shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); /*Q0*/
+ }
+ scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); /*hFdCngCom->cngNoiseLevelExp*/
+ hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift );
+ move16();
+
+ /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
+ *exp_out = Q15;
+ move16();
+ IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) )
+ {
+ IF( NE_16( core, AMR_WB_CORE ) )
+ {
+ /* Compute additional CN level */
+ FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ )
+ {
+ test();
+ test();
+ if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) &&
+ GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) &&
+ LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) )
+ {
+ BREAK;
+ }
+ }
+
+ scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */
+ }
+ ELSE
+ {
+ /* Compute additional CN level */
+ FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ )
+ {
+ if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) )
+ {
+ BREAK;
+ }
+ }
+
+ IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) )
+ {
+ scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */
+ }
+ ELSE
+ {
+ scale_fx = 0;
+ move32();
+ }
+ }
+
+ /* Exclude clean speech */
+ scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); // Q30
+
+ /* Generate Gaussian random noise in real and imaginary parts of the FFT bins
+ Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */
+ IF( startBand == 0 )
+ {
+ rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15
+ ptr_r_fx = fftBuffer_fx + 2; /*Q31 - hFdCngCom->fftBuffer_exp*/
+ Word16 exp1;
+ exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 );
+ Word32 mpy1;
+ mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); /*Q31 - exp1*/
+ mpy1 = L_shl( mpy1, exp1 ); // Q31
+ fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15
+ ptr_level_fx++;
+ }
+ ELSE
+ {
+ fftBuffer_fx[0] = 0;
+ move32();
+ set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) );
+ ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); /*Q31 - hFdCngCom->fftBuffer_exp*/
+ }
+ ptr_i_fx = ptr_r_fx + 1;
+ FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ )
+ {
+ /* Real part in FFT bins */
+ rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15
+ Word16 exp2;
+ exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 );
+ Word32 mpy2;
+ mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); /*Q31 - exp2*/
+ ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15
+ move32();
+ ptr_r_fx += 2;
+
+ /* Imaginary part in FFT bins */
+ rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15
+ ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15
+ ptr_i_fx += 2;
+ }
+
+ /* Remaining FFT bins are set to zero */
+ set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) );
+ /* Nyquist frequency is discarded */
+ fftBuffer_fx[1] = 0;
+ move32();
+ }
+ ELSE
+ {
+ /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */
+ generate_masking_noise_update_seed_fx( hFdCngCom );
+
+ set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen );
+ }
+
+ /* Perform STFT synthesis */
+ IF( secondary )
+ {
+ SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
+ }
+ ELSE
+ {
+ SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
+ }
+ *exp_out = sub( *exp_out, Q9 );
+ move16();
+
+ /* Add some comfort noise on top of decoded signal */
+ IF( return_noise )
+ {
+ Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/
+ }
+ ELSE
+ {
+ v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------
+ * generate_stereo_masking_noise_fx()
+ *
+ * Generate additional comfort noise (kind of noise filling)
+ *-------------------------------------------------------------------*/
+
+void generate_stereo_masking_noise_fx(
+ Word16 *syn, /* i/o: time-domain signal Q_syn*/
+ Word16 Q_syn,
+ Decoder_State *st, /* i/o: decoder state structure */
+ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
+ const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/
+ const Word16 fadeOut, /* i : only fade out of previous state Q0*/
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
+ const Word16 nchan_out /* i : number of output channels Q0*/
+)
+{
+ HANDLE_FD_CNG_COM hFdCngCom;
+ Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/;
+ Word32 Np_fx[L_FRAME16k];
+ Word32 Ns_fx[L_FRAME16k];
+ Word32 N1_fx[L_FRAME16k];
+ Word32 N2_fx[L_FRAME16k];
+ Word16 N1_fx_exp, N2_fx_exp;
+ Word16 i;
+
+ IF( st->idchan == 0 )
+ {
+ hFdCngCom = st->hFdCngDec->hFdCngCom;
+ Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/
+ Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/
+
+ set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) );
+ set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) );
+
+ IF( !fadeOut )
+ {
+ Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/
+ generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6
+ /* Generate masking noise for secondary channel */
+ IF( flag_sec_CNA )
+ {
+ generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6
+ gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); /*Q30*/
+ scale_fx = ONE_IN_Q30;
+ move32();
+ IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) )
+ {
+ Word16 exp_gamma;
+ exp_gamma = 0;
+ move16();
+ Word16 divisor1;
+ divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma
+ gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30
+ Word16 exp_gamma1, exp_gamma2, exp_gamma3;
+ exp_gamma1 = Q1;
+ exp_gamma2 = Q1;
+ exp_gamma3 = Q1;
+ move16();
+ move16();
+ move16();
+ gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); /*Q31 - exp_gamma1*/
+ Word32 temp;
+ temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1
+ gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1
+ gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30
+ Word32 divisor2;
+ divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3
+ scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30
+ }
+ ELSE
+ {
+ gamma_fx = 0;
+ move16();
+ }
+
+ FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ )
+ {
+ Np_fx[i] = L_add( Np_fx[i],
+ Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6
+ move32();
+ Word32 add2;
+ add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6
+ if ( hStereoCng->c_PS_LT_fx < 0 )
+ {
+ add2 = L_negate( add2 ); /*Q6*/
+ }
+ Ns_fx[i] = L_add( Ns_fx[i], add2 ); /*Q6*/
+ move32();
+ }
+ FOR( ; i < hFdCngCom->frameSize; i++ )
+ {
+ Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6
+ move32();
+ Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6
+ move32();
+ IF( hStereoCng->c_PS_LT_fx < 0 )
+ {
+ Ns_fx[i] = L_negate( Ns_fx[i] );
+ move32();
+ }
+ }
+ /* Below code to be converted */
+ Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21
+ FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ )
+ {
+ hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp,
+ L_add( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ),
+ Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ),
+ Q14 ); // Q_olap
+ move16();
+ hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp,
+ L_sub( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ),
+ Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ),
+ Q14 ); // Q_olap
+ move16();
}
}
- else
+ ELSE
{
- for ( i = 0; i < hFdCngCom->frameSize / 2; i++ )
+ FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ )
{
- Np[i] += N1[i];
+ Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6
+ move32();
}
- mvr2r( &N1[hFdCngCom->frameSize / 2], &Np[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2 );
- scale = (float) ( hFdCngCom->fftlen / 2 );
- for ( i = 0; i < hFdCngCom->frameSize; i++ )
+ Copy32( &N1_fx[( hFdCngCom->frameSize / 2 )], &Np_fx[( hFdCngCom->frameSize / 2 )], shr( hFdCngCom->frameSize, 1 ) ); /*Q6*/
+ scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21
+ FOR( i = 0; i < hFdCngCom->frameSize; i++ )
{
- hFdCngCom->olapBufferSynth2[i] = scale * hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4];
+ hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ), Q6 ); // Q_olap
+ move16();
}
}
+
+ Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); /*st->Q_syn*/
}
- else
+ ELSE
{
- set_f( hFdCngCom->olapBufferSynth2, 0.0f, hFdCngCom->frameSize / 2 );
- set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize / 2 );
+ set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) );
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) );
}
- if ( flag_sec_CNA )
+ IF( flag_sec_CNA )
{
- mvr2r( Ns, hStereoCng->maskingNoiseS, hFdCngCom->frameSize );
+ Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6
hStereoCng->enableSecCNA = 1;
+ move16();
}
- else
+ ELSE
{
- set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize );
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize );
}
/* add masking noise */
- v_add( Np, syn, syn, hFdCngCom->frameSize );
+ FOR( i = 0; i < hFdCngCom->frameSize; i++ )
+ {
+ syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn
+ move16();
+ }
}
- else if ( hStereoCng->enableSecCNA )
+ ELSE IF( hStereoCng->enableSecCNA )
{
- SP_ratio = hStereoTD->SP_ratio_LT; /* Use long-term SP ratio based on L/R synthesis */
+ Word16 SP_ratio_fx;
+ SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis Q15*/
+ Word16 prevSP_ratio_fx;
+ prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis Q15*/
+ move16();
/* scale and add masking noise */
- for ( i = 0; i < *hStereoCng->frameSize / 4; i++ )
+ FOR( i = 0; i < shr( *hStereoCng->frameSize, 2 ); i++ )
{
- scale = ( ( hStereoTD->prevSP_ratio * ( *hStereoCng->frameSize / 4 - (float) i ) + SP_ratio * (float) i ) / ( *hStereoCng->frameSize / 4 ) );
- syn[i] += scale * hStereoCng->maskingNoiseS[i];
+ Word16 s;
+ Word16 scale_fx_tmp;
+ scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15
+ scale_fx_tmp = shl( scale_fx_tmp, s );
+ syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/
+ move16();
}
- for ( ; i < *hStereoCng->frameSize / 2; i++ )
+ FOR( ; i < *hStereoCng->frameSize / 2; i++ )
{
- syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i];
+ syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/
+ move16();
}
- for ( ; i < *hStereoCng->frameSize; i++ )
+ FOR( ; i < *hStereoCng->frameSize; i++ )
{
- syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i];
+ syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/
+ move16();
}
- hStereoTD->prevSP_ratio = SP_ratio;
+ hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /*Q15*/
+ move16();
}
return;
}
-
-/*-------------------------------------------------------------------
- * generate_masking_noise_hf_cldfb()
- *
- * Generate additional comfort noise (kind of noise filling)
- *-------------------------------------------------------------------*/
-
-void generate_masking_noise_dirac(
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
- float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */
- float *Cldfb_RealBuffer, /* o : CLDFD real buffer */
- float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */
- const int16_t slot_index, /* i : CLDFB slot index */
- const int16_t cna_flag, /* i : CNA flag for LB and HB */
- const int16_t fd_cng_flag /* i : FD-CNG flag for HB */
+void generate_masking_noise_lb_dirac_fx(
+ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
+ Word32 *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA Q11*/
+ const Word16 nCldfbTs, /* i : number of CLDFB slots that will be rendered Q0*/
+ const Word16 cna_flag /* i : CNA flag for LB and HB Q0*/
)
{
- int16_t i;
- float *cngNoiseLevel = hFdCngCom->cngNoiseLevel;
- float *fftBuffer = hFdCngCom->fftBuffer;
- float *ptr_r;
- float *ptr_i;
- float *ptr_level;
- int16_t *seed = &( hFdCngCom->seed );
- float scale;
+ Word16 i;
+ Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/
+ Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/
+ Word32 *ptr_r;
+ Word32 *ptr_i;
+ Word32 *ptr_level;
+ Word16 *seed = &( hFdCngCom->seed );
+ Word32 scale;
+ Word16 n_samples_out, n_samples_start, n_samples_out_loop;
- wmops_sub_start( "fd_cng_dirac" );
+ push_wmops( "fd_cng_dirac" );
/* Init */
- scale = 0.f;
-
- /* Resample CLDFB memories if necessary*/
- if ( ( h_cldfb->no_channels * h_cldfb->no_col ) != hFdCngCom->frameSize )
- {
- resampleCldfb( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC );
- }
-
- set_zero( Cldfb_RealBuffer, CLDFB_NO_CHANNELS_MAX );
- set_zero( Cldfb_ImagBuffer, CLDFB_NO_CHANNELS_MAX );
-
+ scale = 0;
+ move32();
+ n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs );
+ n_samples_start = 0;
+ move16();
+ Word16 exp_out = Q11;
+ move16();
/*LB CLDFB - CNA from STFT*/
-#ifdef DEBUG_MODE_DIRAC
- {
- int16_t tmp_s;
- tmp_s = (int16_t) ( 32768.f * 0.5f * hFdCngCom->likelihood_noisy_speech * cna_flag + 0.5f );
- dbgwrite( &tmp_s, sizeof( int16_t ), 1, hFdCngCom->frameSize / 16, "./res/ivas_dirac_likelihood_noisy.pcm" );
- }
-#endif
- if ( cna_flag )
+ IF( cna_flag )
{
/* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
- if ( hFdCngCom->likelihood_noisy_speech > DELTA_MASKING_NOISE )
+ IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) )
{
/* Compute additional CN level */
- for ( i = 0; i < 15; i++ )
+ FOR( i = 0; i < 15; i++ )
{
- if ( ( hFdCngCom->CngBandwidth == scaleTable_cn_dirac[i].bwmode ) &&
- ( hFdCngCom->CngBitrate >= scaleTable_cn_dirac[i].bitrateFrom ) &&
- ( hFdCngCom->CngBitrate < scaleTable_cn_dirac[i].bitrateTo ) )
+ test();
+ test();
+ if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) &&
+ GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) &&
+ LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) )
{
- break;
+ BREAK;
}
}
- scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale / 10.f ) - 1.f;
- scale *= hFdCngCom->likelihood_noisy_speech;
+ scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */
+ scale = Mpy_32_16_1( scale, hFdCngCom->likelihood_noisy_speech ); /* Q30 */
}
}
/* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/
- if ( cna_flag && tdBuffer != NULL )
+ test();
+ IF( cna_flag && tdBuffer != NULL )
{
- if ( scale != 0 )
+ WHILE( n_samples_out > 0 )
{
- /*Generate LF comfort noise only at first slot, for the whole frame*/
- if ( slot_index == 0 )
+ n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out );
+ IF( scale != 0 )
{
- ptr_level = cngNoiseLevel;
+ /*Generate LF comfort noise only at first slot, for the whole frame*/
+ ptr_level = cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/
/* Generate Gaussian random noise in real and imaginary parts of the FFT bins
- Amplitudes are adjusted to the estimated noise level cngNoiseLevel in each bin */
- if ( hFdCngCom->startBand == 0 )
+ Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */
+ IF( EQ_16( hFdCngCom->startBand, 0 ) )
{
- rand_gauss( &fftBuffer[0], seed );
- ptr_r = fftBuffer + 2;
- fftBuffer[0] *= (float) sqrt( scale * *ptr_level ); /* DC component in FFT */
+ rand_gauss_fx( &fftBuffer[0], seed, exp_out );
+ ptr_r = fftBuffer + 2; /*hFdCngCom->fftBuffer_exp*/
+
+ Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp );
+ Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT Q31 - exp2*/
+ sqr = L_shl( sqr, exp2 ); /*Q31*/
+ fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT Q31 - hFdCngCom->fftBuffer_exp*/
+ move32();
ptr_level++;
}
- else
+ ELSE
{
- fftBuffer[0] = 0.f;
- set_f( fftBuffer + 2, 0.0f, 2 * ( hFdCngCom->startBand - 1 ) );
- ptr_r = fftBuffer + 2 * hFdCngCom->startBand;
+ fftBuffer[0] = 0;
+ move32();
+ set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) );
+ ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); /*hFdCngCom->fftBuffer_exp*/
}
- ptr_i = ptr_r + 1;
+ ptr_i = ptr_r + 1; /*hFdCngCom->fftBuffer_exp*/
- for ( ; ptr_level < cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; ptr_level++ )
+ FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ )
{
- /* Real part in FFT bins */
- rand_gauss( ptr_r, seed );
- ( *ptr_r ) *= (float) sqrt( ( scale * *ptr_level ) * 0.5f );
+ rand_gauss_fx( ptr_r, seed, exp_out );
+ Word16 exp2 = hFdCngCom->cngNoiseLevelExp;
+ Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); /*Q31 - exp2*/
+ ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/
+ move32();
ptr_r += 2;
+
/* Imaginary part in FFT bins */
- rand_gauss( ptr_i, seed );
- ( *ptr_i ) *= (float) sqrt( ( scale * *ptr_level ) * 0.5f );
+ rand_gauss_fx( ptr_i, seed, exp_out );
+ ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/
+ move32();
ptr_i += 2;
}
-
/* Remaining FFT bins are set to zero */
- set_f( fftBuffer + 2 * hFdCngCom->stopFFTbin, 0.0f, hFdCngCom->fftlen - 2 * hFdCngCom->stopFFTbin );
+ set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) );
/* Nyquist frequency is discarded */
- fftBuffer[1] = 0.f;
+ fftBuffer[1] = 0;
+ move32();
/* Perform STFT synthesis */
- SynthesisSTFT( fftBuffer, tdBuffer, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, X, Y, -1, -1 );
-
-#ifdef DEBUG_MODE_DIRAC
- {
- int16_t tmp[1000];
-
- for ( i = 0; i < hFdCngCom->frameSize; i++ )
- {
- tmp[i] = (int16_t) ( tdBuffer[i] + 0.5f );
- }
- dbgwrite( tmp, sizeof( int16_t ), hFdCngCom->frameSize, 1, "./res/ivas_dirac_cna_fft.pcm" );
- }
-#endif
+ SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom );
+ scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11
}
- /* LF CLDFB*/
- cldfbAnalysis_ts( &( tdBuffer[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, hFdCngCom->numCoreBands, h_cldfb );
- }
- else
- {
- if ( slot_index == 0 )
+ ELSE
{
/* very low level case - update random seeds */
generate_masking_noise_update_seed_fx( hFdCngCom );
- set_f( fftBuffer, 0.f, hFdCngCom->fftlen );
-
+ set32_fx( fftBuffer, 0, hFdCngCom->fftlen );
/* Perform STFT synthesis */
- SynthesisSTFT( fftBuffer, tdBuffer, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, X, Y, -1, -1 );
+ SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom );
+ }
+ hFdCngCom->fftBuffer_exp = 31 - 11;
+ move16();
+ n_samples_out = sub( n_samples_out, hFdCngCom->frameSize );
+ n_samples_start = add( n_samples_start, hFdCngCom->frameSize );
+ }
+ }
-#ifdef DEBUG_MODE_DIRAC
- {
- int16_t tmp[1000];
+ pop_wmops();
- for ( i = 0; i < hFdCngCom->frameSize; i++ )
- {
- tmp[i] = (int16_t) ( tdBuffer[i] + 0.5f );
- }
- dbgwrite( tmp, sizeof( int16_t ), hFdCngCom->frameSize, 1, "./res/ivas_dirac_cna_fft.pcm" );
+ return;
+}
+void generate_masking_noise_dirac_ivas_fx(
+ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
+ Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA q_input*/
+ Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer q_cldfb*/
+ Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer q_cldfb*/
+ const Word16 slot_index, /* i : CLDFB slot index Q0*/
+ const Word16 cna_flag, /* i : CNA flag for LB and HB Q0*/
+ const Word16 fd_cng_flag, /* i : FD-CNG flag for HB Q0*/
+ Word16 q_input,
+ Word16 *q_cldfb )
+{
+ Word16 i;
+ Word32 *ptr_level_fx;
+ Word16 *seed = &( hFdCngCom->seed );
+ Word32 scale_fx;
+ Word16 q_scale, q_shift, q_ptr_level;
+
+ push_wmops( "fd_cng_dirac" );
+
+ /* Init */
+ scale_fx = 0;
+ move32();
+
+ /* Resample CLDFB memories if necessary*/
+ IF( NE_16( i_mult( h_cldfb->no_channels, h_cldfb->no_col ), hFdCngCom->frameSize ) )
+ {
+ resampleCldfb_ivas_fx( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC );
+ }
+
+ set32_fx( Cldfb_RealBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX );
+
+ /*LB CLDFB - CNA from STFT*/
+ IF( cna_flag != 0 )
+ {
+ /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
+ IF( hFdCngCom->likelihood_noisy_speech > 0 )
+ {
+ /* Compute additional CN level */
+ FOR( i = 0; i < 15; i++ )
+ {
+ test();
+ test();
+ if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) &&
+ ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) &&
+ ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) )
+ {
+ BREAK;
}
-#endif
}
+ scale_fx = L_shr( L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ), Q3 ); /* Q27 */
+ scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech );
+ }
+ }
+ /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/
+ IF( cna_flag && tdBuffer_fx != NULL )
+ {
+ *q_cldfb = q_input;
+ move16();
+ IF( scale_fx != 0 )
+ {
+ /* LF CLDFB*/
+ cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb );
+ }
+ ELSE
+ {
/* LB ana CLDFB*/
- cldfbAnalysis_ts( &( tdBuffer[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, hFdCngCom->numCoreBands, h_cldfb );
+ cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb );
}
}
/*HF CLDFB - CNA and/or FD-CNG*/
if ( fd_cng_flag )
{
- scale += 1.f;
+ scale_fx = L_add( scale_fx, ONE_IN_Q27 ); // 1 in Q27
}
- if ( scale != 0 )
+ IF( scale_fx != 0 )
{
- scale *= CLDFB_SCALING_FLT * ( h_cldfb->scale * h_cldfb->scale * 8.f );
- ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand;
-
- for ( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ )
+ q_scale = 27;
+ move16();
+ q_shift = norm_l( scale_fx );
+ scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/
+ q_scale = add( q_scale, q_shift );
+ scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34
+ q_scale = sub( add( q_scale, 2 * Q8 ), 31 );
+ ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/
+ q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp );
+
+ FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ )
{
+ Word32 num;
+ Word16 exp, q_num;
+ q_shift = norm_l( scale_fx );
+ scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/
+ q_scale = add( q_scale, q_shift );
+ num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/
+ q_num = sub( add( q_scale, q_ptr_level ), 31 );
+ exp = sub( 31, q_num );
+ num = Sqrt32( num, &exp ); /*Q31 - exp*/
/* Real part in CLDFB band */
- rand_gauss( &Cldfb_RealBuffer[i], seed );
- Cldfb_RealBuffer[i] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f );
+ rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb );
+ Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp );
+ move32();
/* Imaginary part in CLDFB band */
- rand_gauss( &Cldfb_ImagBuffer[i], seed );
- Cldfb_ImagBuffer[i] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f );
+ rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb );
+ Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp );
+ move32();
- ptr_level++;
+ ptr_level_fx++;
}
}
- wmops_sub_end();
+ pop_wmops();
return;
}
@@ -5349,94 +5702,155 @@ void generate_masking_noise_dirac(
*
*-------------------------------------------------------------------*/
-void FdCngDecodeMDCTStereoSID(
+void FdCngDecodeMDCTStereoSID_fx(
CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */
)
{
DEC_CORE_HANDLE sts[CPE_CHANNELS];
HANDLE_FD_CNG_COM hFdCngCom;
- float *ms_ptr[CPE_CHANNELS];
- float *lr_ptr[CPE_CHANNELS];
- float logNoiseEst[CPE_CHANNELS][NPART];
- float gain[CPE_CHANNELS];
- int16_t indices[FD_CNG_stages_37bits];
- int16_t N, i, ch, p, stages;
- int16_t is_out_ms;
+ Word32 *ms_ptr_fx[CPE_CHANNELS];
+ Word32 *lr_ptr_fx[CPE_CHANNELS];
+ Word32 logNoiseEst_fx[CPE_CHANNELS][NPART];
+ Word32 gain_fx[CPE_CHANNELS];
+ Word16 indices[FD_CNG_stages_37bits];
+ Word16 N, i, ch, p, stages;
+ Word16 is_out_ms;
+ Word32 *invTrfMatrix_fx;
+ Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC];
+ Word16 shift, exp_diff, max_exp_idx;
+ Word16 exp_arr[NPART];
+ Word32 tmp32, tmp32_arr[NPART];
+
+ invTrfMatrix_fx = (Word32 *) tmpRAM_fx;
+ create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31
is_out_ms = 0;
+ move16();
if ( hCPE->hCoreCoder[0]->cng_sba_flag )
{
is_out_ms = 1;
+ move16();
}
N = 0; /* to avoid compilation warning */
+ move16();
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[ch] = hCPE->hCoreCoder[ch];
- ms_ptr[ch] = &logNoiseEst[ch][0];
- lr_ptr[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0];
+ ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/
+ lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q18*/
}
/* decode noise shapes and gains */
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[ch] = hCPE->hCoreCoder[ch];
hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom;
N = hFdCngCom->npart;
- hFdCngCom->sid_frame_counter++;
+ move16();
+ hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /*Q0*/
+ move16();
- if ( ch )
+ IF( ch )
{
stages = FD_CNG_JOINT_stages_25bits;
+ move16();
}
- else
+ ELSE
{
stages = FD_CNG_stages_37bits;
+ move16();
}
/* read bitstream */
- for ( i = 0; i < stages; i++ )
+ FOR( i = 0; i < stages; i++ )
{
- indices[i] = get_next_indice( sts[ch], bits_37bits[i] );
+ indices[i] = get_next_indice_fx( sts[ch], bits_37bits[i] ); /*Q0*/
+ move16();
}
{
- gain[ch] = ( (float) get_next_indice( sts[ch], 7 ) - GAIN_Q_OFFSET_IVAS ) / 1.5f;
+ gain_fx[ch] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[ch], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20
+ move32();
}
/* MSVQ decoder */
- msvq_dec( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, ms_ptr[ch], NULL );
+ shift = find_guarded_bits_fx( N );
+ msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); // Q20 - shift
+
+ Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20
}
- if ( sts[0]->hFdCngDec->hFdCngCom->no_side_flag )
+ dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) );
+
+ IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag )
{
- set_zero( ms_ptr[1], NPART );
+ set32_fx( ms_ptr_fx[1], 0, NPART );
}
- if ( is_out_ms == 0 )
+ IF( EQ_16( is_out_ms, 0 ) )
{
- inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f );
+ inverseMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 );
}
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
+ max_exp_idx = 0;
+ move16();
hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom;
- for ( p = 0; p < N; p++ )
+ FOR( p = 0; p < N; p++ )
{
- lr_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f );
+ tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20
+ tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/
+ move32();
+ if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) )
+ {
+ max_exp_idx = p; /*Q0*/
+ move16();
+ }
+ }
+
+ // Bringing in same exponent
+ FOR( p = 0; p < N; p++ )
+ {
+ lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q31 - exp_arr[max_exp_idx]*/
+ move32();
}
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 );
+ hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx];
+ move16();
+
+ scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 );
+
+ hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp;
+ move16();
lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac );
}
- if ( hCPE->nchan_out == 1 && hCPE->last_element_brate <= IVAS_SID_4k4 )
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) )
{
/* create proper M noise shape in channel zero after gains have been applied */
- for ( p = 0; p < N; p++ )
+ exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp );
+ move16();
+ FOR( p = 0; p < N; p++ )
+ {
+ IF( GT_16( exp_diff, 0 ) )
+ {
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/
+ move32();
+ }
+ ELSE
+ {
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/
+ move32();
+ }
+ }
+ IF( LT_16( exp_diff, 0 ) )
{
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = 0.5f * ( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] + sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] );
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) );
+ move16();
}
}
@@ -5445,86 +5859,141 @@ void FdCngDecodeMDCTStereoSID(
/*-------------------------------------------------------------------
- * FdCngDecodeDiracMDCTStereoSID()
+ * FdCngDecodeDiracMDCTStereoSID_fx()
*
- * Decode FD-Cng parameters for CNG in 2TC DirAC mode from the bitstream
+ * Decode FD-CNG parameters for CNG in 2TC DirAC mode from the bitstream
*-------------------------------------------------------------------*/
-void FdCngDecodeDiracMDCTStereoSID(
+void FdCngDecodeDiracMDCTStereoSID_fx(
CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */
)
{
DEC_CORE_HANDLE sts[CPE_CHANNELS];
HANDLE_FD_CNG_COM hFdCngCom;
- float *ms_ptr[CPE_CHANNELS];
- float *lr_ptr[CPE_CHANNELS];
- float logNoiseEst[CPE_CHANNELS][NPART];
- float gain[CPE_CHANNELS];
- int16_t indices[FD_CNG_stages_37bits];
- int16_t N, i, ch, p;
-
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ Word32 *ms_ptr_fx[CPE_CHANNELS];
+ Word32 *lr_ptr_fx[CPE_CHANNELS];
+ Word32 logNoiseEst_fx[CPE_CHANNELS][NPART];
+ Word32 gain_fx[CPE_CHANNELS];
+ Word16 indices[FD_CNG_stages_37bits];
+ Word16 N, i, ch, p;
+ Word32 *invTrfMatrix_fx;
+ Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC];
+ Word16 shift, exp_diff, max_exp_idx;
+ Word16 exp_arr[NPART];
+ Word32 tmp32, tmp32_arr[NPART];
+
+ invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */
+ create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31
+
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[ch] = hCPE->hCoreCoder[ch];
- ms_ptr[ch] = &logNoiseEst[ch][0];
- lr_ptr[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0];
- ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++;
+ ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/
+ lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q20*/
+ ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; /*Q18*/
}
/* decode noise shapes and gains */
hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom;
- N = hFdCngCom->npart;
+ N = hFdCngCom->npart; /*Q0*/
+ move16();
/* read bitstream */
- for ( i = 0; i < FD_CNG_stages_37bits; i++ )
+ FOR( i = 0; i < FD_CNG_stages_37bits; i++ )
{
- indices[i] = get_next_indice( sts[0], bits_37bits[i] );
+ indices[i] = get_next_indice_fx( sts[0], bits_37bits[i] ); /*Q0*/
+ move16();
}
- gain[0] = ( (float) get_next_indice( sts[0], 7 ) - GAIN_Q_OFFSET_IVAS ) / 1.5f;
- gain[1] = gain[0];
+ gain_fx[0] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[0], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20
+ move32();
+
+ gain_fx[1] = gain_fx[0]; /*Q20*/
+ move32();
/* MSVQ decoder */
- msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, ms_ptr[0], NULL );
- mvr2r( ms_ptr[0], ms_ptr[1], N );
+ shift = find_guarded_bits_fx( N );
+ msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); // Q20 - shift
+
+ Scale_sig32( ms_ptr_fx[0], N, shift ); // Q20
- /*inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f );*/
+ Copy32( ms_ptr_fx[0], ms_ptr_fx[1], N ); /*Q20*/
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
+ max_exp_idx = 0;
+ move16();
hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom;
- for ( p = 0; p < N; p++ )
+
+ FOR( p = 0; p < N; p++ )
+ {
+ tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20
+ tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/
+ move32();
+ if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) )
+ {
+ max_exp_idx = p; /*Q0*/
+ move16();
+ }
+ }
+
+ // Bringing in same exponent
+ FOR( p = 0; p < N; p++ )
{
- lr_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f );
+ lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q20*/
+ move32();
}
+ hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; /*Q0*/
+ move16();
+
/* NB last band energy compensation */
- if ( hFdCngCom->CngBandwidth == NB )
+ test();
+ IF( hFdCngCom->CngBandwidth == NB )
{
- lr_ptr[ch][N - 1] *= NB_LAST_BAND_SCALE;
+ lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], NB_LAST_BAND_SCALE_Q31 ); /*Q20*/
+ move32();
}
- else if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 )
+ ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
{
- lr_ptr[ch][N - 1] *= SWB_13k2_LAST_BAND_SCALE;
+ lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); /*Q20*/
+ move32();
}
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 );
+ scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 );
+
+ hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp;
+ move16();
lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac );
}
- sts[0]->hFdCngDec->hFdCngCom->coherence = 0.0f;
- sts[1]->hFdCngDec->hFdCngCom->coherence = 0.0f;
+ sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0;
+ move16();
+ sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0;
+ move16();
- if ( hCPE->nchan_out == 1 )
+ IF( EQ_16( hCPE->nchan_out, 1 ) )
{
/* create proper M noise shape in channel zero after gains have been applied */
- for ( p = 0; p < N; p++ )
+ exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp );
+ FOR( p = 0; p < N; p++ )
+ {
+ IF( exp_diff > 0 )
+ {
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/
+ move32();
+ }
+ ELSE
+ {
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/
+ move32();
+ }
+ }
+ IF( exp_diff < 0 )
{
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = 0.5f * ( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] + sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] );
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) );
+ move16();
}
- sts[0]->hFdCngDec->hFdCngCom->coherence = 0.0f;
- sts[1]->hFdCngDec->hFdCngCom->coherence = 0.0f;
}
return;
}
-#endif
diff --git a/lib_dec/gain_dec.c b/lib_dec/gain_dec.c
deleted file mode 100644
index 47e1f0be1a2a79b57dd772f7d1e5b59af4112750..0000000000000000000000000000000000000000
--- a/lib_dec/gain_dec.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/gaus_dec.c b/lib_dec/gaus_dec.c
deleted file mode 100644
index 47e1f0be1a2a79b57dd772f7d1e5b59af4112750..0000000000000000000000000000000000000000
--- a/lib_dec/gaus_dec.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/gs_dec.c b/lib_dec/gs_dec.c
deleted file mode 100644
index 4d34802bb66f2beb47f83cb9a11810c14de7d4a3..0000000000000000000000000000000000000000
--- a/lib_dec/gs_dec.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "ivas_prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * decod_audio()
- *
- * Decode audio (AC) frames
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/gs_dec_amr_wb.c b/lib_dec/gs_dec_amr_wb.c
deleted file mode 100644
index 47e1f0be1a2a79b57dd772f7d1e5b59af4112750..0000000000000000000000000000000000000000
--- a/lib_dec/gs_dec_amr_wb.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c
index 3a39f9e3312ee58ab31739545e069199f2d2accb..8f29eb9d13ce53f72ad042cec7c6fe757ca09f7d 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -6,7 +6,6 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot.h"
#include "prot_fx.h"
#include "ivas_cnst.h"
/*=========================================================================*/
@@ -75,12 +74,7 @@ void decod_audio_fx(
/* decode GSC SWB speech flag */
test();
-#if !defined ADD_LRTD
IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) )
-#else
- if ( st_fx->GSC_IVAS_mode >= 1 || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20 ) ||
- ( st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k ) ) ) )
-#endif
{
st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
move16();
@@ -98,30 +92,13 @@ void decod_audio_fx(
}
/* set bit-allocation */
-#ifdef ADD_LRTD
-#ifdef NONBE_FIX_GSC_BSTR
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
-#else
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
-#endif
/*---------------------------------------------------------------*
* Decode energy dynamics
*---------------------------------------------------------------*/
-#if defined ADD_LRTD
- test();
- test();
- IF( st_fx->GSC_IVAS_mode >= 1 || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) )
-#else
+
IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
-#endif
{
nb_subfr = NB_SUBFR; /* Q0 */
move16();
@@ -129,25 +106,6 @@ void decod_audio_fx(
move16();
hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */
move16();
-#ifdef ADD_LRTD
- if ( st_fx->GSC_IVAS_mode >= 1 )
- {
- if ( st_fx->core_brate < GSC_L_RATE_STG && st_fx->GSC_IVAS_mode < 3 )
- {
- nb_subfr = 2;
- }
- hGSCDec->noise_lev = NOISE_LEVEL_SP2;
-
- if ( st_fx->GSC_IVAS_mode == 3 ) /* Music like */
- {
- hGSCDec->noise_lev = NOISE_LEVEL_SP0;
- }
- else if ( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */
- {
- hGSCDec->noise_lev = NOISE_LEVEL_SP3;
- }
- }
-#endif
}
ELSE
{
@@ -165,54 +123,30 @@ void decod_audio_fx(
/*---------------------------------------------------------------*
* Decode number of subframes
*---------------------------------------------------------------*/
-#ifdef ADD_LRTD
- if ( st_fx->L_frame == L_FRAME16k && ( st_fx->core_brate <= ACELP_13k20 || st_fx->coder_type == INACTIVE ) )
- {
- hGSCDec->cor_strong_limit = 0;
- nb_subfr = 1;
- }
- else
-#endif
+
+
+ hGSCDec->cor_strong_limit = 1; /* Q0 */
+ move16();
+ nb_subfr = SWNB_SUBFR;
+ move16();
+
+ IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
{
- hGSCDec->cor_strong_limit = 1; /* Q0 */
+ nbits = 1;
move16();
- nb_subfr = SWNB_SUBFR;
+ nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
move16();
- IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
+ IF( s_and( nb_frame_flg, 0x1 ) == 0 )
{
- nbits = 1;
+ nb_subfr = 2 * SWNB_SUBFR; /* Q0 */
move16();
-#ifdef ADD_LRTD
- if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR )
- {
- nbits = 2;
- }
-#endif
- nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
+ hGSCDec->cor_strong_limit = 0;
move16();
-
- IF( s_and( nb_frame_flg, 0x1 ) == 0 )
- {
- nb_subfr = 2 * SWNB_SUBFR; /* Q0 */
- move16();
- hGSCDec->cor_strong_limit = 0;
- move16();
- }
-#ifdef ADD_LRTD
- else if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR )
- {
- nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */
- }
-
- if ( ( nb_frame_flg >> 1 ) == 1 )
- {
- nb_subfr *= 2;
- }
-#endif
}
}
}
+
/*---------------------------------------------------------------*
* Decode the last band where the adaptive (pitch) contribution is significant
*---------------------------------------------------------------*/
@@ -282,13 +216,7 @@ void decod_audio_fx(
* Decode adaptive (pitch) excitation contribution
*---------------------------------------------------------------*/
test();
-#ifdef ADD_LRTD
- if ( !( st_fx->GSC_IVAS_mode > 0 && st_fx->L_frame / nb_subfr == 2 * L_SUBFR && st_fx->GSC_IVAS_mode < 3 ) &&
- ( ( st_fx->core_brate >= MIN_RATE_FCB || st_fx->GSC_noisy_speech ) &&
- ( ( nb_subfr == NB_SUBFR && st_fx->L_frame == L_FRAME ) || ( nb_subfr == NB_SUBFR16k && st_fx->L_frame == L_FRAME16k ) ) ) )
-#else
IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) )
-#endif
{
Word16 indice;
nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */
@@ -303,11 +231,9 @@ void decod_audio_fx(
Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
}
-#ifdef ADD_LRTD
- dec_pit_exc_fx( st_fx, Aq, coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
-#else
+
dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf );
-#endif
+
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
{
minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit );
@@ -439,39 +365,19 @@ void decod_audio_fx(
tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */
move16();
-#ifdef IVAS_CODE
- if ( st_fx->extl_brate_fx_orig > 0 )
-#else
+
if ( st_fx->extl_brate > 0 )
-#endif
{
/* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
}
-
- test();
-#if defined ADD_LRTD
- test();
- if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
-#else
test();
if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) )
-#endif
{
tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */
}
-#ifdef ADD_LRTD
- IF( EQ_16( st_fx->idchan, 1 ) )
- {
- tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS );
- IF( EQ_16( st_fx->tdm_LRTD_flag, 1 ) )
- {
- tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA );
- }
- }
-#endif
gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc );
/*--------------------------------------------------------------------------------------*
* iDCT transform
@@ -612,26 +518,15 @@ void decod_audio_ivas_fx(
}
/* set bit-allocation */
-#if 1 // def ADD_LRTD
-#ifdef NONBE_FIX_GSC_BSTR
config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
/*---------------------------------------------------------------*
* Decode energy dynamics
*---------------------------------------------------------------*/
-#if 1 // defined ADD_LRTD
+
test();
test();
IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) )
-#else
- IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
-#endif
{
nb_subfr = NB_SUBFR; /* Q0 */
move16();
@@ -639,7 +534,7 @@ void decod_audio_ivas_fx(
move16();
hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */
move16();
-#if 1 // def ADD_LRTD
+
IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
{
test();
@@ -662,7 +557,6 @@ void decod_audio_ivas_fx(
move16();
}
}
-#endif
}
ELSE
{
@@ -680,7 +574,7 @@ void decod_audio_ivas_fx(
/*---------------------------------------------------------------*
* Decode number of subframes
*---------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
test();
test();
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || st_fx->coder_type == INACTIVE ) )
@@ -691,7 +585,6 @@ void decod_audio_ivas_fx(
move16();
}
ELSE
-#endif
{
hGSCDec->cor_strong_limit = 1; /* Q0 */
move16();
@@ -702,14 +595,14 @@ void decod_audio_ivas_fx(
{
nbits = 1; /* Q0 */
move16();
-#if 1 // def ADD_LRTD
+
test();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
{
nbits = 2; /* Q0 */
move16();
}
-#endif
+
nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
move16();
@@ -721,7 +614,6 @@ void decod_audio_ivas_fx(
hGSCDec->cor_strong_limit = 0;
move16();
}
-#if 1 // def ADD_LRTD
ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
{
nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */
@@ -732,18 +624,17 @@ void decod_audio_ivas_fx(
{
nb_subfr = shl( nb_subfr, 1 ); /* Q0 */
}
-#endif
}
}
}
-#if 1
+
test();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) )
{
nb_subfr = NB_SUBFR16k; /* Q0 */
move16();
}
-#endif
+
/*---------------------------------------------------------------*
* Decode the last band where the adaptive (pitch) contribution is significant
*---------------------------------------------------------------*/
@@ -802,7 +693,6 @@ void decod_audio_ivas_fx(
hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
move16();
-
/*--------------------------------------------------------------------------------------*
* Decode adaptive (pitch) excitation contribution
* Reset unvaluable part of the adaptive (pitch) excitation contribution
@@ -813,7 +703,6 @@ void decod_audio_ivas_fx(
* Decode adaptive (pitch) excitation contribution
*---------------------------------------------------------------*/
test();
-#if 1 // def ADD_LRTD
test();
test();
test();
@@ -824,9 +713,6 @@ void decod_audio_ivas_fx(
IF( !( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( idiv1616( st_fx->L_frame, nb_subfr ), 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
-#else
- IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) )
-#endif
{
Word16 indice;
nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */
@@ -841,11 +727,9 @@ void decod_audio_ivas_fx(
Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
}
-#if 1 // def ADD_LRTD
+
dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
-#else
- dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf );
-#endif
+
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
{
minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit );
@@ -977,29 +861,20 @@ void decod_audio_ivas_fx(
tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */
move16();
-#if 1 // def IVAS_CODE
+
if ( st_fx->extl_brate_orig > 0 )
-#else
- if ( st_fx->extl_brate > 0 )
-#endif
{
/* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
}
-
test();
-#if 1 // defined ADD_LRTD
test();
if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
-#else
- if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) )
-#endif
{
tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */
}
-#if 1 // ydef ADD_LRTD
IF( EQ_16( st_fx->idchan, 1 ) )
{
tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); /* Q0 */
@@ -1008,7 +883,7 @@ void decod_audio_ivas_fx(
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); /* Q0 */
}
}
-#endif
+
Word16 Q_exc_old = st_fx->Q_exc;
move16();
gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
@@ -1105,7 +980,6 @@ void gsc_dec_fx(
Word16 Q_exc )
{
Word16 i, j, bit, nb_subbands, pvq_len;
-#if 1 // def ADD_LRTD
Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
Word16 bitallocation_exc[2];
Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
@@ -1113,15 +987,6 @@ void gsc_dec_fx(
Word16 exc_diffQ[L_FRAME16k];
Word16 bits_per_bands[MBANDS_GN_BITALLOC16k];
Word16 concat_out[L_FRAME16k];
-#else
- Word16 bitallocation_band[MBANDS_GN];
- Word16 bitallocation_exc[2];
- Word16 Ener_per_bd_iQ[MBANDS_GN];
- Word16 max_ener_band[MBANDS_GN];
- Word16 exc_diffQ[L_FRAME];
- Word16 bits_per_bands[MBANDS_GN];
- Word16 concat_out[L_FRAME];
-#endif
Word16 inpulses_fx[NB_SFM];
Word16 imaxpulse_fx[NB_SFM];
Word16 mean_gain;
@@ -1145,22 +1010,7 @@ void gsc_dec_fx(
*--------------------------------------------------------------------------------------*/
bit = bits_used;
move16();
-#ifdef ADD_LRTD
- test();
- test();
- test();
- test();
- IF( EQ_16( coder_type, INACTIVE ) && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) )
- {
- bit = add( bit, GSC_LRES_NB_NITS );
- }
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Mbands_gn = MBANDS_GN16k;
- move16();
- }
-#endif
set16_fx( exc_diffQ, 0, st_fx->L_frame );
/*--------------------------------------------------------------------------------------*
@@ -1184,33 +1034,8 @@ void gsc_dec_fx(
}
ELSE
{
-
-#ifdef ADD_LRTD
- i = 0;
- move16();
- While( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
- {
- IF( LQ_32( st_fx->core_brate, brate_intermed_tbl[i] ) )
- {
- break;
- }
- i = add( i, 1 );
- }
-
- test();
- test();
- test();
- test();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) > &&EQ_16( coder_type, AUDIO ) &&
- LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */
- {
- i--;
- }
- mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth );
-
-#else
mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */
-#endif
+
st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
move16();
}
@@ -1236,10 +1061,7 @@ void gsc_dec_fx(
* reduce spectral dynamic
* save spectrum
*--------------------------------------------------------------------------------------*/
-#ifdef ADD_LRTD
- max_eq = 32767;
- move16();
-#endif
+
test();
IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) )
{
@@ -1270,12 +1092,6 @@ void gsc_dec_fx(
max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech,
st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-#ifdef ADD_LRTD
- if ( bit == 0 )
- {
- set16_fx( concact_out, 0, L_FRAME16k );
- }
-#endif
{
pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
@@ -1283,17 +1099,6 @@ void gsc_dec_fx(
seed_init = 0;
move16();
-#ifdef ADD_LRTD
- max_eq = 0.0f;
- max_eq_val = 1.0f;
-
- if ( ( ( st_fx->core_brate < ACELP_7k20 && st_fx->GSC_noisy_speech == 1 ) || st_fx->core_brate < 6000 ) && coder_type <= UNVOICED )
- {
- j = emaximum( concat_out, nb_subbands * 16, &max_eq );
- max_eq = (float) ( max_eq_val / ( fabs( concat_out[j] ) + 0.01f ) );
- max_eq = min( max_eq_val, max_eq );
- }
-#endif
/* Reorder Q bands */
FOR( j = 0; j < nb_subbands; j++ )
{
@@ -1350,34 +1155,8 @@ void gsc_dec_fx(
* Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
* Gain is based on the inter-correlation gain between the pulses found and residual signal
*--------------------------------------------------------------------------------------*/
-#ifdef ADD_LRTD
- test();
- test();
- test();
- test();
- test();
- test();
- IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) )
- {
- FOR( i = 64; i < st_fx->L_frame; i++ )
- {
- PMT( "GSC FIX point to be done here" )
- exc_diffQ[i] *= max_eq;
- }
- }
- ELSE IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) )
- {
- FOR( i = 0; i < L_FRAME; i++ )
- {
- PMT( "GSC FIX point to be done here" )
- exc_diffQ[i] *= max_eq;
- }
- }
- else
-#endif
- {
- freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame );
- }
+
+ freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame );
}
/*--------------------------------------------------------------------------------------*
@@ -1432,7 +1211,6 @@ void gsc_dec_ivas_fx(
Word16 *Q_exc )
{
Word16 i, j, bit, nb_subbands, pvq_len;
-#if 1 // def ADD_LRTD
Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
Word16 bitallocation_exc[2];
Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
@@ -1441,19 +1219,10 @@ void gsc_dec_ivas_fx(
Word16 bits_per_bands[MBANDS_GN_BITALLOC16k];
Word16 concat_out[L_FRAME16k];
Word16 max_eq, max_eq_val;
-#else
- Word16 bitallocation_band[MBANDS_GN];
- Word16 bitallocation_exc[2];
- Word16 Ener_per_bd_iQ[MBANDS_GN];
- Word16 max_ener_band[MBANDS_GN];
- Word16 exc_diffQ[L_FRAME];
- Word16 bits_per_bands[MBANDS_GN];
- Word16 concat_out[L_FRAME];
-#endif
Word16 inpulses_fx[NB_SFM];
Word16 imaxpulse_fx[NB_SFM];
Word16 mean_gain;
- Word16 Mbands_gn = 16;
+ Word16 Mbands_gn = MBANDS_GN;
Word16 Qexc_diffQ = Q_PVQ_OUT;
Word32 L_tmp;
Word16 Q_tmp;
@@ -1461,8 +1230,8 @@ void gsc_dec_ivas_fx(
GSC_DEC_HANDLE hGSCDec;
hGSCDec = st_fx->hGSCDec;
- move16(); // for Mbands_gn
- move16(); // for Qexc_diffQ
+ move16(); /* for Mbands_gn */
+ move16(); /* for Qexc_diffQ */
set16_fx( inpulses_fx, 0, NB_SFM );
set16_fx( imaxpulse_fx, 0, NB_SFM );
@@ -1471,7 +1240,7 @@ void gsc_dec_ivas_fx(
*--------------------------------------------------------------------------------------*/
bit = bits_used;
move16();
-#if 1 // def ADD_LRTD
+
test();
test();
test();
@@ -1485,7 +1254,7 @@ void gsc_dec_ivas_fx(
Mbands_gn = MBANDS_GN16k; /* Q0 */
move16();
}
-#endif
+
set16_fx( exc_diffQ, 0, st_fx->L_frame );
/*--------------------------------------------------------------------------------------*
@@ -1509,8 +1278,6 @@ void gsc_dec_ivas_fx(
}
ELSE
{
-
-#if 1 // def ADD_LRTD
i = 0;
move16();
WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
@@ -1532,9 +1299,6 @@ void gsc_dec_ivas_fx(
}
mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
-#else
- mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth );
-#endif
st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
move16();
}
@@ -1560,17 +1324,17 @@ void gsc_dec_ivas_fx(
* reduce spectral dynamic
* save spectrum
*--------------------------------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
max_eq = 32767;
move16();
-#endif
+
test();
IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) )
{
FOR( i = 0; i < st_fx->L_frame; i++ )
{
L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/
- L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */
+ L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /*Q10*/
hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/
move16();
}
@@ -1594,27 +1358,20 @@ void gsc_dec_ivas_fx(
max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech,
st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-#if 1 // def ADD_LRTD
IF( bit == 0 )
{
set16_fx( concat_out, 0, L_FRAME16k );
}
-#endif
+
+ pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
+ IF( nb_subbands > 0 )
{
- pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
-#ifdef MSAN_FIX
- IF( nb_subbands > 0 )
- {
- Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
- }
-#else
Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
-#endif
}
+
seed_init = 0;
move16();
-#if 1 // def ADD_LRTD
max_eq = 0;
move16();
max_eq_val = 32767; /* 1.0f in Q15 */
@@ -1626,7 +1383,6 @@ void gsc_dec_ivas_fx(
IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( coder_type, UNVOICED ) )
{
j = maximum_fx( concat_out, imult1616( nb_subbands, 16 ), &max_eq );
- // max_eq = max_eq_val / (abs_s(concat_out[j]) + 328 /*0.01f*/ );
Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/;
if ( LE_16( temp_max_eq, ONE_IN_Q10 ) )
{
@@ -1641,7 +1397,7 @@ void gsc_dec_ivas_fx(
max_eq = shl( max_eq, exp ); /* Q15 */
}
}
-#endif
+
/* Reorder Q bands */
FOR( j = 0; j < nb_subbands; j++ )
{
@@ -1667,11 +1423,7 @@ void gsc_dec_ivas_fx(
}
if ( concat_out[j] < 0 )
{
-#ifdef BASOP_NOGLOB_TMP_715
seed_init = add_sat( seed_init, 3 ); /* Q0 */
-#else
- seed_init = add( seed_init, 3 );
-#endif
}
}
@@ -1701,7 +1453,7 @@ void gsc_dec_ivas_fx(
* Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
* Gain is based on the inter-correlation gain between the pulses found and residual signal
*--------------------------------------------------------------------------------------*/
-#if 1 // def ADD_LRTD
+
test();
test();
test();
@@ -1710,8 +1462,6 @@ void gsc_dec_ivas_fx(
{
FOR( i = 64; i < st_fx->L_frame; i++ )
{
- // PMT("GSC FIX point to be done here")
- // exc_diffQ[i] *= max_eq;
exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */
move16();
}
@@ -1720,14 +1470,11 @@ void gsc_dec_ivas_fx(
{
FOR( i = 0; i < L_FRAME; i++ )
{
- // PMT("GSC FIX point to be done here")
- // exc_diffQ[i] *= max_eq;
exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */
move16();
}
}
ELSE
-#endif
{
freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame );
}
@@ -1768,17 +1515,11 @@ void GSC_dec_init(
move16();
move16();
-#ifdef ADD_LRTD
- set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME16k );
- set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME16k );
- set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN_BITALLOC16k );
- set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN_BITALLOC16k );
-#else
set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME );
set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME );
set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN );
set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN ); /*Q12*/
-#endif
+
hGSCDec->last_ener_fx = 0;
move16();
set16_fx( hGSCDec->last_bitallocation_band, 0, 6 );
diff --git a/lib_dec/hdecnrm.c b/lib_dec/hdecnrm.c
deleted file mode 100644
index 19627a4f33c4fbc9a2068d446f2bc8aee6f846b0..0000000000000000000000000000000000000000
--- a/lib_dec/hdecnrm.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "rom_dec.h"
-#include "wmc_auto.h"
-
-
-/*--------------------------------------------------------------------------*/
-/* Function decode_huff_context() */
-/* */
-/* Context based Huffman decoding for indices of quantized norms */
-/*--------------------------------------------------------------------------*/
-
-
-/*--------------------------------------------------------------------------*/
-/* Function hdecnrm() */
-/* */
-/* Huffman decoding for indices of quantized norms */
-/*--------------------------------------------------------------------------*/
-
-
-/*--------------------------------------------------------------------------
- * huff_dec()
- *
- * Huffman decoding
- *--------------------------------------------------------------------------*/
-
-
-/*--------------------------------------------------------------------------
- * hdecnrm_context()
- *
- * Huffman decoding for indices of quantized norms
- *--------------------------------------------------------------------------*/
-
-
-/*--------------------------------------------------------------------------
- * hdecnrm_resize()
- *
- *
- *--------------------------------------------------------------------------*/
-
-
-/*--------------------------------------------------------------------------
- * hdecnrm_trans()
- *
- * Huffman decoding for indices of quantized norms
- *--------------------------------------------------------------------------*/
diff --git a/lib_dec/hf_synth.c b/lib_dec/hf_synth.c
deleted file mode 100644
index fc8c8da5f16f2b20dafcf992e2d09d13def88ec0..0000000000000000000000000000000000000000
--- a/lib_dec/hf_synth.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-#include "basop32.h"
-
-/*---------------------------------------------------------------------*
- * Local function prototypes
- *---------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------------------*
- * hf_synthesis_amr_wb()
- *
- * HF noise synthesis
- * - Generate HF noise between 6 and 8 kHz, mix it with signal obtained by linear resampling.
- * - Set energy of high band
- *-----------------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------------------*
- * EnhanceClass()
- *
- *
- *-----------------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------------------*
- * envelope()
- *
- *
- *-----------------------------------------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------*
- * AdaptiveStartBand()
- *
- * adaptively select the start band of bandwidth extension
- *---------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------*
- * hp400_12k8()
- *
- * 2nd order Cheb2 high pass filter with cut off frequency at 400 Hz.
- * Optimized for fixed-point to get the following frequency response:
- *
- * frequency : 0Hz 100Hz 200Hz 300Hz 400Hz 630Hz 1.5kHz 3kHz
- * dB loss : -infdB -30dB -20dB -10dB -3dB +6dB +1dB 0dB
- *
- * Algorithm :
- *
- * y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]
- * + a[1]*y[i-1] + a[2]*y[i-2];
- *
- * short b[3] = {3660, -7320, 3660}; in Q12
- * short a[3] = {4096, 7320, -3540}; in Q12
- *
- * float b[3] = {0.893554687, -1.787109375, 0.893554687};
- * float a[3] = {1.000000000, 1.787109375, -0.864257812};
- *-----------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------*
- * filt_6k_7k()
- *
- * 15th order band pass 6kHz to 7kHz FIR filter
- *
- * frequency :4kHz 5kHz 5.5kHz 6kHz 6.5kHz 7kHz 7.5kHz 8kHz
- * dB loss : -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB
- * (gain = 4.0)
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c
index c61bf95ce2298f39e258b4d8f1a0e63a8ee639fd..94c7d4c6282edf47fa8278add6362ece82625d00 100644
--- a/lib_dec/hf_synth_fx.c
+++ b/lib_dec/hf_synth_fx.c
@@ -7,7 +7,6 @@
#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Static table prototypes */
#include "basop32.h"
-#include "prot.h"
/*---------------------------------------------------------------------*
* Local constants
@@ -21,7 +20,7 @@
*---------------------------------------------------------------------*/
static void filt_6k_7k_scale_fx( Word16 signal[], Word16 lg, Word16 mem[], Word16 fact, Word16 exp );
-static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn, Word16 *delay_syn_hf, Word16 *memExp1, Word16 *mem_hp_interp, const Word16 extl, const Word16 CNG_mode );
+static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn );
static void hf_synthesis_amr_wb_fx( const Word32 core_brate, const Word16 output_subfr, const Word16 Ap[], Word16 exc16k[], Word16 synth_out[], Word16 *mem_syn_hf, Word16 *delay_syn_hf, Word16 *mem_hp_interp, Word16 p_r, Word16 HF_corr_gain, Word16 til, Word16 voice_factors, const Word16 exc[], const Word16 Q_exc, const Word16 Q_out, Word16 qhf );
static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, const Word16 Aq[], Word16 Ap[], Word16 *r, Word16 tilt0, Word16 tilt, Word16 voice_factor );
static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const Word16 *lsf, const Word16 voicing_fac, const Word16 clas, Word16 *voicing_flag, Word16 *start_band_old, Word32 *OptCrit_old );
@@ -87,12 +86,7 @@ void hf_synth_fx(
Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
const Word16 Q_exc, /* i : excitation scaling */
- const Word16 Q_syn2, /* i : synthesis scaling */
- Word16 *delay_syn_hf, /*i/o: HF synthesis memory Q_syn2*/
- Word16 *memExp1, /* o : HF excitation exponent */
- Word16 *mem_hp_interp, /* i/o: interpol. memory Qx*/
- const Word16 extl, /* i : flag indicating BWE Q0*/
- const Word16 CNG_mode /* i : CNG_mode Q0*/
+ const Word16 Q_syn2 /* i : synthesis scaling */
)
{
const Word16 *p_Aq;
@@ -104,8 +98,7 @@ void hf_synth_fx(
p_Aq = Aq; /* Q12 */
FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
{
- hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[imult3216( (Word32) i_subfr, output_subfr ) / L_SUBFR],
- Q_syn2, delay_syn_hf, memExp1, mem_hp_interp, extl, CNG_mode );
+ hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[imult3216( (Word32) i_subfr, output_subfr ) / L_SUBFR], Q_syn2 );
p_Aq += ( M + 1 ); /* Q12 */
}
@@ -133,27 +126,19 @@ static void hf_synthesis_fx(
const Word16 Q_exc, /* i : excitation scaling */
Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/
Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/
- const Word16 Q_syn, /* i : synthesis scaling */
- Word16 *delay_syn_hf, /* i/o: HF synthesis memory Q_syn*/
- Word16 *memExp1, /* o : HF excitation scaling exponent */
- Word16 *mem_hp_interp, /* i/o: interpol. memory Qx*/
- const Word16 extl, /* i : flag indicating BWE Q0*/
- const Word16 CNG_mode /* i : CNG_mode Q0*/
+ const Word16 Q_syn /* i : synthesis scaling */
)
{
- Word16 i;
+ Word16 i, s;
Word16 HF_syn[L_SUBFR16k], upsampled_HF_syn[L_FRAME48k / NB_SUBFR];
Word16 HF_exc[L_SUBFR16k];
- Word16 temp_buffer[NS2SA( 16000, DELAY_CLDFB_NS ) - L_FILT16k];
- Word16 tmp, ener, exp1, exp2, scale, delay;
+ Word16 tmp, ener, exp1, exp2, scale;
Word32 L_tmp;
Word16 Ap[M16k + 1];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
#endif
- (void) extl;
- (void) CNG_mode;
/*-----------------------------------------------------------------*
* generate white noise vector
@@ -189,8 +174,8 @@ static void hf_synthesis_fx(
L_tmp = Isqrt_lc( L_tmp, &exp1 );
scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */
- exp2 = sub( *memExp1, exp1 );
- *memExp1 = exp1;
+ exp2 = sub( hBWE_zero->memExp1, exp1 );
+ hBWE_zero->memExp1 = exp1;
move16();
/*-----------------------------------------------------------------*
@@ -280,41 +265,31 @@ static void hf_synthesis_fx(
*-----------------------------------------------------------------*/
/* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */
- delay = NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15;
- Copy( HF_syn + sub( L_SUBFR16k, delay ), temp_buffer, delay ); /* Q_syn+exp1 */
- Copy( HF_syn, HF_syn + delay, sub( L_SUBFR16k, delay ) ); /* Q_syn+exp1 */
- Copy( delay_syn_hf, HF_syn, delay ); /* Q_syn */
- Copy( temp_buffer, delay_syn_hf, delay ); /* Q_syn */
+ delay_signal_fx( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf_fx, NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15 );
/* interpolate the HF synthesis */
IF( EQ_16( output_subfr, L_SUBFR48k ) ) /* 48kHz sampled output */
{
- {
- Word16 s;
- s = s_max( s_min( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( mem_hp_interp, INTERP_3_1_MEM_LEN - 3 ) ), 3 ),
- sub( Find_Max_Norm16( mem_hp_interp + INTERP_3_1_MEM_LEN - 3, 3 ), 1 ) ),
- 0 );
- Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
- Scale_sig( mem_hp_interp, INTERP_3_1_MEM_LEN, s ); /* Qx + s */
- interpolate_3_over_1_allpass_fx( HF_syn, L_SUBFR16k, upsampled_HF_syn, mem_hp_interp );
- Scale_sig( upsampled_HF_syn, 3 * L_SUBFR16k, -s ); /* Q_syn + exp1 + s */
- Scale_sig( mem_hp_interp, INTERP_3_1_MEM_LEN, -s ); /* Qx */
- Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
- }
+ s = s_max( s_min( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN - 3 ) ), 3 ),
+ sub( Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx + INTERP_3_1_MEM_LEN - 3, 3 ), 1 ) ),
+ 0 );
+ Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, s ); /* Qx + s */
+ interpolate_3_over_1_allpass_fx( HF_syn, L_SUBFR16k, upsampled_HF_syn, hBWE_zero->mem_hp_interp_fx );
+ Scale_sig( upsampled_HF_syn, 3 * L_SUBFR16k, -s ); /* Q_syn + exp1 + s */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, -s ); /* Qx */
+ Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
Scale_sig( upsampled_HF_syn, L_SUBFR48k, -1 );
}
ELSE IF( EQ_16( output_subfr, L_SUBFR32k ) ) /* 32kHz sampled output */
{
- {
- Word16 s;
- s = s_max( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( mem_hp_interp, 2 * ALLPASSSECTIONS_STEEP ) ), 2 ), 0 );
- Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
- Scale_sig( mem_hp_interp, 2 * ALLPASSSECTIONS_STEEP, s ); /* Qx + s */
- Interpolate_allpass_steep_fx( HF_syn, mem_hp_interp, L_SUBFR16k, upsampled_HF_syn );
- Scale_sig( upsampled_HF_syn, 2 * L_SUBFR16k, -s ); /* Q_syn + exp1 */
- Scale_sig( mem_hp_interp, 2 * ALLPASSSECTIONS_STEEP, -s ); /* Qx */
- Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
- }
+ s = s_max( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP ) ), 2 ), 0 );
+ Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, s ); /* Qx + s */
+ Interpolate_allpass_steep_fx( HF_syn, hBWE_zero->mem_hp_interp_fx, L_SUBFR16k, upsampled_HF_syn );
+ Scale_sig( upsampled_HF_syn, 2 * L_SUBFR16k, -s ); /* Q_syn + exp1 */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, -s ); /* Qx */
+ Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
}
ELSE /* 16kHz sampled output */
{
@@ -1151,7 +1126,8 @@ static void hf_synthesis_amr_wb_fx(
* Synchronize LB and HB components (delay componsation)
* Add synthesised high band to speech synthesis
*-----------------------------------------------------------------*/
- delay_signal( HF_syn, L_SUBFR16k, delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) );
+
+ delay_signal_fx( HF_syn, L_SUBFR16k, delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) );
IF( EQ_16( output_subfr, L_SUBFR48k ) ) /* 48kHz sampled output */
{
diff --git a/lib_dec/hq_classifier_dec.c b/lib_dec/hq_classifier_dec.c
deleted file mode 100644
index c899b52ff72d3d5658f135f34e7730d22f0987de..0000000000000000000000000000000000000000
--- a/lib_dec/hq_classifier_dec.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/hq_conf_fec.c b/lib_dec/hq_conf_fec.c
deleted file mode 100644
index b25a46f03b521c59cfd2d349c3cd49bafb0b6183..0000000000000000000000000000000000000000
--- a/lib_dec/hq_conf_fec.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c
deleted file mode 100644
index cd29271f1d6d30c313225a2a83e73b2a89cea683..0000000000000000000000000000000000000000
--- a/lib_dec/hq_core_dec.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "ivas_prot.h"
-
-/*--------------------------------------------------------------------------
- * hq_core_dec()
- *
- * HQ core decoder
- *--------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------*
- * hq_core_dec_init()
- *
- * Initialize HQ core state structure
- *-------------------------------------------------------------------*/
diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c
index 626f25ef4861d56dfdc4a97bf817b3929084e0a2..4d1ef677471054485e43ff9c2a27c3b2058f86d3 100644
--- a/lib_dec/hq_core_dec_fx.c
+++ b/lib_dec/hq_core_dec_fx.c
@@ -6,7 +6,6 @@
#include "cnst.h" /* Common constants */
#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot.h"
#include "ivas_prot_fx.h"
/*--------------------------------------------------------------------------
* hq_core_dec()
@@ -491,30 +490,18 @@ void hq_core_dec_fx(
test();
test();
test();
- IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && st_fx->plcInfo.concealment_method == TCX_NONTONAL && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) )
+ IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && st_fx->hPlcInfo->concealment_method == TCX_NONTONAL && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) )
{
- st_fx->plcInfo.recovery_gain = shl_sat( st_fx->plcInfo.recovery_gain, *Q_synth ); /* Q14 + Q_synth */
+ st_fx->hPlcInfo->recovery_gain = shl_sat( st_fx->hPlcInfo->recovery_gain, *Q_synth ); /* Q14 + Q_synth */
move16();
- IF( st_fx->tonalMDCTconceal.q_lastPcmOut != 0 )
+ IF( st_fx->hTonalMDCTConc->q_lastPcmOut != 0 )
{
- Scale_sig( st_fx->tonalMDCTconceal.secondLastPcmOut, shr( st_fx->plcInfo.FrameSize, 1 ), negate( st_fx->tonalMDCTconceal.q_lastPcmOut ) );
- Scale_sig( st_fx->tonalMDCTconceal.lastPcmOut, st_fx->plcInfo.FrameSize, negate( st_fx->tonalMDCTconceal.q_lastPcmOut ) );
- st_fx->tonalMDCTconceal.q_lastPcmOut = 0;
+ Scale_sig( st_fx->hTonalMDCTConc->secondLastPcmOut, shr( st_fx->hPlcInfo->L_frameTCX, 1 ), negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) );
+ Scale_sig( st_fx->hTonalMDCTConc->lastPcmOut, st_fx->hPlcInfo->L_frameTCX, negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) );
+ st_fx->hTonalMDCTConc->q_lastPcmOut = 0;
move16();
}
- waveform_adj2_fix( st_fx->tonalMDCTconceal.secondLastPcmOut,
- synth,
- st_fx->plcInfo.data_noise,
- &st_fx->plcInfo.outx_new_n1_fx,
- &st_fx->plcInfo.nsapp_gain_fx,
- &st_fx->plcInfo.nsapp_gain_n_fx,
- &st_fx->plcInfo.recovery_gain,
- st_fx->plcInfo.step_concealgain_fx,
- st_fx->plcInfo.Pitch_fx,
- st_fx->plcInfo.FrameSize,
- 0,
- add( extract_l( st_fx->plcInfo.nbLostCmpt ), 1 ),
- st_fx->bfi );
+ waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth, 0, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
}
IF( GE_16( output_frame, L_FRAME16k ) )
@@ -640,9 +627,7 @@ void ivas_hq_core_dec_fx(
set16_fx( gapsynth_fx, 0, L_FRAME48k );
set16_fx( num_bands_p, 0, MAX_SB_NB );
set16_fx( ynrm, 39, NB_SFM ); /* Initialize to the smallest value */
-#ifdef MSAN_FIX
set16_fx( wtda_audio_16, 0, 2 * L_FRAME48k );
-#endif
mean_en_high_fx = 0;
move16();
Q_audio = 12;
@@ -964,9 +949,6 @@ void ivas_hq_core_dec_fx(
index = tcx_cfg->tcx_last_overlap_mode; /* Q0 */
move16();
-#ifndef MSAN_FIX
- Copy_Scale_sig_32_16( wtda_audio, wtda_audio_16, 2 * L_FRAME48k, -13 );
-#endif
/* LB synthesis */
E_audio = sub( 31, Q_audio );
@@ -1123,30 +1105,18 @@ void ivas_hq_core_dec_fx(
test();
test();
test();
- IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) )
+ IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) )
{
- st_fx->plcInfo.recovery_gain = shl_sat( st_fx->plcInfo.recovery_gain, *Q_synth ); /* Q15 */
+ st_fx->hPlcInfo->recovery_gain = shl_sat( st_fx->hPlcInfo->recovery_gain, *Q_synth ); /* Q15 */
move16();
- IF( st_fx->tonalMDCTconceal.q_lastPcmOut != 0 )
+ IF( st_fx->hTonalMDCTConc->q_lastPcmOut != 0 )
{
- Scale_sig( st_fx->tonalMDCTconceal.secondLastPcmOut, shr( st_fx->plcInfo.FrameSize, 1 ), negate( st_fx->tonalMDCTconceal.q_lastPcmOut ) );
- Scale_sig( st_fx->tonalMDCTconceal.lastPcmOut, st_fx->plcInfo.FrameSize, negate( st_fx->tonalMDCTconceal.q_lastPcmOut ) );
- st_fx->tonalMDCTconceal.q_lastPcmOut = 0;
+ Scale_sig( st_fx->hTonalMDCTConc->secondLastPcmOut, shr( st_fx->hPlcInfo->L_frameTCX, 1 ), negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) );
+ Scale_sig( st_fx->hTonalMDCTConc->lastPcmOut, st_fx->hPlcInfo->L_frameTCX, negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) );
+ st_fx->hTonalMDCTConc->q_lastPcmOut = 0;
move16();
}
- waveform_adj2_fix( st_fx->tonalMDCTconceal.secondLastPcmOut,
- synth,
- st_fx->plcInfo.data_noise,
- &st_fx->plcInfo.outx_new_n1_fx,
- &st_fx->plcInfo.nsapp_gain_fx,
- &st_fx->plcInfo.nsapp_gain_n_fx,
- &st_fx->plcInfo.recovery_gain,
- st_fx->plcInfo.step_concealgain_fx,
- st_fx->plcInfo.Pitch_fx,
- st_fx->plcInfo.FrameSize,
- 0,
- add( extract_l( st_fx->plcInfo.nbLostCmpt ), 1 ),
- st_fx->bfi );
+ waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth, 0, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
}
IF( GE_16( output_frame, L_FRAME16k ) )
@@ -1226,17 +1196,15 @@ void HQ_core_dec_init_fx(
)
{
set16_fx( hHQ_core->old_out_fx, 0, L_FRAME48k );
+ set32_fx( hHQ_core->old_out_fx32, 0, L_FRAME48k );
set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME32k );
- set32_fx( hHQ_core->oldOut_fx, 0, L_FRAME48k );
- set32_fx( hHQ_core->old_outLB_fx, 0, L_FRAME32k );
+ set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME32k );
hHQ_core->Q_old_wtda = 15;
hHQ_core->Q_old_postdec = 0;
hHQ_core->Q_old_wtda_LB = 0;
move16();
move16();
move16();
- move16();
- move16();
hHQ_core->last_hq_core_type = -1; /* Q0 */
move16();
diff --git a/lib_dec/hq_env_dec.c b/lib_dec/hq_env_dec.c
deleted file mode 100644
index d029c2fa8ff7ca387884c05ac7f0cdc99d30c61d..0000000000000000000000000000000000000000
--- a/lib_dec/hq_env_dec.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 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.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include