diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d296ff540b02f53c1e71ce3e2db9d16ff70b29fb..0c4ea050f74da0f1db8426534b3fbfe6e05461d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,9 +49,9 @@ variables: FAILED_TESTCASES_LIST: "failed-testcases.txt" ERRORS_TESTCASES_LIST: "errors-testcases.txt" PYTEST_CACHE_ARTIFACT: "pytest_cache.zip" - FLOAT_REF_COMMIT_FILE: "float-ref-git-sha" - CUT_COMMIT_FILE: "CuT-git-sha" - MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha" + FLOAT_REF_COMMIT_FILE: "float-ref-git-sha.txt" + CUT_COMMIT_FILE: "CuT-git-sha.txt" + MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha.txt" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -221,7 +221,7 @@ stages: - git pull origin $FLOAT_REF_BRANCH - *activate-debug-mode-info-if-set - make clean - - make -j + - make -j >> /dev/null - mv ./IVAS_cod ./$REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_dec ./$REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_rend ./IVAS_rend_ref @@ -237,7 +237,7 @@ stages: - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - *activate-debug-mode-info-if-set - make clean - - make -j + - make -j >> /dev/null - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_rend ./IVAS_rend_merge_target @@ -252,7 +252,7 @@ stages: ### build dut binaries - *activate-debug-mode-info-if-set - make clean - - make -j + - make -j >> /dev/null .build-and-create-float-ref-outputs: &build-and-create-float-ref-outputs - *build-float-ref-and-dut-binaries @@ -547,8 +547,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 @@ -660,7 +660,7 @@ stages: - *build-float-ref-binaries - *build-merge-target-binaries - make clean - - make -j + - make -j >> /dev/null - *check-up-to-date-in-comparison-jobs - exit_code_target=0 @@ -668,7 +668,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 @@ -787,13 +787,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 @@ -808,10 +811,10 @@ stages: - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - make clean - - make -j + - make -j >> /dev/null # 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 @@ -907,7 +910,7 @@ stages: - make_args="$make_args IGNORELIST=1" - fi - make clean - - make -j $make_args + - make -j $make_args >> /dev/null - testcase_timeout_arg="--testcase_timeout $TESTCASE_TIMEOUT_LTV_SANITIZERS" # disable per-testcase timeout for msan to evaluate what is going on that it takes so long - if [[ $CLANG_NUM = 1 ]]; then @@ -949,10 +952,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 @@ -1903,7 +1909,7 @@ coverage-test-on-main-scheduled: - *copy-ltv-files-to-testv-dir - *build-float-ref-binaries # Build DuT binaries with GCOV - - make clean + - make clean >> /dev/null - make GCOV=1 -j - cp IVAS_rend IVAS_rend_ref # Copy to ensure instrumented renderer is run in the first pytest call @@ -1963,7 +1969,7 @@ be-2-evs-26444: - *print-common-info - *update-scripts-repo - sed -i".bak" "s/\(#define EVS_FLOAT\)/\/\/\1/" lib_com/options.h - - make -j + - make -j >> /dev/null # copy over to never change the testvector dir - cp -r $EVS_BE_TEST_DIR_BASOP ./evs_be_test @@ -2027,7 +2033,7 @@ voip-be-on-merge-request: script: - *print-common-info - make clean - - make -j + - make -j >> /dev/null - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py @@ -2252,13 +2258,19 @@ ivas-pytest-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/apps/renderer.c b/apps/renderer.c index 480ed47fbaa28d3488934d657a69a96bf6e821aa..2a14e28112fff7f6554da1f6fb5e718149acc74a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -837,10 +837,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 ) || @@ -1009,7 +1007,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 ); @@ -1052,7 +1049,6 @@ int main( exit( -1 ); } -#endif /* === Configure === */ if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) { 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_util.c b/lib_com/basop_util.c index b7ee35ab3652df0a2c64aa61715c992dd4f96808..ec15e9769bde64635ccb2196c7ec7932c6d08e5d 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1062,6 +1062,414 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) return z; } +#ifdef DIV32_OPT_NEWTON +Word32 div_w_newton( Word32 num, Word32 den ); +/* +Table of 256 precalculated estimates to be used by the "div_w_newton" +function using the Newton/Raphson method. +Note: The first table value (for denominator near 0x40000000) is not fully +accurate and should not be used. +*/ +Word32 div_w_newton_lookup[256] = { + /* Precalculated rounded results for 0x40000000 / b with b in [0x40000000 ... 0x7FFFFFFF] */ + 0x7FFFFFFF, // 1.000000000000000 i=0 0.5 / 0.5+0/512 (b=0x40000000) + 0x7F807F80, // 0.996108949416342 i=1 0.5 / 0.5+1/512 (b=0x40400000) + 0x7F01FC07, // 0.992248062015504 i=2 0.5 / 0.5+2/512 (b=0x40800000) + 0x7E8472A8, // 0.988416988416988 i=3 0.5 / 0.5+3/512 (b=0x40C00000) + 0x7E07E07E, // 0.984615384615385 i=4 0.5 / 0.5+4/512 (b=0x41000000) + 0x7D8C42B2, // 0.980842911877395 i=5 0.5 / 0.5+5/512 (b=0x41400000) + 0x7D119679, // 0.977099236641221 i=6 0.5 / 0.5+6/512 (b=0x41800000) + 0x7C97D910, // 0.973384030418251 i=7 0.5 / 0.5+7/512 (b=0x41C00000) + 0x7C1F07C1, // 0.969696969696970 i=8 0.5 / 0.5+8/512 (b=0x42000000) + 0x7BA71FE1, // 0.966037735849057 i=9 0.5 / 0.5+9/512 (b=0x42400000) + 0x7B301ECC, // 0.962406015037594 i=10 0.5 / 0.5+10/512 (b=0x42800000) + 0x7ABA01EA, // 0.958801498127341 i=11 0.5 / 0.5+11/512 (b=0x42C00000) + 0x7A44C6AF, // 0.955223880597015 i=12 0.5 / 0.5+12/512 (b=0x43000000) + 0x79D06A96, // 0.951672862453532 i=13 0.5 / 0.5+13/512 (b=0x43400000) + 0x795CEB24, // 0.948148148148148 i=14 0.5 / 0.5+14/512 (b=0x43800000) + 0x78EA45E7, // 0.944649446494465 i=15 0.5 / 0.5+15/512 (b=0x43C00000) + 0x78787878, // 0.941176470588235 i=16 0.5 / 0.5+16/512 (b=0x44000000) + 0x78078078, // 0.937728937728938 i=17 0.5 / 0.5+17/512 (b=0x44400000) + 0x77975B8F, // 0.934306569343066 i=18 0.5 / 0.5+18/512 (b=0x44800000) + 0x77280772, // 0.930909090909091 i=19 0.5 / 0.5+19/512 (b=0x44C00000) + 0x76B981DA, // 0.927536231884058 i=20 0.5 / 0.5+20/512 (b=0x45000000) + 0x764BC88C, // 0.924187725631769 i=21 0.5 / 0.5+21/512 (b=0x45400000) + 0x75DED952, // 0.920863309352518 i=22 0.5 / 0.5+22/512 (b=0x45800000) + 0x7572B201, // 0.917562724014337 i=23 0.5 / 0.5+23/512 (b=0x45C00000) + 0x75075075, // 0.914285714285714 i=24 0.5 / 0.5+24/512 (b=0x46000000) + 0x749CB28F, // 0.911032028469751 i=25 0.5 / 0.5+25/512 (b=0x46400000) + 0x7432D63D, // 0.907801418439716 i=26 0.5 / 0.5+26/512 (b=0x46800000) + 0x73C9B971, // 0.904593639575972 i=27 0.5 / 0.5+27/512 (b=0x46C00000) + 0x73615A24, // 0.901408450704225 i=28 0.5 / 0.5+28/512 (b=0x47000000) + 0x72F9B658, // 0.898245614035088 i=29 0.5 / 0.5+29/512 (b=0x47400000) + 0x7292CC15, // 0.895104895104895 i=30 0.5 / 0.5+30/512 (b=0x47800000) + 0x722C996B, // 0.891986062717770 i=31 0.5 / 0.5+31/512 (b=0x47C00000) + 0x71C71C71, // 0.888888888888889 i=32 0.5 / 0.5+32/512 (b=0x48000000) + 0x71625344, // 0.885813148788927 i=33 0.5 / 0.5+33/512 (b=0x48400000) + 0x70FE3C07, // 0.882758620689655 i=34 0.5 / 0.5+34/512 (b=0x48800000) + 0x709AD4E4, // 0.879725085910653 i=35 0.5 / 0.5+35/512 (b=0x48C00000) + 0x70381C0E, // 0.876712328767123 i=36 0.5 / 0.5+36/512 (b=0x49000000) + 0x6FD60FBA, // 0.873720136518771 i=37 0.5 / 0.5+37/512 (b=0x49400000) + 0x6F74AE26, // 0.870748299319728 i=38 0.5 / 0.5+38/512 (b=0x49800000) + 0x6F13F596, // 0.867796610169492 i=39 0.5 / 0.5+39/512 (b=0x49C00000) + 0x6EB3E453, // 0.864864864864865 i=40 0.5 / 0.5+40/512 (b=0x4A000000) + 0x6E5478AC, // 0.861952861952862 i=41 0.5 / 0.5+41/512 (b=0x4A400000) + 0x6DF5B0F7, // 0.859060402684564 i=42 0.5 / 0.5+42/512 (b=0x4A800000) + 0x6D978B8E, // 0.856187290969900 i=43 0.5 / 0.5+43/512 (b=0x4AC00000) + 0x6D3A06D3, // 0.853333333333333 i=44 0.5 / 0.5+44/512 (b=0x4B000000) + 0x6CDD212B, // 0.850498338870432 i=45 0.5 / 0.5+45/512 (b=0x4B400000) + 0x6C80D901, // 0.847682119205298 i=46 0.5 / 0.5+46/512 (b=0x4B800000) + 0x6C252CC7, // 0.844884488448845 i=47 0.5 / 0.5+47/512 (b=0x4BC00000) + 0x6BCA1AF2, // 0.842105263157895 i=48 0.5 / 0.5+48/512 (b=0x4C000000) + 0x6B6FA1FE, // 0.839344262295082 i=49 0.5 / 0.5+49/512 (b=0x4C400000) + 0x6B15C06B, // 0.836601307189543 i=50 0.5 / 0.5+50/512 (b=0x4C800000) + 0x6ABC74BE, // 0.833876221498371 i=51 0.5 / 0.5+51/512 (b=0x4CC00000) + 0x6A63BD81, // 0.831168831168831 i=52 0.5 / 0.5+52/512 (b=0x4D000000) + 0x6A0B9944, // 0.828478964401295 i=53 0.5 / 0.5+53/512 (b=0x4D400000) + 0x69B4069B, // 0.825806451612903 i=54 0.5 / 0.5+54/512 (b=0x4D800000) + 0x695D041D, // 0.823151125401929 i=55 0.5 / 0.5+55/512 (b=0x4DC00000) + 0x69069069, // 0.820512820512820 i=56 0.5 / 0.5+56/512 (b=0x4E000000) + 0x68B0AA1F, // 0.817891373801917 i=57 0.5 / 0.5+57/512 (b=0x4E400000) + 0x685B4FE5, // 0.815286624203822 i=58 0.5 / 0.5+58/512 (b=0x4E800000) + 0x68068068, // 0.812698412698413 i=59 0.5 / 0.5+59/512 (b=0x4EC00000) + 0x67B23A54, // 0.810126582278481 i=60 0.5 / 0.5+60/512 (b=0x4F000000) + 0x675E7C5D, // 0.807570977917981 i=61 0.5 / 0.5+61/512 (b=0x4F400000) + 0x670B453B, // 0.805031446540881 i=62 0.5 / 0.5+62/512 (b=0x4F800000) + 0x66B893A9, // 0.802507836990596 i=63 0.5 / 0.5+63/512 (b=0x4FC00000) + 0x66666666, // 0.800000000000000 i=64 0.5 / 0.5+64/512 (b=0x50000000) + 0x6614BC36, // 0.797507788161994 i=65 0.5 / 0.5+65/512 (b=0x50400000) + 0x65C393E0, // 0.795031055900621 i=66 0.5 / 0.5+66/512 (b=0x50800000) + 0x6572EC2F, // 0.792569659442725 i=67 0.5 / 0.5+67/512 (b=0x50C00000) + 0x6522C3F3, // 0.790123456790123 i=68 0.5 / 0.5+68/512 (b=0x51000000) + 0x64D319FE, // 0.787692307692308 i=69 0.5 / 0.5+69/512 (b=0x51400000) + 0x6483ED27, // 0.785276073619632 i=70 0.5 / 0.5+70/512 (b=0x51800000) + 0x64353C48, // 0.782874617737003 i=71 0.5 / 0.5+71/512 (b=0x51C00000) + 0x63E7063E, // 0.780487804878049 i=72 0.5 / 0.5+72/512 (b=0x52000000) + 0x639949EB, // 0.778115501519757 i=73 0.5 / 0.5+73/512 (b=0x52400000) + 0x634C0634, // 0.775757575757576 i=74 0.5 / 0.5+74/512 (b=0x52800000) + 0x62FF3A01, // 0.773413897280967 i=75 0.5 / 0.5+75/512 (b=0x52C00000) + 0x62B2E43D, // 0.771084337349398 i=76 0.5 / 0.5+76/512 (b=0x53000000) + 0x626703D8, // 0.768768768768769 i=77 0.5 / 0.5+77/512 (b=0x53400000) + 0x621B97C2, // 0.766467065868264 i=78 0.5 / 0.5+78/512 (b=0x53800000) + 0x61D09EF3, // 0.764179104477612 i=79 0.5 / 0.5+79/512 (b=0x53C00000) + 0x61861861, // 0.761904761904762 i=80 0.5 / 0.5+80/512 (b=0x54000000) + 0x613C0309, // 0.759643916913947 i=81 0.5 / 0.5+81/512 (b=0x54400000) + 0x60F25DEA, // 0.757396449704142 i=82 0.5 / 0.5+82/512 (b=0x54800000) + 0x60A92806, // 0.755162241887906 i=83 0.5 / 0.5+83/512 (b=0x54C00000) + 0x60606060, // 0.752941176470588 i=84 0.5 / 0.5+84/512 (b=0x55000000) + 0x60180601, // 0.750733137829912 i=85 0.5 / 0.5+85/512 (b=0x55400000) + 0x5FD017F4, // 0.748538011695906 i=86 0.5 / 0.5+86/512 (b=0x55800000) + 0x5F889545, // 0.746355685131195 i=87 0.5 / 0.5+87/512 (b=0x55C00000) + 0x5F417D05, // 0.744186046511628 i=88 0.5 / 0.5+88/512 (b=0x56000000) + 0x5EFACE48, // 0.742028985507246 i=89 0.5 / 0.5+89/512 (b=0x56400000) + 0x5EB48823, // 0.739884393063584 i=90 0.5 / 0.5+90/512 (b=0x56800000) + 0x5E6EA9AE, // 0.737752161383285 i=91 0.5 / 0.5+91/512 (b=0x56C00000) + 0x5E293205, // 0.735632183908046 i=92 0.5 / 0.5+92/512 (b=0x57000000) + 0x5DE42046, // 0.733524355300860 i=93 0.5 / 0.5+93/512 (b=0x57400000) + 0x5D9F7390, // 0.731428571428571 i=94 0.5 / 0.5+94/512 (b=0x57800000) + 0x5D5B2B08, // 0.729344729344729 i=95 0.5 / 0.5+95/512 (b=0x57C00000) + 0x5D1745D1, // 0.727272727272727 i=96 0.5 / 0.5+96/512 (b=0x58000000) + 0x5CD3C315, // 0.725212464589235 i=97 0.5 / 0.5+97/512 (b=0x58400000) + 0x5C90A1FD, // 0.723163841807910 i=98 0.5 / 0.5+98/512 (b=0x58800000) + 0x5C4DE1B6, // 0.721126760563380 i=99 0.5 / 0.5+99/512 (b=0x58C00000) + 0x5C0B8170, // 0.719101123595506 i=100 0.5 / 0.5+100/512 (b=0x59000000) + 0x5BC9805B, // 0.717086834733894 i=101 0.5 / 0.5+101/512 (b=0x59400000) + 0x5B87DDAD, // 0.715083798882682 i=102 0.5 / 0.5+102/512 (b=0x59800000) + 0x5B46989A, // 0.713091922005571 i=103 0.5 / 0.5+103/512 (b=0x59C00000) + 0x5B05B05B, // 0.711111111111111 i=104 0.5 / 0.5+104/512 (b=0x5A000000) + 0x5AC5242A, // 0.709141274238227 i=105 0.5 / 0.5+105/512 (b=0x5A400000) + 0x5A84F345, // 0.707182320441989 i=106 0.5 / 0.5+106/512 (b=0x5A800000) + 0x5A451CEA, // 0.705234159779614 i=107 0.5 / 0.5+107/512 (b=0x5AC00000) + 0x5A05A05A, // 0.703296703296703 i=108 0.5 / 0.5+108/512 (b=0x5B000000) + 0x59C67CD8, // 0.701369863013699 i=109 0.5 / 0.5+109/512 (b=0x5B400000) + 0x5987B1A9, // 0.699453551912568 i=110 0.5 / 0.5+110/512 (b=0x5B800000) + 0x59493E14, // 0.697547683923706 i=111 0.5 / 0.5+111/512 (b=0x5BC00000) + 0x590B2164, // 0.695652173913043 i=112 0.5 / 0.5+112/512 (b=0x5C000000) + 0x58CD5AE2, // 0.693766937669377 i=113 0.5 / 0.5+113/512 (b=0x5C400000) + 0x588FE9DC, // 0.691891891891892 i=114 0.5 / 0.5+114/512 (b=0x5C800000) + 0x5852CDA0, // 0.690026954177898 i=115 0.5 / 0.5+115/512 (b=0x5CC00000) + 0x58160581, // 0.688172043010753 i=116 0.5 / 0.5+116/512 (b=0x5D000000) + 0x57D990D0, // 0.686327077747989 i=117 0.5 / 0.5+117/512 (b=0x5D400000) + 0x579D6EE3, // 0.684491978609626 i=118 0.5 / 0.5+118/512 (b=0x5D800000) + 0x57619F0F, // 0.682666666666667 i=119 0.5 / 0.5+119/512 (b=0x5DC00000) + 0x572620AE, // 0.680851063829787 i=120 0.5 / 0.5+120/512 (b=0x5E000000) + 0x56EAF319, // 0.679045092838196 i=121 0.5 / 0.5+121/512 (b=0x5E400000) + 0x56B015AC, // 0.677248677248677 i=122 0.5 / 0.5+122/512 (b=0x5E800000) + 0x567587C4, // 0.675461741424802 i=123 0.5 / 0.5+123/512 (b=0x5EC00000) + 0x563B48C2, // 0.673684210526316 i=124 0.5 / 0.5+124/512 (b=0x5F000000) + 0x56015805, // 0.671916010498688 i=125 0.5 / 0.5+125/512 (b=0x5F400000) + 0x55C7B4F1, // 0.670157068062827 i=126 0.5 / 0.5+126/512 (b=0x5F800000) + 0x558E5EE9, // 0.668407310704961 i=127 0.5 / 0.5+127/512 (b=0x5FC00000) + 0x55555555, // 0.666666666666667 i=128 0.5 / 0.5+128/512 (b=0x60000000) + 0x551C979A, // 0.664935064935065 i=129 0.5 / 0.5+129/512 (b=0x60400000) + 0x54E42523, // 0.663212435233161 i=130 0.5 / 0.5+130/512 (b=0x60800000) + 0x54ABFD5A, // 0.661498708010336 i=131 0.5 / 0.5+131/512 (b=0x60C00000) + 0x54741FAB, // 0.659793814432990 i=132 0.5 / 0.5+132/512 (b=0x61000000) + 0x543C8B84, // 0.658097686375321 i=133 0.5 / 0.5+133/512 (b=0x61400000) + 0x54054054, // 0.656410256410256 i=134 0.5 / 0.5+134/512 (b=0x61800000) + 0x53CE3D8B, // 0.654731457800512 i=135 0.5 / 0.5+135/512 (b=0x61C00000) + 0x5397829C, // 0.653061224489796 i=136 0.5 / 0.5+136/512 (b=0x62000000) + 0x53610EFB, // 0.651399491094148 i=137 0.5 / 0.5+137/512 (b=0x62400000) + 0x532AE21C, // 0.649746192893401 i=138 0.5 / 0.5+138/512 (b=0x62800000) + 0x52F4FB76, // 0.648101265822785 i=139 0.5 / 0.5+139/512 (b=0x62C00000) + 0x52BF5A81, // 0.646464646464647 i=140 0.5 / 0.5+140/512 (b=0x63000000) + 0x5289FEB5, // 0.644836272040302 i=141 0.5 / 0.5+141/512 (b=0x63400000) + 0x5254E78E, // 0.643216080402010 i=142 0.5 / 0.5+142/512 (b=0x63800000) + 0x52201488, // 0.641604010025063 i=143 0.5 / 0.5+143/512 (b=0x63C00000) + 0x51EB851E, // 0.640000000000000 i=144 0.5 / 0.5+144/512 (b=0x64000000) + 0x51B738D1, // 0.638403990024938 i=145 0.5 / 0.5+145/512 (b=0x64400000) + 0x51832F1F, // 0.636815920398010 i=146 0.5 / 0.5+146/512 (b=0x64800000) + 0x514F678B, // 0.635235732009926 i=147 0.5 / 0.5+147/512 (b=0x64C00000) + 0x511BE195, // 0.633663366336634 i=148 0.5 / 0.5+148/512 (b=0x65000000) + 0x50E89CC2, // 0.632098765432099 i=149 0.5 / 0.5+149/512 (b=0x65400000) + 0x50B59897, // 0.630541871921182 i=150 0.5 / 0.5+150/512 (b=0x65800000) + 0x5082D499, // 0.628992628992629 i=151 0.5 / 0.5+151/512 (b=0x65C00000) + 0x50505050, // 0.627450980392157 i=152 0.5 / 0.5+152/512 (b=0x66000000) + 0x501E0B44, // 0.625916870415648 i=153 0.5 / 0.5+153/512 (b=0x66400000) + 0x4FEC04FE, // 0.624390243902439 i=154 0.5 / 0.5+154/512 (b=0x66800000) + 0x4FBA3D0A, // 0.622871046228710 i=155 0.5 / 0.5+155/512 (b=0x66C00000) + 0x4F88B2F3, // 0.621359223300971 i=156 0.5 / 0.5+156/512 (b=0x67000000) + 0x4F576646, // 0.619854721549637 i=157 0.5 / 0.5+157/512 (b=0x67400000) + 0x4F265691, // 0.618357487922705 i=158 0.5 / 0.5+158/512 (b=0x67800000) + 0x4EF58364, // 0.616867469879518 i=159 0.5 / 0.5+159/512 (b=0x67C00000) + 0x4EC4EC4E, // 0.615384615384615 i=160 0.5 / 0.5+160/512 (b=0x68000000) + 0x4E9490E1, // 0.613908872901679 i=161 0.5 / 0.5+161/512 (b=0x68400000) + 0x4E6470B0, // 0.612440191387560 i=162 0.5 / 0.5+162/512 (b=0x68800000) + 0x4E348B4D, // 0.610978520286396 i=163 0.5 / 0.5+163/512 (b=0x68C00000) + 0x4E04E04E, // 0.609523809523810 i=164 0.5 / 0.5+164/512 (b=0x69000000) + 0x4DD56F47, // 0.608076009501188 i=165 0.5 / 0.5+165/512 (b=0x69400000) + 0x4DA637CF, // 0.606635071090047 i=166 0.5 / 0.5+166/512 (b=0x69800000) + 0x4D77397E, // 0.605200945626478 i=167 0.5 / 0.5+167/512 (b=0x69C00000) + 0x4D4873EC, // 0.603773584905660 i=168 0.5 / 0.5+168/512 (b=0x6A000000) + 0x4D19E6B3, // 0.602352941176471 i=169 0.5 / 0.5+169/512 (b=0x6A400000) + 0x4CEB916D, // 0.600938967136150 i=170 0.5 / 0.5+170/512 (b=0x6A800000) + 0x4CBD73B5, // 0.599531615925059 i=171 0.5 / 0.5+171/512 (b=0x6AC00000) + 0x4C8F8D28, // 0.598130841121495 i=172 0.5 / 0.5+172/512 (b=0x6B000000) + 0x4C61DD63, // 0.596736596736597 i=173 0.5 / 0.5+173/512 (b=0x6B400000) + 0x4C346404, // 0.595348837209302 i=174 0.5 / 0.5+174/512 (b=0x6B800000) + 0x4C0720AB, // 0.593967517401392 i=175 0.5 / 0.5+175/512 (b=0x6BC00000) + 0x4BDA12F6, // 0.592592592592593 i=176 0.5 / 0.5+176/512 (b=0x6C000000) + 0x4BAD3A87, // 0.591224018475751 i=177 0.5 / 0.5+177/512 (b=0x6C400000) + 0x4B809701, // 0.589861751152074 i=178 0.5 / 0.5+178/512 (b=0x6C800000) + 0x4B542804, // 0.588505747126437 i=179 0.5 / 0.5+179/512 (b=0x6CC00000) + 0x4B27ED36, // 0.587155963302752 i=180 0.5 / 0.5+180/512 (b=0x6D000000) + 0x4AFBE639, // 0.585812356979405 i=181 0.5 / 0.5+181/512 (b=0x6D400000) + 0x4AD012B4, // 0.584474885844749 i=182 0.5 / 0.5+182/512 (b=0x6D800000) + 0x4AA4724B, // 0.583143507972665 i=183 0.5 / 0.5+183/512 (b=0x6DC00000) + 0x4A7904A7, // 0.581818181818182 i=184 0.5 / 0.5+184/512 (b=0x6E000000) + 0x4A4DC96E, // 0.580498866213152 i=185 0.5 / 0.5+185/512 (b=0x6E400000) + 0x4A22C04A, // 0.579185520361991 i=186 0.5 / 0.5+186/512 (b=0x6E800000) + 0x49F7E8E2, // 0.577878103837472 i=187 0.5 / 0.5+187/512 (b=0x6EC00000) + 0x49CD42E2, // 0.576576576576577 i=188 0.5 / 0.5+188/512 (b=0x6F000000) + 0x49A2CDF3, // 0.575280898876405 i=189 0.5 / 0.5+189/512 (b=0x6F400000) + 0x497889C2, // 0.573991031390135 i=190 0.5 / 0.5+190/512 (b=0x6F800000) + 0x494E75FA, // 0.572706935123042 i=191 0.5 / 0.5+191/512 (b=0x6FC00000) + 0x49249249, // 0.571428571428571 i=192 0.5 / 0.5+192/512 (b=0x70000000) + 0x48FADE5C, // 0.570155902004454 i=193 0.5 / 0.5+193/512 (b=0x70400000) + 0x48D159E2, // 0.568888888888889 i=194 0.5 / 0.5+194/512 (b=0x70800000) + 0x48A8048A, // 0.567627494456763 i=195 0.5 / 0.5+195/512 (b=0x70C00000) + 0x487EDE04, // 0.566371681415929 i=196 0.5 / 0.5+196/512 (b=0x71000000) + 0x4855E601, // 0.565121412803532 i=197 0.5 / 0.5+197/512 (b=0x71400000) + 0x482D1C31, // 0.563876651982379 i=198 0.5 / 0.5+198/512 (b=0x71800000) + 0x48048048, // 0.562637362637363 i=199 0.5 / 0.5+199/512 (b=0x71C00000) + 0x47DC11F7, // 0.561403508771930 i=200 0.5 / 0.5+200/512 (b=0x72000000) + 0x47B3D0F1, // 0.560175054704595 i=201 0.5 / 0.5+201/512 (b=0x72400000) + 0x478BBCEC, // 0.558951965065502 i=202 0.5 / 0.5+202/512 (b=0x72800000) + 0x4763D59C, // 0.557734204793028 i=203 0.5 / 0.5+203/512 (b=0x72C00000) + 0x473C1AB6, // 0.556521739130435 i=204 0.5 / 0.5+204/512 (b=0x73000000) + 0x47148BF0, // 0.555314533622560 i=205 0.5 / 0.5+205/512 (b=0x73400000) + 0x46ED2901, // 0.554112554112554 i=206 0.5 / 0.5+206/512 (b=0x73800000) + 0x46C5F19F, // 0.552915766738661 i=207 0.5 / 0.5+207/512 (b=0x73C00000) + 0x469EE584, // 0.551724137931034 i=208 0.5 / 0.5+208/512 (b=0x74000000) + 0x46780467, // 0.550537634408602 i=209 0.5 / 0.5+209/512 (b=0x74400000) + 0x46514E02, // 0.549356223175966 i=210 0.5 / 0.5+210/512 (b=0x74800000) + 0x462AC20E, // 0.548179871520343 i=211 0.5 / 0.5+211/512 (b=0x74C00000) + 0x46046046, // 0.547008547008547 i=212 0.5 / 0.5+212/512 (b=0x75000000) + 0x45DE2864, // 0.545842217484009 i=213 0.5 / 0.5+213/512 (b=0x75400000) + 0x45B81A25, // 0.544680851063830 i=214 0.5 / 0.5+214/512 (b=0x75800000) + 0x45923543, // 0.543524416135881 i=215 0.5 / 0.5+215/512 (b=0x75C00000) + 0x456C797D, // 0.542372881355932 i=216 0.5 / 0.5+216/512 (b=0x76000000) + 0x4546E68F, // 0.541226215644820 i=217 0.5 / 0.5+217/512 (b=0x76400000) + 0x45217C38, // 0.540084388185654 i=218 0.5 / 0.5+218/512 (b=0x76800000) + 0x44FC3A34, // 0.538947368421053 i=219 0.5 / 0.5+219/512 (b=0x76C00000) + 0x44D72044, // 0.537815126050420 i=220 0.5 / 0.5+220/512 (b=0x77000000) + 0x44B22E27, // 0.536687631027254 i=221 0.5 / 0.5+221/512 (b=0x77400000) + 0x448D639D, // 0.535564853556485 i=222 0.5 / 0.5+222/512 (b=0x77800000) + 0x4468C066, // 0.534446764091858 i=223 0.5 / 0.5+223/512 (b=0x77C00000) + 0x44444444, // 0.533333333333333 i=224 0.5 / 0.5+224/512 (b=0x78000000) + 0x441FEEF8, // 0.532224532224532 i=225 0.5 / 0.5+225/512 (b=0x78400000) + 0x43FBC043, // 0.531120331950207 i=226 0.5 / 0.5+226/512 (b=0x78800000) + 0x43D7B7EA, // 0.530020703933747 i=227 0.5 / 0.5+227/512 (b=0x78C00000) + 0x43B3D5AF, // 0.528925619834711 i=228 0.5 / 0.5+228/512 (b=0x79000000) + 0x43901956, // 0.527835051546392 i=229 0.5 / 0.5+229/512 (b=0x79400000) + 0x436C82A2, // 0.526748971193416 i=230 0.5 / 0.5+230/512 (b=0x79800000) + 0x43491158, // 0.525667351129363 i=231 0.5 / 0.5+231/512 (b=0x79C00000) + 0x4325C53E, // 0.524590163934426 i=232 0.5 / 0.5+232/512 (b=0x7A000000) + 0x43029E1A, // 0.523517382413088 i=233 0.5 / 0.5+233/512 (b=0x7A400000) + 0x42DF9BB0, // 0.522448979591837 i=234 0.5 / 0.5+234/512 (b=0x7A800000) + 0x42BCBDC8, // 0.521384928716904 i=235 0.5 / 0.5+235/512 (b=0x7AC00000) + 0x429A0429, // 0.520325203252033 i=236 0.5 / 0.5+236/512 (b=0x7B000000) + 0x42776E9A, // 0.519269776876268 i=237 0.5 / 0.5+237/512 (b=0x7B400000) + 0x4254FCE4, // 0.518218623481781 i=238 0.5 / 0.5+238/512 (b=0x7B800000) + 0x4232AECD, // 0.517171717171717 i=239 0.5 / 0.5+239/512 (b=0x7BC00000) + 0x42108421, // 0.516129032258065 i=240 0.5 / 0.5+240/512 (b=0x7C000000) + 0x41EE7CA6, // 0.515090543259557 i=241 0.5 / 0.5+241/512 (b=0x7C400000) + 0x41CC9829, // 0.514056224899598 i=242 0.5 / 0.5+242/512 (b=0x7C800000) + 0x41AAD671, // 0.513026052104208 i=243 0.5 / 0.5+243/512 (b=0x7CC00000) + 0x4189374B, // 0.512000000000000 i=244 0.5 / 0.5+244/512 (b=0x7D000000) + 0x4167BA81, // 0.510978043912176 i=245 0.5 / 0.5+245/512 (b=0x7D400000) + 0x41465FDF, // 0.509960159362550 i=246 0.5 / 0.5+246/512 (b=0x7D800000) + 0x41252730, // 0.508946322067594 i=247 0.5 / 0.5+247/512 (b=0x7DC00000) + 0x41041041, // 0.507936507936508 i=248 0.5 / 0.5+248/512 (b=0x7E000000) + 0x40E31ADE, // 0.506930693069307 i=249 0.5 / 0.5+249/512 (b=0x7E400000) + 0x40C246D4, // 0.505928853754941 i=250 0.5 / 0.5+250/512 (b=0x7E800000) + 0x40A193F1, // 0.504930966469428 i=251 0.5 / 0.5+251/512 (b=0x7EC00000) + 0x40810204, // 0.503937007874016 i=252 0.5 / 0.5+252/512 (b=0x7F000000) + 0x406090D9, // 0.502946954813359 i=253 0.5 / 0.5+253/512 (b=0x7F400000) + 0x40404040, // 0.501960784313725 i=254 0.5 / 0.5+254/512 (b=0x7F800000) + 0x40201008 // 0.500978473581213 i=255 0.5 / 0.5+255/512 (b=0x7FC00000) +}; + + +/* + * Fractional multiplication of signed a and b, both in Q31. The result is doubled. + * Note: in this test, saturation is not needed. + * BASOP weights: 3 + */ + +static Word32 L_dmult( Word32 L_var1, Word32 L_var2 ) +{ + Word64 L64_var1 = W_mult0_32_32( L_var1, L_var2 ); + L64_var1 = W_shr( L64_var1, 30 ); + return W_extract_l( L64_var1 ); +} + +/* + * 32 by 32 bit division, following the Newton / Raphson method. + * Usage of this low-level procedure by the caller: + * 1. Numerator can use the full range of signed 32-bit datatypes: 0x80000000...0x7FFFFFFF + * Note: Since is not normalized here, but it is multplied to the reciprocal of the + * denominator, the caller should use a normalized and handle any exponent outside. + * 2. Denominator must be normalized into range 0x40000001 to 0x7FFFFFFF (all positive) + * Note: In case of den=0x40000000, the caller is not allowed to call the division routine, + since the result is known. + * Note: num / 0x40000000 equals to num with exp += 1. + * 3. The result is in range 0x40000000 to 0x7FFFFFFF, finally multiplied by . + * BASOP weights: 24 (incl. L_dmult) + */ + +Word32 div_w_newton( Word32 num, Word32 den ) +{ + Word32 x0, x1, x2, x3, diff, result; + + x0 = div_w_newton_lookup[sub( extract_l( L_shr( den, 22 ) ), 256 )]; + move32(); + + diff = L_sub( 0x40000000, Mpy_32_32( den, x0 ) ); + + x1 = L_add( x0, L_dmult( x0, diff ) ); + diff = L_sub( 0x40000000, Mpy_32_32( den, x1 ) ); + + x2 = L_add( x1, L_dmult( x1, diff ) ); + diff = L_sub( 0x40000000, Mpy_32_32( den, x2 ) ); + + x3 = L_add( x2, L_dmult( x2, diff ) ); + + result = Mpy_32_32( num, x3 ); + + return result; +} + +/* + * 32 / 32 division + * Usage of this global procedure by the caller: + * 1. Numerator can use the full range of signed 32-bit datatypes: 0x80000000...0x7FFFFFFF + * Note: Since is not normalized here, but it is multplied to the reciprocal of the + * denominator, the caller should use a normalized and handle any exponent outside. + * 2. Denominator can use the full range of signed 32-bit datatypes: 0x80000000...0x7FFFFFFF + * except den=0x00000000. In case of 0x80000000, it becomes internally negated to 0x7FFFFFFF. + * 3. The result is 0x00000000 (*s=0)for equals 0x00000000. + * The result is rather left aligned, with up to 1 bit headroom. + * 4. The result exponent is stored in s[0] + * BASOP weights: 41 (incl. div_w_newton) + */ + +Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) +{ + Word32 z; + Word16 sx; + Word16 sy; + Word32 sign; + + assert( y != (Word32) 0 ); + + /* Early exit, if numerator is zero */ + IF( x == (Word32) 0 ) + { + *s = 0; + return ( (Word32) 0 ); + } + +#if 0 + sign = L_xor( x, y ); /* check (sign < 0) for result negation */ + + if ( x < 0 ) + { + x = L_negate( x ); + } +#else + IF( EQ_32( y, 0x80000000 ) ) + { + /* Division by -1.0: same as negation of numerator */ + /* Return normalized negated numerator */ + sx = norm_l( x ); + x = L_shl( x, sx ); + *s = negate( sx ); + return L_negate( x ); + } + sign = y; + move32(); +#endif + if ( y < 0 ) + { + y = L_negate( y ); + } + + /* Normalize numerator */ + sx = norm_l( x ); + x = L_shl( x, sx ); + + /* Normalize denominator */ + sy = norm_l( y ); + y = L_shl( y, sy ); + + /* Store exponent: + 1 for div_w_newton computing 0.5*num/den */ + *s = sub( add( sy, 1 ), sx ); + move16(); + + /* Special treatment for den=0x40000000 */ + /* Result is known: z=2*num */ + IF( EQ_32( y, 0x40000000 ) ) + { + if ( sign < 0 ) + { + x = L_negate( x ); + } + return x; + } + + /* Invoke division applying Newton/Raphson-Algorithm */ + z = div_w_newton( x, y ); + + if ( sign < 0 ) + { + z = L_negate( z ); + } + + return z; +} +#endif /* DIV32_OPT_NEWTON */ + Word16 BASOP_Util_Divide3232_Scale( Word32 x, Word32 y, Word16 *s ) { Word16 z; diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index a6db7dc8d62ced0c28ff5010bf7ef9513eb04c5e..b1d4b5fc18da6e9657c30667fb42609b8b1980e3 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -333,6 +333,13 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ +#ifdef DIV32_OPT_NEWTON +Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, /*!< i : Numerator*/ + Word32 y, /*!< i : Denominator*/ + Word16 *s ); /*!< o : Additional scalefactor difference*/ +#endif + + /************************************************************************/ /*! \brief Binary logarithm with 7 iterations diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 88b276126a66e4b3aa9064e073b9cd8295264f27..8162a98d3fa3147ea128100fddad063e0f8cd18d 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -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(); diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 712a6905e67e78a5d38bc6406266f5d933fe86f3..07a6a632fc43a787473c42f94b849dda8c876540 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -240,11 +240,11 @@ Word16 rate2EVSmode( } /*-------------------------------------------------------------------* - * push_indice_fx( ) + * push_indice( ) * * Push a new indice into the buffer *-------------------------------------------------------------------*/ - +#ifndef HARM_PUSH_BIT void push_indice_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ Word16 id, /* i : ID of the indice */ @@ -288,9 +288,8 @@ void push_indice_fx( return; } - /*-------------------------------------------------------------------* - * push_next_indice_fx() * + * push_next_indice() * * Push a new indice into the buffer at the next position *-------------------------------------------------------------------*/ @@ -318,7 +317,7 @@ void push_next_indice_fx( /*-------------------------------------------------------------------* - * push_next_bits_fx() + * push_next_bits() * Push a bit buffer into the buffer at the next position *-------------------------------------------------------------------*/ @@ -368,6 +367,7 @@ void push_next_bits_fx( hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); move16(); } +#endif /*-------------------------------------------------------------------* * get_next_indice_fx( ) @@ -526,17 +526,16 @@ void reset_indices_enc_fx( { Word16 i; -#ifdef MSAN_FIX hBstr->nb_ind_tot = 0; move16(); -#endif hBstr->nb_bits_tot = 0; move16(); +#ifndef HARM_PUSH_BIT hBstr->next_ind_fx = 0; move16(); hBstr->last_ind_fx = -1; move16(); - +#endif FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; @@ -567,7 +566,7 @@ void reset_indices_dec_fx( * * Write the buffer of indices to a file *-------------------------------------------------------------------*/ - +#ifndef HARM_PUSH_BIT void write_indices_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ @@ -665,12 +664,13 @@ void write_indices_fx( return; } +#endif /*-------------------------------------------------------------------* * write_indices_buf_fx() * * Write the buffer of indices to a file *-------------------------------------------------------------------*/ - +#ifndef HARM_PUSH_BIT void write_indices_buf_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ @@ -774,6 +774,7 @@ void write_indices_buf_fx( return; } +#endif /*-------------------------------------------------------------------* * indices_to_serial() * diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index e1afa3da7687b852a41ef7a7bb59b6323926b1ea..d4a6d8ace63ae5b16928fcaa174771d58052fed4 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -398,18 +398,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(); } @@ -449,18 +459,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(); } @@ -489,8 +509,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(); } @@ -519,8 +544,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(); } @@ -541,8 +571,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(); @@ -1090,6 +1125,7 @@ void cldfbAnalysis_ts_fx_fixed_q( return; } + /*-------------------------------------------------------------------* * cldfbSynthesis_ivas() * @@ -1100,9 +1136,10 @@ void cldfbSynthesis_ivas_fx( 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 */ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - const Word16 shift, /* i : scale for state buffer */ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ + 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 */ ) { @@ -1268,10 +1305,8 @@ void cldfbSynthesis_ivas_fx( } /* synthesis prototype filter */ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( 0 == shift ) { -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ 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 @@ -1291,7 +1326,6 @@ void cldfbSynthesis_ivas_fx( synthesisBuffer_fx[4 * L2 + i] = accu4; move32(); } -#ifdef OPT_SBA_AVOID_SPAR_RESCALE } ELSE { @@ -1299,11 +1333,11 @@ void cldfbSynthesis_ivas_fx( 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 - accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx - 1 - accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx - 1 - accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx - 1 - accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx - 1 + 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(); @@ -1317,13 +1351,27 @@ void cldfbSynthesis_ivas_fx( move32(); } } -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ - 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; @@ -1338,7 +1386,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 */ diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index aa1ceea81f28f54461f025c6f652385f62e25fe1..b314357adee7954c8797853f405db0296b5df6ee 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -1165,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 1bcfcdb8f3fa23325597a599a71fc696b336cee1..e7e511e0dce2cd1b8fa73bfda1f606c6f34b287a 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -787,6 +787,9 @@ enum #define L_HP20_MEM 4 /* HP20 filter memory length */ #define CLDFB_NO_CHANNELS_MAX 60 /* CLDFB resampling - max number of CLDFB channels, == IVAS_CLDFB_NO_CHANNELS_MAX */ +#ifdef FIX_867_CLDFB_NRG_SCALE +#define CLDFB_NO_CHANNELS_HALF 30 /* CLDFB resampling - max number of CLDFB channels, == IVAS_CLDFB_NO_CHANNELS_MAX */ +#endif #define CLDFB_NO_CHANNELS_MAX_FX 30720 /*Q9*/ #define CLDFB_NO_COL_MAX 16 /* CLDFB resampling - max number of CLDFB col., == IVAS_CLDFB_NO_COL_MAX */ #define ONE_BY_CLDFB_NO_COL_MAX_Q31 134217728 @@ -935,9 +938,7 @@ 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 */ -#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD #define DTX_THR 5 /* DTX - lp_noise threshold for DTX at higher bitrates */ -#endif #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 */ diff --git a/lib_com/deemph.c b/lib_com/deemph.c index c03a050bca095711ea2e0c6a07e721aeb29e1dbf..9bc20cb6f6892b86fe023ff163fa8272ec9cc7bb 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -41,26 +41,23 @@ 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/disclaimer.c b/lib_com/disclaimer.c index 1a01c2c320d249726ccf142ca9a0390f2846ac24..3b16773657ca881ea1c5bf7c555638788ae9fca8 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -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 b1e2a7dd9b76719cec5ef06815655c249d617237..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; diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 7b63e9c679ce1219a018d92196ed50bc04861795..5ee5098797c3b57caf6c91e826bcc76dd1fdf850 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -7555,172 +7555,3 @@ void rfft_fx( return; } - -Word16 find_guarded_bits_fx( Word32 n ) -{ - // return n <= 1 ? 0 : n <= 2 ? 1 - // : n <= 4 ? 2 - // : n <= 8 ? 3 - // : n <= 16 ? 4 - // : n <= 32 ? 5 - // : n <= 64 ? 6 - // : n <= 128 ? 7 - // : n <= 256 ? 8 - // : n <= 512 ? 9 - // : n <= 1024 ? 10 - // : n <= 2048 ? 11 - // : n <= 4096 ? 12 - // : n <= 8192 ? 13 - // : n <= 16384 ? 14 - // : 15; - /*Word16 val = 0; - move32(); - test(); - WHILE( GT_32( n, L_shl( 1, val ) ) && LT_32( val, 16 ) ) - { - val = add( val, 1 ); - }*/ - IF( LE_32( n, 1 ) ) - { - return 0; - } - ELSE - { - - return sub( 31, norm_l( L_sub( n, 1 ) ) ); - } -} - -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; - - q_tst = norm_l( arr[i] ); - if ( arr[i] != 0 ) - { - q = s_min( q, q_tst ); - } - } - -#endif - return q; -} - -Word16 norm_arr( Word16 *arr, Word16 size ) -{ - Word16 q = 15; - Word16 exp = 0; - move16(); - move16(); - FOR( Word16 i = 0; i < size; i++ ) - { - if ( arr[i] != 0 ) - { - exp = norm_s( arr[i] ); - } - if ( arr[i] != 0 ) - { - q = s_min( q, exp ); - } - } - return q; -} - -Word16 W_norm_arr( Word64 *arr, Word16 size ) -{ - Word16 q = 63; - Word16 exp = 0; - move16(); - move16(); - FOR( Word16 i = 0; i < size; i++ ) - { - if ( arr[i] != 0 ) - { - exp = W_norm( arr[i] ); - } - if ( arr[i] != 0 ) - { - q = s_min( q, exp ); - } - } - return q; -} - -Word16 get_min_scalefactor( Word32 x, Word32 y ) -{ -#ifndef FIX_1104_OPT_GETMINSCALEFAC - Word16 scf = Q31; - move16(); - test(); - IF( x == 0 && y == 0 ) - { - return 0; - } - IF( x != 0 ) - { - scf = s_min( scf, norm_l( x ) ); - } - IF( y != 0 ) - { - scf = s_min( scf, norm_l( y ) ); - } - return scf; -#else - Word16 scf_y; - Word16 scf = Q31; - move16(); - - test(); - if ( x == 0 && y == 0 ) - { - scf = 0; - move16(); - } - - if ( x != 0 ) - { - scf = norm_l( x ); - } - - scf_y = norm_l( y ); - if ( y != 0 ) - { - scf = s_min( scf_y, scf ); - } - - return scf; -#endif -} - - -Flag is_zero_arr( Word32 *arr, Word16 size ) -{ - FOR( Word16 i = 0; i < size; i++ ) - IF( arr[i] != 0 ) - { - return 0; - } - - return 1; -} - -Flag is_zero_arr16( Word16 *arr, Word16 size ) -{ - FOR( Word16 i = 0; i < size; i++ ) - IF( arr[i] != 0 ) - { - return 0; - } - - return 1; -} diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 87ba794d46728dabaed82ef6287774aad7c09f14..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 diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 35236b6032acbd590fb57c68e3063ca671292c21..ecfe9aae0f28d32e24ac362414cc1f52f47b58b4 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1028,7 +1028,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ mean_4g[0] = round_fx( L_tmp ); move16(); idx_g = vquant_fx( mean_4g, Gain_meanNB_fx, mean_4g, Gain_mean_dicNB_fx, 1, 64 ); - push_indice_fx( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); + push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); FOR( i = 0; i < Mbands_gn; i++ ) { @@ -1040,21 +1040,21 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 ); idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); IF( LT_32( core_brate, ACELP_9k60 ) ) { idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); } ELSE { idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); } /*add end */ test(); @@ -1122,7 +1122,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); idx_g = vquant_fx( mean_4g, mean_m_fx, mean_4g, mean_gain_dic_fx, 1, 64 ); - push_indice_fx( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); + push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); FOR( i = 0; i < Mbands_gn; i++ ) { @@ -1148,11 +1148,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); /* Update to quantized vector */ @@ -1185,13 +1185,13 @@ Word16 gsc_gainQ_fx( /*Q12*/ ELSE { idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); - push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); } } 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/hq_tools_fx.c b/lib_com/hq_tools_fx.c index cf3ce202e0f0951c92b3610319cb5e7db95146b8..0e00b9428f61a9c68daa8f2a4da70847b4cc48dc 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -2036,7 +2036,7 @@ Word16 calc_nor_delta_hf_fx( /* updating norm & storing delta norm */ add_bits_denv = 2; move16(); - push_indice_fx( hBstr, IND_DELTA_ENV_HQ, sub( bitsforDelta, 2 ), 2 ); + push_indice( hBstr, IND_DELTA_ENV_HQ, sub( bitsforDelta, 2 ), 2 ); FOR( i = num_env_bands; i < nb_sfm; ++i ) { IF( Rsubband[i] != 0 ) @@ -2052,7 +2052,7 @@ Word16 calc_nor_delta_hf_fx( delta = min_delta; /*Q0*/ move16(); } - push_indice_fx( hBstr, IND_DELTA_ENV_HQ, delta - min_delta, bitsforDelta ); + push_indice( hBstr, IND_DELTA_ENV_HQ, delta - min_delta, bitsforDelta ); ynrm[i] = add( ynrm[i], delta ); /*Q0*/ move16(); add_bits_denv = add( add_bits_denv, bitsforDelta ); diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index fbccdb5191fe889c5aab51fa4dd2bc4c9a07c6ed..44cf27c5f3da77010f5d13489439a0dc2bc507c7 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1242,7 +1242,7 @@ void IGFCommonFuncsWriteSerialBit( IF( hBstr ) { - push_next_indice_fx( hBstr, bit, 1 ); + push_next_indice( hBstr, bit, 1 ); } *pBitOffset = add( *pBitOffset, 1 ); move16(); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 2abb790f1629a172b0dc5b3e82ac1e5fb82ce6ed..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 diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index 3a93ed1f577c0a8f2536607f5d25256674bd4f5c..9a8de3c1f055c1e3a119181c3c404a3a903242a7 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -42,6 +42,8 @@ *-----------------------------------------------------------------------------------------*/ #define BAND_SMOOTH_REST_START_IDX ( 2 ) +#define ONEeN20_Q97 0x5E728433 // 1e-20 in Q97 1.584.563.251 + /*-----------------------------------------------------------------------------------------* * Function ivas_calculate_update_factor_fx() @@ -87,9 +89,10 @@ static void ivas_calculate_smoothning_factor_fx( move16(); tmp = BASOP_Util_Divide3232_Scale( update_factor, L_shl( L_deposit_l( min_pool_size ), Q22 ), &exp_diff ); // Q(31 - exp_diff) - *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q16, exp_diff ) ); // Q31 + *Smoothing_factor = L_shl_sat( L_deposit_h( tmp ), exp_diff ); // Q31 move32(); + IF( NE_32( smooth_mode, COV_SMOOTH_MC ) ) { IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) @@ -264,19 +267,17 @@ void ivas_spar_covar_smooth_enc_close_fx( return; } - /*-----------------------------------------------------------------------------------------* * Function ivas_compute_smooth_cov_fx() * * Compute smooth covariance real/imag. *-----------------------------------------------------------------------------------------*/ - static void ivas_compute_smooth_cov_fx( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, Word32 *pCov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], // i/o: Q(q_cov[i][j]) Word32 *pPrior_cov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], // i: hCovState->q_cov_real_per_band[i][j][k] - const Word32 fac, + const Word32 fac, // i: ONEeN20_Q97 (1e-20 in Q97) const Word16 start_band, const Word16 end_band, const Word16 num_ch, @@ -285,10 +286,15 @@ static void ivas_compute_smooth_cov_fx( { Word16 i, j, k; Word16 prev_idx = hCovState->prior_bank_idx; - Word32 factor = 0, L_tmp, L_tmp1; + Word32 factor = 0, L_tmp0, L_tmp1; + + const Word16 q_fac = 97; + const Word16 fac_e = sub( Q31, q_fac ); + + Word16 cov_buf_e; + Word16 sm_b; Word16 non_sm_b_idx; - Word16 q_tmp[IVAS_MAX_NUM_BANDS]; sm_b = BAND_SMOOTH_REST_START_IDX; move16(); @@ -296,7 +302,6 @@ static void ivas_compute_smooth_cov_fx( move32(); assert( end_band <= pFb->filterbank_num_bands ); - test(); IF( EQ_16( prev_idx, -1 ) || EQ_16( transient_det[1], 1 ) ) { @@ -311,9 +316,11 @@ static void ivas_compute_smooth_cov_fx( { FOR( k = start_band; k < end_band; k++ ) { - L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31 - pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( hCovState->q_cov_real_per_band[i][i][k], Q31 ) ) ); // hCovState->q_cov_real_per_band[i][j][k] + /* ref: pCov_buf[i][i][k] += ( hCovState->pSmoothing_factor[k] * fac ); */ + pCov_buf[i][i][k] = BASOP_Util_Add_Mant32Exp( pCov_buf[i][i][k], sub( Q31, q_cov[i][i] ), Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ), fac_e, &cov_buf_e ); move32(); + hCovState->q_cov_real_per_band[i][i][k] = sub( Q31, cov_buf_e ); + move16(); } } } @@ -326,38 +333,45 @@ static void ivas_compute_smooth_cov_fx( { IF( EQ_16( i, j ) ) { - factor = fac; // Q31 + factor = fac; // Q97 move32(); } ELSE { - factor = 0; + factor = 0; // Q97 move32(); } - set16_fx( q_tmp, q_cov[i][j], sub( end_band, start_band ) ); FOR( k = start_band; k < non_sm_b_idx; k++ ) { - L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j]) -> q_cov[i][j] - L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, hCovState->q_cov_real_per_band[i][j][k]) -> hCovState->q_cov_real_per_band[i][j][k] - pCov_buf[i][j][k] = BASOP_Util_Add_Mant32Exp( L_tmp, sub( Q31, q_cov[i][j] ), L_tmp1, sub( Q31, hCovState->q_prior_cov_real_per_band[i][j][k] ), &q_tmp[k] ); // Q(31 - q_tmp[k]) + /* ref: pCov_buf[i][j][k] = pPrior_cov_buf[i][j][k] + ( hCovState->pSmoothing_factor[k] * ( pCov_buf[i][j][k] - pPrior_cov_buf[i][j][k] + factor ) ); */ + /* mod: pCov_buf[i][j][k] = pCov_buf[i][j][k] * hCovState->pSmoothing_factor[k] + + pPrior_cov_buf[i][j][k] * (1.0 - hCovState->pSmoothing_factor[k]) + + factor * hCovState->pSmoothing_factor[k] ); */ + L_tmp0 = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // q_tmp0: q_cov[i][j] // (Q31, q_cov[i][j]) -> q_cov[i][j] + L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // q_tmp1: hCovState->q_prior_cov_real_per_band[i][j][k] + L_tmp0 = BASOP_Util_Add_Mant32Exp( L_tmp0, sub( Q31, q_cov[i][j] ), L_tmp1, sub( Q31, hCovState->q_prior_cov_real_per_band[i][j][k] ), &cov_buf_e ); + pCov_buf[i][j][k] = BASOP_Util_Add_Mant32Exp( L_tmp0, cov_buf_e, Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), fac_e, &cov_buf_e ); move32(); - q_tmp[k] = sub( Q31, q_tmp[k] ); // Q of pConv_buf[i][j][k] is now q_tmp[k] + hCovState->q_cov_real_per_band[i][j][k] = sub( Q31, cov_buf_e ); // Q of pCov_buf[i][j][k] + move16(); + } + FOR( ; k < end_band; k++ ) + { + hCovState->q_cov_real_per_band[i][j][k] = q_cov[i][j]; move16(); - L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_tmp[k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_tmp[k] - pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp ); // q_tmp[k] - move32(); } - Copy( q_tmp, hCovState->q_cov_real_per_band[i][j], sub( end_band, start_band ) ); // Q of pCov_buf[i][j][k] is hCovState->q_cov_real_per_band[i][j][j] } } FOR( i = 0; i < num_ch; i++ ) { FOR( k = non_sm_b_idx; k < end_band; k++ ) { - L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31 - pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( hCovState->q_cov_real_per_band[i][i][k], Q31 ) ) ); // hCovState->q_cov_real_per_band[i][j][j] + /* ref: pCov_buf[i][i][k] += ( hCovState->pSmoothing_factor[k] * fac ); */ + pCov_buf[i][i][k] = BASOP_Util_Add_Mant32Exp( pCov_buf[i][i][k], sub( Q31, q_cov[i][i] ), Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ), fac_e, &cov_buf_e ); move32(); + hCovState->q_cov_real_per_band[i][i][k] = sub( Q31, cov_buf_e ); // Q of pCov_buf[i][i][k] + move16(); } } } @@ -369,28 +383,29 @@ static void ivas_compute_smooth_cov_fx( { IF( EQ_16( i, j ) ) { - factor = fac; // Q31 + factor = fac; // Q97 move32(); } ELSE { - factor = 0; + factor = 0; // Q97 move32(); } FOR( k = start_band; k < end_band; k++ ) { - L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j]) -> q_cov[i][j] - L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, hCovState->q_cov_real_per_band[i][j][k]) -> hCovState->q_cov_real_per_band[i][j][k] - pCov_buf[i][j][k] = BASOP_Util_Add_Mant32Exp( L_tmp, sub( Q31, q_cov[i][j] ), L_tmp1, sub( Q31, hCovState->q_prior_cov_real_per_band[i][j][k] ), &q_tmp[k] ); // Q(31 - q_tmp[k]) + /* ref: pCov_buf[i][j][k] = pPrior_cov_buf[i][j][k] + ( hCovState->pSmoothing_factor[k] * ( pCov_buf[i][j][k] - pPrior_cov_buf[i][j][k] + factor ) ); */ + /* mod: pCov_buf[i][j][k] = pCov_buf[i][j][k] * hCovState->pSmoothing_factor[k] + + pPrior_cov_buf[i][j][k] * (1.0 - hCovState->pSmoothing_factor[k]) + + factor * hCovState->pSmoothing_factor[k] ); */ + L_tmp0 = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // q_tmp0: q_cov[i][j] // (Q31, q_cov[i][j]) -> q_cov[i][j] + L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // q_tmp1: hCovState->q_prior_cov_real_per_band[i][j][k] + L_tmp0 = BASOP_Util_Add_Mant32Exp( L_tmp0, sub( Q31, q_cov[i][j] ), L_tmp1, sub( Q31, hCovState->q_prior_cov_real_per_band[i][j][k] ), &cov_buf_e ); + pCov_buf[i][j][k] = BASOP_Util_Add_Mant32Exp( L_tmp0, cov_buf_e, Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), fac_e, &cov_buf_e ); move32(); - q_tmp[k] = sub( Q31, q_tmp[k] ); // Q of pConv_buf[i][j][k] is now q_tmp[k] + hCovState->q_cov_real_per_band[i][j][k] = sub( Q31, cov_buf_e ); // Q of pCov_buf[i][j][k] move16(); - L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_tmp[k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_tmp[k] - pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp ); // q_tmp[k] - move32(); } - Copy( q_tmp, hCovState->q_cov_real_per_band[i][j], sub( end_band, start_band ) ); // Q of pCov_buf[i][j][k] is hCovState->q_cov_real_per_band[i][j][j] } } } @@ -418,7 +433,7 @@ void ivas_cov_smooth_process_fx( Word16 i, j, k; Word16 num_bands = sub( end_band, start_band ); - ivas_compute_smooth_cov_fx( hCovState, pFb, cov_real, hCovState->pPrior_cov_real_fx, 0, start_band, end_band, num_ch, transient_det, q_cov ); + ivas_compute_smooth_cov_fx( hCovState, pFb, cov_real, hCovState->pPrior_cov_real_fx, ONEeN20_Q97, start_band, end_band, num_ch, transient_det, q_cov ); FOR( i = 0; i < num_ch; i++ ) { diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 677c72860c3fb3f4f44caaa86a8c351354ccabec..f68b976a727e47dd4d3c53211c7da7beb7504380 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -616,11 +616,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; @@ -638,7 +635,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 ) ); @@ -651,12 +647,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 ); @@ -973,17 +963,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 ) { -#ifdef FIX_USAN_ISSUES shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); -#else - shiftEquiv = L_lshl( 0x80000000, shift_q ); -#endif } if ( shift_q >= 0 ) { @@ -997,27 +982,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 ); @@ -1026,14 +990,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 ) { -#ifdef FIX_USAN_ISSUES shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); -#else - shiftEquiv = L_lshl( 0x80000000, shift_q ); -#endif } if ( shift_q >= 0 ) { @@ -1051,34 +1010,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_prot_fx.h b/lib_com/ivas_prot_fx.h index 890f4c8fa3d5e913d0b5e5e34b6845d2f5277a51..f61890e98746f869b2a6a6a086098a4090628441 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1311,7 +1311,6 @@ Word16 matrix_diag_product_fx( Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); -#ifdef OPT_BASOP_ADD_v1 Word16 matrix_diag_product_fx_2( const Word32 *X, /* i : left hand matrix Q31 - X_e*/ const Word16 X_e, @@ -1323,7 +1322,6 @@ Word16 matrix_diag_product_fx_2( 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 ); -#endif /* OPT_BASOP_ADD_v1 */ Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix */ @@ -3048,10 +3046,11 @@ void acelp_fast_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 cdk_index, /* i : codebook index */ const Word16 dn_orig[L_SUBFR], - /* i : corr. between target and h[]. */ // Q_new + 1 + /* i : corr. between target and h[]. */ // Q_dn Word16 Q_dn, const Word16 cn[L_SUBFR], - /* i : residual after long term prediction */ // Q_new + 1 + /* i : residual after long term prediction */ // q_cn + const Word16 q_cn, const Word16 H[L_SUBFR], /* i : impulse response of weighted synthesis filter */ // e(norm_s(H[0])+1) Word16 code[L_SUBFR], /* o : algebraic (fixed) codebook excitation */ @@ -3286,11 +3285,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( @@ -3843,10 +3839,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( 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 */ -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - , - Word16 out_len /*Store the length of values in each channel*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ); ivas_error ivas_osba_ism_metadata_dec_fx( @@ -4772,21 +4764,11 @@ Word32 dot_product_cholesky_fx( const Word16 N /* i : vector & matrix size */ ); -#ifndef DOT_PROD_CHOLESKY_64BIT -Word32 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 ); -#else 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 */ ); -#endif void v_mult_mat_fx( Word32 *y_fx, /* o : the product x*A */ @@ -5070,6 +5052,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 */ @@ -5414,20 +5405,12 @@ ivas_error ivas_sba_dec_render_fx( 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*/ -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - , - Word16 out_len /*Store the length of values in each channel*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ); 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 */ -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - , - Word16 out_len -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ); ivas_error ivas_spar_md_enc_open_fx( @@ -6072,9 +6055,7 @@ ivas_error pre_proc_front_ivas_fx( 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 diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index c9ad840979d7af9f492d83747fb9abbfc4c8d99b..a5fbf9e83c6d8c0c3b21f77d0a96f8d889f4543a 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -152,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 ); } } @@ -315,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++ ) @@ -407,7 +399,6 @@ ivas_error only_reduce_bits_direction_fx( } ELSE { -#ifdef FIX_QMETADATA_PENALTY Word16 m, sorted, index1, index2; @@ -455,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_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 929eaa2c5cd8b94aa689decdc59f27ce2110b67b..8aaeb7f63b97fdf8e81aa76c9798808e0569ea29 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -51,24 +51,16 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define IVAS_FLT_EPS ( 1e-10F ) -#define IVAS_FIX_EPS ( 1 ) -#define IVAS_DBL_EPS ( (double) 1e-20 ) +#define IVAS_FIX_EPS ( 1 ) +#define IVAS_FIX_EPS_Q40 ( 110 ) -#define IVAS_REMIX_MULT_FAC ( 0.5f ) -#define IVAS_ACTIVEW_DM_F ( 1.0f ) #define IVAS_ACTIVEW_DM_F_Q30 ( ONE_IN_Q30 ) /*1 Q30*/ -#define IVAS_ACTIVEW_DM_F_DTX ( 0.25f ) -#define IVAS_ACTIVEW_DM_F_DTX_Q30 ( 268435456 ) /*0.25 Q30*/ -#define IVAS_ACTIVEW_DM_F_VLBR ( 0.25f ) -#define IVAS_ACTIVEW_DM_F_VLBR_Q30 ( 268435456 ) /*0.25 Q30*/ -#define IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH ( 3.0f ) +#define IVAS_ACTIVEW_DM_F_DTX_Q30 ( 268435456 ) /*0.25 Q30*/ +#define IVAS_ACTIVEW_DM_F_VLBR_Q30 ( 268435456 ) /*0.25 Q30*/ #define IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH_Q29 ( 1610612736 ) /*3 Q29*/ -#define IVAS_P_NORM_SCALING ( 1.0f ) #define IVAS_P_NORM_SCALING_FX ( ONE_IN_Q31 ) // 1 Q31 -#define IVAS_P_NORM_SCALING_DTX ( 0.75f ) #define IVAS_P_NORM_SCALING_DTX_FX ( 1610612736 ) // 0.75 Q31 #define IVAS_MAT_DIM_3 ( 3 ) @@ -1626,8 +1618,18 @@ static void ivas_get_Wscaling_factor_enc_fx( ivas_calc_post_pred_per_band_enc_fx( cov_real, q_cov_real, mixer_mat, q_mixer_mat, num_ch, b, postpred_cov_re, &q_postpred_cov_re ); } - Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], L_max( postpred_cov_re[0][0], IVAS_FIX_EPS ), &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re)) - q_Gw_sq = add( sub( 15, tmp_exp ), sub( q_cov_real[0][0][b], q_postpred_cov_re ) ); + tmp = L_shl_sat( IVAS_FIX_EPS_Q40, sub( q_postpred_cov_re, 40 ) ); + + IF( LE_32( postpred_cov_re[0][0], tmp ) ) + { + Gw_sq = Mpy_32_32( cov_real[0][0][b], 1250000000 ); /*1/1e-10 = 1250000000 Q(-4)*/ + q_Gw_sq = add( q_cov_real[0][0][b], -4 - 31 ); + } + ELSE + { + Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], postpred_cov_re[0][0], &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re)) + q_Gw_sq = add( sub( 15, tmp_exp ), sub( q_cov_real[0][0][b], q_postpred_cov_re ) ); + } shift = MAX16B; move16(); @@ -1992,12 +1994,15 @@ static void ivas_calc_post_pred_per_band_enc_fx( Word32 postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*q_postpred_cov_re*/ Word16 *q_postpred_cov_re ) { - Word16 i, j, k, guard_bits, tmp, q_temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], q_tmp_re, q_W_tmp; + Word16 i, j, k; Word32 dmx_mat_conj[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - Word32 max_val; - Word64 tmp_re, W_tmp; - Word16 q_postpred_cov_re_per_value[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; + Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; + Word16 q_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; + Word16 min_val; + Word32 tmp_re; + Word16 tmp_q; + Word16 tmp_e; FOR( i = 0; i < num_ch; i++ ) { @@ -2014,135 +2019,71 @@ static void ivas_calc_post_pred_per_band_enc_fx( set32_fx( postpred_cov_re[i], 0, num_ch ); } - max_val = 1; - move32(); + min_val = MAX16B; + move16(); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { - tmp_re = 0; - move64(); - q_tmp_re = 31; + temp_mat[i][j] = 0; + move32(); + temp_mat_e[i][j] = 0; move16(); FOR( k = 0; k < num_ch; k++ ) { - W_tmp = W_shr( W_mult0_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ), q_mixer_mat ); /*q_cov_real[i][k][band_idx]*/ - IF( LT_16( q_cov_real[i][k][band_idx], q_tmp_re ) ) - { - tmp_re = W_add( W_shr( tmp_re, sub( q_tmp_re, q_cov_real[i][k][band_idx] ) ), W_tmp ); /*q_cov_real[i][k][band_idx]*/ - q_tmp_re = q_cov_real[i][k][band_idx]; - move16(); - } - ELSE + tmp_re = Mpy_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ); + tmp_e = sub( 62, add( q_cov_real[i][k][band_idx], q_mixer_mat ) ); + IF( tmp_re ) { - tmp_re = W_add( tmp_re, W_shr( W_tmp, sub( q_cov_real[i][k][band_idx], q_tmp_re ) ) ); /*q_tmp_re*/ + temp_mat[i][j] = BASOP_Util_Add_Mant32Exp( temp_mat[i][j], temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); + move32(); } } - IF( tmp_re == 0 ) - { - q_temp_mat[i][j] = 31; - move16(); - temp_mat[i][j] = 0; - move32(); - } - ELSE - { - q_temp_mat[i][j] = q_tmp_re; - move16(); - q_tmp_re = W_norm( tmp_re ); - temp_mat[i][j] = W_extract_h( W_shl( tmp_re, q_tmp_re ) ); /*q_temp_mat[i][j]+ q_tmp_re -32*/ - move32(); - q_temp_mat[i][j] = sub( add( q_temp_mat[i][j], q_tmp_re ), 32 ); - move16(); - } - max_val = L_max( max_val, L_abs( temp_mat[i][j] ) ); } } - guard_bits = find_guarded_bits_fx( num_ch ); - - tmp = norm_l( max_val ); - IF( LT_16( tmp, guard_bits ) ) - { - guard_bits = sub( guard_bits, tmp ); - } - ELSE - { - guard_bits = 0; - move16(); - } - - *q_postpred_cov_re = 31; - move16(); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { - tmp_re = 0; - move64(); - q_tmp_re = 31; + q_postpred_cov_re_buf[i][j] = *q_postpred_cov_re; move16(); FOR( k = 0; k < num_ch; k++ ) { - W_tmp = W_shr( W_mult0_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ), guard_bits ); // q_temp_mat[k][j]+ q_mixer_mat-guard_bits - q_W_tmp = sub( add( q_temp_mat[k][j], q_mixer_mat ), guard_bits ); - IF( LT_16( q_W_tmp, q_tmp_re ) ) + tmp_re = Mpy_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ); + tmp_q = sub( q_mixer_mat, temp_mat_e[k][j] ); + IF( tmp_re ) { - tmp_re = W_add( W_shr( tmp_re, sub( q_tmp_re, q_W_tmp ) ), W_tmp ); // q_W_tmp - q_tmp_re = q_W_tmp; + tmp_e = sub( 31, q_postpred_cov_re_buf[i][j] ); + postpred_cov_re[i][j] = BASOP_Util_Add_Mant32Exp( postpred_cov_re[i][j], tmp_e, tmp_re, sub( Q31, tmp_q ), &tmp_e ); + move32(); + q_postpred_cov_re_buf[i][j] = sub( 31, tmp_e ); move16(); } - ELSE - { - tmp_re = W_add( tmp_re, W_shr( W_tmp, sub( q_W_tmp, q_tmp_re ) ) ); // q_tmp_re - } } - - if ( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) ) - { - tmp_re = 0; - move64(); - } - - q_postpred_cov_re_per_value[i][j] = q_tmp_re; - move16(); - IF( tmp_re == 0 ) + IF( postpred_cov_re[i][j] ) { - postpred_cov_re[i][j] = W_extract_l( tmp_re ); /* q_tmp_re*/ - move32(); - } - ELSE - { - q_tmp_re = W_norm( tmp_re ); - postpred_cov_re[i][j] = W_extract_h( W_shl( tmp_re, q_tmp_re ) ); /* q_tmp_re+ q_postpred_cov_re_per_value[i][j] -32*/ - move32(); - q_postpred_cov_re_per_value[i][j] = sub( add( q_tmp_re, q_postpred_cov_re_per_value[i][j] ), 32 ); - move16(); + min_val = s_min( min_val, q_postpred_cov_re_buf[i][j] ); } - *q_postpred_cov_re = s_min( *q_postpred_cov_re, q_postpred_cov_re_per_value[i][j] ); - move16(); } } + /*Changing Q of postpred_cov_re to min_val*/ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { - IF( postpred_cov_re[i][j] >= 0 ) - { - postpred_cov_re[i][j] = L_shr( postpred_cov_re[i][j], sub( q_postpred_cov_re_per_value[i][j], *q_postpred_cov_re ) ); //*q_postpred_cov_re - move32(); - } - ELSE + IF( postpred_cov_re[i][j] ) { - postpred_cov_re[i][j] = L_negate( L_shr( L_negate( postpred_cov_re[i][j] ), sub( q_postpred_cov_re_per_value[i][j], *q_postpred_cov_re ) ) ); //*q_postpred_cov_re + postpred_cov_re[i][j] = L_shl( postpred_cov_re[i][j], sub( min_val, q_postpred_cov_re_buf[i][j] ) ); move32(); } } } + FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < i; j++ ) @@ -2152,6 +2093,14 @@ static void ivas_calc_post_pred_per_band_enc_fx( } } + if ( EQ_16( min_val, MAX16B ) ) + { + min_val = Q31; + move16(); + } + *q_postpred_cov_re = min_val; + move16(); + return; } @@ -2631,11 +2580,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(); @@ -2691,7 +2636,8 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( trace = W_add( trace, W_deposit32_l( L_abs( cov_uu_re[i - num_dmx][i - num_dmx] ) ) ); // q_cov_uu_re } - factor = L_max( IVAS_FIX_EPS, postpred_cov_re[0][0] ); // q_postpred_cov_re + factor = postpred_cov_re[0][0]; // q_postpred_cov_re + move32(); q_factor = q_postpred_cov_re; move16(); IF( trace != 0 ) @@ -2712,10 +2658,22 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( factor = L_max( factor, tmp ); // q_factor } + tmp = L_shl_sat( 189 /* 1e-20 in Q74 */, sub( q_factor, 74 ) ); + Word16 factor_exp = 0; move16(); - factor = BASOP_Util_Divide3232_Scale( 1, factor, &factor_exp ); // q=15-(factor_exp+31-(31-q_factor)) - factor_exp = add( factor_exp, q_factor ); + IF( LE_32( factor, tmp ) ) + { + factor = 22204; // (1 / 1e-20) in Q(-52) + factor_exp = Q15 - ( -52 ); + move32(); + move16(); + } + ELSE + { + factor = BASOP_Util_Divide3232_Scale( 1, factor, &factor_exp ); // q=15-(factor_exp+31-(31-q_factor)) + factor_exp = add( factor_exp, q_factor ); + } /* normalise Hermitian (except for rounding) cov_uu */ FOR( i = num_dmx; i < num_ch; i++ ) @@ -2732,7 +2690,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( { q_tmp = W_norm( W_tmp ); } - cov_uu_re[i - num_dmx][j - num_dmx] = W_extract_h( W_shl( W_mult0_32_32( cov_uu_re[i - num_dmx][j - num_dmx], factor ), q_tmp ) ); /*q_cov_uu_re+15-factor_exp+q_tmp-32*/ + cov_uu_re[i - num_dmx][j - num_dmx] = W_extract_h( W_shl( W_tmp, q_tmp ) ); /*q_cov_uu_re+15-factor_exp+q_tmp-32*/ move32(); q_cov_uu_re_per_value[i - num_dmx][j - num_dmx] = sub( add( add( q_cov_uu_re, sub( 15, factor_exp ) ), q_tmp ), 32 ); move16(); @@ -3315,6 +3273,9 @@ void ivas_calc_c_p_coeffs_enc_fx( Word16 i, j, q_postpred_cov_re; Word32 postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; + q_postpred_cov_re = 0; + move16(); + FOR( i = 0; i < IVAS_SPAR_MAX_CH; i++ ) { set_zero_fx( postpred_cov_re[i], IVAS_SPAR_MAX_CH ); @@ -3834,11 +3795,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(); } } @@ -3865,7 +3822,6 @@ 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( j = 0; j < sub( ndm, 1 ); j++ ) @@ -3874,15 +3830,6 @@ void ivas_compute_spar_params_fx( move32(); } } -#else - for ( i = 0; i < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; i++ ) - { - for ( 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(); } @@ -7182,6 +7129,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 = MIN_32; + } + + + 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_tools_fx.c b/lib_com/ivas_tools_fx.c index 04d6f7bf50be3f68f9684774ee1d4c7da7412cdf..ca8dec27615addfd578de77e9464538d8f21d519 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -306,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, */ @@ -334,7 +328,6 @@ void v_add_inc_fx( ix1 = 0; ix2 = 0; iy = 0; -#endif move16(); move16(); move16(); @@ -604,44 +597,6 @@ void v_sub32_fx( * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) *---------------------------------------------------------------------*/ -#ifndef DOT_PROD_CHOLESKY_64BIT -/*! r: the dot product x'*A*A'*x */ -Word32 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 ) -{ - Word16 i, j; - Word32 suma, tmp_sum, mul; - 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(); - 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 - } - - 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*/ - } - - return suma; -} -#else /*! r: the dot product x'*A*A'*x */ Word64 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x Q31 - exp_x*/ @@ -677,7 +632,6 @@ Word64 dot_product_cholesky_fixed( return suma; } -#endif void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ @@ -978,9 +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; -#ifndef OPT_BASOP_ADD_v1 - Word16 x_idx, y_idx; -#endif /* OPT_BASOP_ADD_v1 */ Word64 temp; Word16 temp_e; Word16 prod_e = add( X_fx_e, Y_fx_e ); @@ -1007,13 +958,7 @@ Word16 matrix_product_mant_exp_fx( FOR( k = 0; k < rowsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e -#else /* OPT_BASOP_ADD_v1 */ - 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 -#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1051,13 +996,7 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e -#else /* OPT_BASOP_ADD_v1 */ - 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 -#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1095,13 +1034,7 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e -#else /* OPT_BASOP_ADD_v1 */ - 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 -#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1140,13 +1073,7 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e -#else /* OPT_BASOP_ADD_v1 */ - 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 -#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1204,9 +1131,6 @@ Word16 matrix_product_fx( ) { Word16 i, j, k; -#ifndef OPT_BASOP_ADD_v1 - Word16 x_idx, y_idx; -#endif /* OPT_BASOP_ADD_v1 */ Word32 *Zp_fx = Z_fx; /* Processing */ @@ -1227,13 +1151,7 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Qx + Qy - 31*/ -#else /* OPT_BASOP_ADD_v1 */ - 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*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp_fx++; @@ -1254,13 +1172,7 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/ -#else /* OPT_BASOP_ADD_v1 */ - 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*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp_fx++; @@ -1281,13 +1193,7 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/ -#else /* OPT_BASOP_ADD_v1 */ - 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*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } @@ -1310,13 +1216,7 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); /*Qx + Qy - 31*/ -#else /* OPT_BASOP_ADD_v1 */ - 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*/ -#endif /* OPT_BASOP_ADD_v1 */ // TODO: overflow of Z_fx to be checked move32(); } @@ -1341,9 +1241,6 @@ Word16 matrix_product_q30_fx( ) { Word16 i, j, k; -#ifndef OPT_BASOP_ADD_v1 - Word16 x_idx, y_idx; -#endif /* OPT_BASOP_ADD_v1 */ Word32 *Zp_fx = Z_fx; Word64 W_tmp; @@ -1366,14 +1263,7 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < rowsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 -#else /* OPT_BASOP_ADD_v1 */ - //( *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 -#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1397,14 +1287,7 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 -#else /* OPT_BASOP_ADD_v1 */ - //( *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 -#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1428,11 +1311,6 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { -#ifndef OPT_BASOP_ADD_v1 - //( *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*/ -#endif /* OPT_BASOP_ADD_v1 */ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 } @@ -1459,14 +1337,7 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 -#else /* OPT_BASOP_ADD_v1 */ - //( *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 -#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1499,9 +1370,6 @@ Word16 matrix_product_mant_exp( Word16 *Zp_e = Z_e; Word32 L_tmp; Word16 tmp_e; -#ifndef OPT_BASOP_ADD_v1 - Word16 x_idx, y_idx; -#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ test(); @@ -1523,16 +1391,8 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < rowsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 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] ); -#else /* OPT_BASOP_ADD_v1 */ - 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] ); -#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1560,16 +1420,8 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 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] ); -#else /* OPT_BASOP_ADD_v1 */ - 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] ); -#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); ( *Zp_e ) = tmp_e; @@ -1596,16 +1448,8 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 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] ); -#else /* OPT_BASOP_ADD_v1 */ - 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] ); -#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1635,16 +1479,8 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 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] ); -#else /* OPT_BASOP_ADD_v1 */ - 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] ); -#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1675,9 +1511,6 @@ Word16 matrix_diag_product_fx( { Word16 i, j; Word32 *Zp = Z; -#ifndef OPT_BASOP_ADD_v1 - Word16 tmp; -#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1690,12 +1523,7 @@ Word16 matrix_diag_product_fx( { FOR( i = 0; i < colsX; ++i ) { -#ifdef OPT_BASOP_ADD_v1 *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - tmp = add( j, imult1616( i, rowsX ) ); - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; } @@ -1726,7 +1554,6 @@ Word16 matrix_diag_product_fx( return EXIT_SUCCESS; } -#ifdef OPT_BASOP_ADD_v1 Word16 matrix_diag_product_fx_2( const Word32 *X, /* i : left hand matrix Q31 - X_e*/ const Word16 X_e, @@ -1818,7 +1645,6 @@ Word16 matrix_diag_product_fx_2( return EXIT_SUCCESS; } -#endif /* OPT_BASOP_ADD_v1 */ Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix Q31 - X_e*/ @@ -1835,9 +1661,6 @@ Word16 matrix_diag_product_fx_1( Word16 i, j; Word32 *Zp = Z; Word16 *Z_ep = Z_e; -#ifndef OPT_BASOP_ADD_v1 - Word16 tmp; -#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1850,19 +1673,10 @@ Word16 matrix_diag_product_fx_1( { FOR( i = 0; i < colsX; ++i ) { -#ifdef OPT_BASOP_ADD_v1 *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - tmp = add( j, imult1616( i, rowsX ) ); /*Q0*/ - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; -#ifdef OPT_BASOP_ADD_v1 *( Z_ep ) = add( X_e[j + i * rowsX], Y_e[j] ); -#else /* OPT_BASOP_ADD_v1 */ - *( Z_ep ) = add( X_e[tmp], Y_e[j] ); -#endif /* OPT_BASOP_ADD_v1 */ move16(); Z_ep++; } @@ -1908,9 +1722,6 @@ Word16 diag_matrix_product_fx( { Word16 i, j; Word32 *Zp = Z; -#ifndef OPT_BASOP_ADD_v1 - Word16 tmp; -#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1923,12 +1734,7 @@ Word16 diag_matrix_product_fx( { FOR( j = 0; j < entriesY; ++j ) { -#ifdef OPT_BASOP_ADD_v1 *( Zp ) = Mpy_32_32( X[i + j * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/ - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; } @@ -1974,9 +1780,6 @@ Word16 matrix_product_diag_fx( { Word16 j, k; Word32 *Zp = Z; -#ifndef OPT_BASOP_ADD_v1 - Word16 y_idx, x_idx; -#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ test(); @@ -1995,13 +1798,7 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - 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)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; @@ -2019,13 +1816,7 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - 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)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; @@ -2045,13 +1836,7 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - 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)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } @@ -2071,13 +1856,7 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { -#ifdef OPT_BASOP_ADD_v1 ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ -#else /* OPT_BASOP_ADD_v1 */ - 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)*/ -#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 4e306b93698eaff8917a518ff6f531615683af53..6f148057faa5dba000aa064e5e4ba169de6781ec 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -356,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/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/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 6437cc393c2d82d488fe5f6a373235bb0e53edbb..5f0f5aaec035d6eeb5ff1785b03453e6bf58056c 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/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 10e5604335a7b1ad471ffb3cf631bf2b8c6856aa..cf2ad8a8a0df8a9294e4f0a13f57664441b19676 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -461,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; } @@ -491,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 @@ -503,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; } @@ -549,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 a20bbcbc3d58b2edcead84c39eba283084e38a1c..6fb9e5c9443482c2bed87170ee15606f926b5453 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -67,112 +67,22 @@ #define BASOP_NOGLOB_DECLARE_LOCAL #endif -#define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */ -#define MSAN_FIX -#define FIX_TMP_714 -#define BASOP_NOGLOB_TMP_715 -#define EVS_FUNC_MODIFIED -#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_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ -#define FIX_USAN_ISSUES /* Ittiam: Fix issues reported by USAN */ -#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 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 */ -#define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ +#define FIX_867_CLDFB_NRG_SCALE + +#define FIX_1378_ACELP_OUT_OF_BOUNDS + //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ -#define FIX_ISSUE_1327 /* Ittiam: Fix for issue 1327: Glitch when stereo is switching from TD to FD*/ -#define NONBE_FIX_1402_WAVEADJUST /* VA: BASOP iisue 1402: fix waveform adjustment decoder PLC */ -#define FIX_ISSUE_1376 /* VA: Fix for issue 1376 (issue with GSC excitation) */ -#define OPT_SBA_AVOID_SPAR_RESCALE /* Optimization made to spar decoder and IGF */ +#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. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ +#define HARM_PUSH_BIT +#define HARM_ENC_INIT +//#define HARM_SCE_INIT +#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ +#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 0846c618be15583797a4c64ccbae74c7a21fa224..92387209012c8cd2dfd7a6bacdb30ab3903715ad 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -21,7 +21,7 @@ static Word16 PutIntoBitstream_fx( value = *( *pStream )++; codedValue = EncodeValue( value, index ); - push_next_indice_fx( hBstr, codedValue, nBits ); + push_next_indice( hBstr, codedValue, nBits ); return value; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3fd3e4b3694eb950ff133f84fa90b64de6147064..45641b3f8f6789c864216b5d78a78c3b7d747452 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -881,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, @@ -1446,6 +1444,13 @@ void scale_sig32( const Word16 lg, /* i : size of x[] Q0 */ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx xx exp */ ); + +void Scale_sig64( + Word64 x[], /* i/o: signal to scale Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp /* i : exponent: x = round(x << exp) Qx exp */ +); + void scale_sig32_r( Word32 x[], /* i/o: signal to scale Qx */ const Word16 lg, /* i : size of x[] Q0 */ @@ -1653,7 +1658,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 */ @@ -4853,33 +4857,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( @@ -5082,14 +5084,7 @@ void fine_gain_quant_fx( Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); -void fine_gain_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains i:Q12 / o:Q11 */ - const Word16 *gopt /* i : Optimal gains Q12 */ -); + void get_max_pulses_fx( const Word16 *band_start, /* i : Sub band start indices */ const Word16 *band_end, /* i : Sub band end indices */ @@ -5850,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 @@ -9752,9 +9742,10 @@ void cldfbSynthesis_ivas_fx( 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 */ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - const Word16 shift, /* i : scale for state buffer */ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ + 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 */ ); @@ -10867,8 +10858,11 @@ void ProcessStereoIGF_fx( Word16 q_pITFMDCTSpectrum_1, Word16 q_pITFMDCTSpectrum_2, Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ const Word16 frameno, /* i : flag indicating index of current subfr. */ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ const Word32 element_brate, /* i : element bitrate */ @@ -10881,8 +10875,11 @@ void IGFEncApplyStereo_fx( const Word16 igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ + Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ const Word16 frameno, /* i : flag indicating index of current subfr. */ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ const Word32 element_brate, /* i : element bitrate */ @@ -10983,33 +10980,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( diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index 479bc04d9c357ca0101de7e154b903b3e4d75924..a6c0bc462d6757c2a53af013c84dff95f6b44461 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -509,73 +509,6 @@ void apply_gain_fx( * * Fine gain quantization *--------------------------------------------------------------------------*/ -void fine_gain_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains i:Q12 / o:Q11 */ - const Word16 *gopt /* i : Optimal gains Q12 */ -) -{ - Word16 band; - Word16 gbits; - Word16 idx; - Word16 gain_db, gain_dbq; - Word16 err; - - Word16 tmp1, tmp2, exp1, exp2; - Word32 L_tmp; - UWord16 lsb; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - FOR( band = 0; band < num_sfm; band++ ) - { - gbits = gain_bits[ord[band]]; /* Q0 */ - move16(); - test(); - IF( fg_pred[band] != 0 && gbits > 0 ) - { - exp1 = norm_s( gopt[band] ); - exp1 = sub( exp1, 1 ); - tmp1 = shl( gopt[band], exp1 ); - exp2 = norm_s( fg_pred[band] ); - tmp2 = shl( fg_pred[band], exp2 ); /* Q12 + exp2 */ - exp1 = add( 15, sub( exp1, exp2 ) ); - err = div_s( tmp1, tmp2 ); /* Q15 */ - tmp1 = norm_s( err ); - exp2 = Log2_norm_lc( L_deposit_h( shl( err, tmp1 ) ) ); - tmp1 = sub( 14, tmp1 ); - tmp1 = sub( tmp1, exp1 ); - L_tmp = L_Comp( tmp1, exp2 ); - Mpy_32_16_ss( L_tmp, 24660, &L_tmp, &lsb ); /* 24660 = 20*log10(2) in Q12 */ /*16+12-15=13 */ - gain_db = round_fx_sat( L_shl_o( L_tmp, 17, &Overflow ) ); /* Q14 */ - - idx = squant_fx( gain_db, &gain_dbq, finegain_fx[gbits - 1], gain_cb_size[gbits - 1] ); /* Q0 */ - push_indice( hBstr, IND_PVQ_FINE_GAIN, idx, gbits ); - - L_tmp = L_mult0( gain_dbq, 21771 ); /* 21771=0.05*log2(10) */ /* 14+17=31 */ - L_tmp = L_shr( L_tmp, 15 ); /* Q16 */ - tmp1 = L_Extract_lc( L_tmp, &exp1 ); - tmp1 = abs_s( tmp1 ); - tmp1 = extract_l( Pow2( 14, tmp1 ) ); - exp1 = sub( 14, exp1 ); - - L_tmp = L_mult0( fg_pred[band], tmp1 ); /*12+exp1 */ - fg_pred[band] = round_fx( L_shl( L_tmp, sub( 15, exp1 ) ) ); /*12+exp1+16-exp1-16=12 - 1-> Q11*/ - move16(); - } - ELSE - { - fg_pred[band] = shr( fg_pred[band], 1 ); // Q12 -> Q11 To align all the fg_pred indices in same Q. - } - } - - return; -} void fine_gain_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order Q0 */ @@ -622,7 +555,7 @@ void fine_gain_quant_fx( gain_db = round_fx_sat( L_shl_o( L_tmp, 17, &Overflow ) ); idx = squant_fx( gain_db, &gain_dbq, finegain_fx[gbits - 1], gain_cb_size[gbits - 1] ); - push_indice_fx( hBstr, IND_PVQ_FINE_GAIN, idx, gbits ); + push_indice( hBstr, IND_PVQ_FINE_GAIN, idx, gbits ); L_tmp = L_mult0( gain_dbq, 21771 ); /* 21771=0.05*log2(10) */ /* 14+17=31 */ L_tmp = L_shr( L_tmp, 15 ); /* Q16 */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 87b323d0a98edcd61b34d804e630c3980db98088..a5c8a3b7c65d8747e20b83f4afa8205438fe54ac 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -16790,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*/ @@ -16823,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 */ @@ -22050,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, @@ -22085,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, @@ -25351,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 10bce5bb2af3fc6903d463624d8cd1d533049d60..73156b9892df5be8df2ea273d450acaf492e1fdc 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1504,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/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_fx.c b/lib_com/swb_tbe_com_fx.c index 238478b1aa6a7b3875be079d3a96dbf15b9dc929..238b478c5abce7058655ca0592e3f89969e1e201 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -12,11 +12,12 @@ #include "ivas_prot_fx.h" #include "options_warnings.h" -#define POW_EXC16k_WHTND 1.14e11f /* power of random excitation, length 320 samples, uniform distribution */ -#define POW_EXC16k_WHTND_FX_INV_SQRT 6360 // Q31 -#define POW_EXC16k_WHTND_FX 178125000 // Q-6 -#define THR_ENV_ERROR_PLOSIVE 200.0f /* threshold for envelope error used in plosive detection */ -#define THR_ENV_ERROR_PLOSIVE_FX 200 /* threshold for envelope error used in plosive detection Q0 */ +#define POW_EXC16k_WHTND 1.14e11f /* power of random excitation, length 320 samples, uniform distribution */ +#define POW_EXC16k_WHTND_FX_INV_SQRT 6360 // Q31 +#define POW_EXC16k_WHTND_FX_INV_SQRT_IN_Q49 1667313793 // Q49 +#define POW_EXC16k_WHTND_FX 178125000 // Q-6 +#define THR_ENV_ERROR_PLOSIVE 200.0f /* threshold for envelope error used in plosive detection */ +#define THR_ENV_ERROR_PLOSIVE_FX 200 /* threshold for envelope error used in plosive detection Q0 */ /*-----------------------------------------------------------------* * Local function prototypes @@ -930,7 +931,7 @@ static void Calc_st_filt_tbe_ivas_enc_fx( { L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); } - g0 = extract_h( L_shl_sat( L_g0, 14 ) ); + g0 = extract_h( L_shl( L_g0, 14 ) ); /* Scale signal i of 1/A(gamma1) */ IF( GT_16( g0, 1024 ) ) @@ -1036,11 +1037,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 */ } @@ -3962,7 +3959,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( Word16 exc32k[L_FRAME32k], exc16k[L_FRAME16k]; Word32 pow1, pow22; Word16 scale, temp1, temp2, temp3; - + Word16 Q_White_exc16k; Word16 excTmp2[L_FRAME16k]; Word16 *White_exc16k; Word16 excNoisyEnv[L_FRAME16k]; @@ -3993,12 +3990,13 @@ void GenShapedSHBExcitation_ivas_dec_fx( Word32 White_exc16k_32[L_FRAME16k]; Word16 White_exc16k_tmp[L_FRAME16k]; Word16 Q_temp; - Word16 prev_Q_bwe_exc_fb; - Word16 chk1, chk2; + Word16 prev_Q_bwe_exc_fb, Q_exc16kWhtnd; + Word16 chk1; + Word32 chk2; chk1 = 0; chk2 = 0; move16(); - move16(); + move32(); #if 1 // def ADD_IVAS_TBE_CODE Word16 alpha, step, mem_csfilt_left, mem_csfilt_right, excNoisyEnvLeft[L_FRAME16k], excNoisyEnvRight[L_FRAME16k]; @@ -4266,7 +4264,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( } /* normalize the amplitude of the gaussian excitation to that of the LB exc. */ - Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT; + Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT_IN_Q49; move32(); move32(); pow22 = POW_EXC16k_WHTND_FX; @@ -4275,21 +4273,23 @@ void GenShapedSHBExcitation_ivas_dec_fx( // v_multc(White_exc16k, (float)sqrt(pow1 / pow22), White_exc16k, L_FRAME16k); Word16 pow1_exp = sub( Q31, Q_pow1 ); Word32 temp_pow = Sqrt32( pow1, &pow1_exp ); - temp_pow = L_shl( Mpy_32_32( temp_pow, pow22_inv ), pow1_exp ); + temp_pow = Mpy_32_32( temp_pow, pow22_inv ); /*Word16 out_exp; Word32 temp_pow1 = root_a_over_b_fx(pow1, Q_pow1, pow22, Q_pow22, &out_exp); temp_pow1 = L_shl(temp_pow1, out_exp);*/ // v_multc_fixed_16_16(White_exc16k, round_fx(temp_pow), White_exc16k, L_FRAME16k); L_tmp = 0; move32(); + shift = getScaleFactor16( White_exc16k, L_FRAME16k ); FOR( k = 0; k < L_FRAME16k; k++ ) { White_exc16k_32[k] = Mpy_32_16_1( temp_pow, White_exc16k[k] ); move32(); - White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], sub( *Q_bwe_exc, NOISE_QADJ ) ) ); // Q_bwe_exc - NOISE_QADJ + White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], shift ) ); // Q_White_exc16k move16(); L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); } + Q_White_exc16k = add( shift, sub( 49 - 31, pow1_exp ) ); Q_temp = norm_l( L_tmp ); IF( L_tmp == 0 ) { @@ -4327,22 +4327,24 @@ void GenShapedSHBExcitation_ivas_dec_fx( /* calculate pow22 */ /* pow22=0.00001f */ tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 ); - pow22 = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */ + Word64 sum = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */ + Q_White_exc16k = getScaleFactor32( White_exc16k_32, L_FRAME16k ); FOR( k = 0; k < L_FRAME16k; k++ ) { - /* White_exc16k[k] *= excNoisyEnv[k]; */ - White_exc16k[k] = mult_r( excNoisyEnv[k], shl( White_exc16k[k], 1 ) ); // Q_excTmp2 + 5 + 1 - 15 ==> Q_excTmp2 - 9 - move16(); - chk2 = s_or( chk2, White_exc16k[k] ); + + White_exc16k[k] = extract_h( L_shl( White_exc16k_32[k], Q_White_exc16k ) ); // Q_excTmp2 + 6 + Q_White_exc16k - 16 ==> Q_excTmp2 + Q_White_exc16k - 10 + chk2 = L_or( chk2, White_exc16k_32[k] ); /* i: excNoisyEnv in (Q_excTmp2) */ /* i: White_exc16k in Q6 */ - /* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */ + /* o: White_exc16k in (Q_White_exc16k) */ /* pow22 += White_exc16k[k] * White_exc16k[k]; */ - pow22 = L_mac0_sat( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2-NOISE_QADJ)*/ + sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2 + Q_White_exc16k - 10)*/ + move16(); } - /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/ - Q_pow22 = shl( sub( Q_excTmp2, NOISE_QADJ ), 1 ); - Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_excTmp2 ) ); + Q_pow22 = W_norm( sum ); + pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2 + Q_White_exc16k - 10)+Q_pow22-32 + Q_pow22 = sub( add( Q_pow22, shl( sub( add( Q_White_exc16k, Q_excTmp2 ), 10 ), 1 ) ), 32 ); + Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) ); } #if 1 // def ADD_IVAS_TBE_CODE @@ -4629,7 +4631,6 @@ void GenShapedSHBExcitation_ivas_dec_fx( move16(); } } -#if 1 // def ADD_IVAS_TBE_CODE test(); IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL ) { @@ -4642,29 +4643,42 @@ void GenShapedSHBExcitation_ivas_dec_fx( temp_fac = Sqrt16(temp_fac, &temp_fac_exp);*/ L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); Word16 temp_fac = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15 + shift = sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ); // v_multc_fixed_16_16(White_exc16k,shr(temp_fac, temp_fac_exp) , mixExc16k, L_FRAME16k); FOR( k = 0; k < L_FRAME16k; k++ ) { - mixExc16k[k] = mult_r( White_exc16k[k], temp_fac ); + mixExc16k[k] = mult_r( shl_sat( White_exc16k[k], shift ), temp_fac ); move16(); } } -#endif tmp = sub( Q_temp, 3 ); FOR( k = 0; k < L_FRAME16k; k++ ) { - White_exc16k_FB[k] = White_exc16k[k]; /* Q_bwe_exc-NOISE_QADJ */ + White_exc16k_FB[k] = White_exc16k[k]; /* Q_White_exc16k */ } prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; move16(); - *Q_bwe_exc_fb = sub( *Q_bwe_exc, NOISE_QADJ ); + *Q_bwe_exc_fb = Q_White_exc16k; move16(); + *tbe_demph = shl_sat( *tbe_demph, sub( Q_White_exc16k, sub( *Q_bwe_exc, NOISE_QADJ ) ) ); deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); - /* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */ - /* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */ + *tbe_demph = shl_sat( *tbe_demph, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); -#if 1 // def ADD_IVAS_TBE_CODE + Q_exc16kWhtnd = getScaleFactor16( exc16kWhtnd, L_FRAME16k ); + Q_exc16kWhtnd = add( Q_exc16kWhtnd, *Q_bwe_exc ); + + shift = getScaleFactor16( White_exc16k, L_FRAME16k ); + + shift = s_min( Q_exc16kWhtnd, add( shift, Q_White_exc16k ) ); + scale_sig( exc16kWhtnd, L_FRAME16k, sub( shift, *Q_bwe_exc ) ); + scale_sig( White_exc16k, L_FRAME16k, sub( shift, Q_White_exc16k ) ); + + Q_exc16kWhtnd = Q_White_exc16k = shift; + move16(); + move16(); + *tbe_premph = shl_sat( *tbe_premph, sub( Q_White_exc16k, sub( *Q_bwe_exc, NOISE_QADJ ) ) ); + move16(); test(); IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { @@ -4697,11 +4711,8 @@ void GenShapedSHBExcitation_ivas_dec_fx( /* mixing of LB and gaussian excitation in the first half of the frame */ FOR( k = 0; k < L_FRAME16k / 2; k++ ) { - // exc16kWhtnd[k] = (float)fact * (White_exc16k[k] * scale) + (float)(1 - fact) * exc16kWhtnd[k]; - // exc16kWhtnd[k] = add(mult_r(fact, mult(shl(White_exc16k[k], *Q_bwe_exc), scale)), mult_r(sub(32767, fact), exc16kWhtnd[k])); - L_tmp = L_add( L_shl( L_mult( fact, mult_r( White_exc16k[k], scale ) ), NOISE_QADJ ), - L_mult( sub( 32767, fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc - exc16kWhtnd[k] = round_fx( L_tmp ); + exc16kWhtnd[k] = mac_r( L_mult( fact, mult_r( White_exc16k[k], scale ) ), + sub( 32767, fact ), exc16kWhtnd[k] ); // Q_exc16kWhtnd move16(); fact = add_sat( fact, step ); scale = add_sat( scale, step_scale ); @@ -4710,11 +4721,8 @@ void GenShapedSHBExcitation_ivas_dec_fx( /* mixing of LB and gaussian excitation in the second half of the frame */ FOR( ; k < L_FRAME16k; k++ ) { - // exc16kWhtnd[k] = (float)new_fact * White_exc16k[k] + (float)(1 - new_fact) * exc16kWhtnd[k]; - // exc16kWhtnd[k] = add(mult_r(new_fact, shl(White_exc16k[k], *Q_bwe_exc)), mult_r(sub(32767, new_fact), exc16kWhtnd[k])); - L_tmp = L_add( L_shl( L_mult( new_fact, White_exc16k[k] ), NOISE_QADJ ), - mult_r( sub( 32767, new_fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc - exc16kWhtnd[k] = round_fx( L_tmp ); + exc16kWhtnd[k] = mac_r( L_mult( new_fact, White_exc16k[k] ), + sub( 32767, new_fact ), exc16kWhtnd[k] ); // Q_exc16kWhtnd move16(); } } @@ -4722,14 +4730,9 @@ void GenShapedSHBExcitation_ivas_dec_fx( PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); } ELSE -#endif { -#if 1 // def ADD_IVAS_TBE_CODE test(); IF( EQ_16( coder_type, UNVOICED ) || EQ_16( MSFlag, 1 ) ) -#else - IF( EQ_16( coder_type, UNVOICED ) ) -#endif { L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); test(); @@ -4741,16 +4744,12 @@ void GenShapedSHBExcitation_ivas_dec_fx( scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ FOR( k = 0; k < L_FRAME16k; k++ ) { - /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */ - L_tmp = L_mult( White_exc16k[k], scale ); - /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */ - exc16kWhtnd[k] = round_fx_sat( L_shl_sat( L_tmp, NOISE_QADJ ) ); + exc16kWhtnd[k] = mult_r_sat( White_exc16k[k], scale ); move16(); - /* exc16kWhtnd: Q_bwe_exc */ } PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); - /* i/o: exc16kWhtnd (Q_bwe_exc) */ - /* i/o: tbe_premph (Q_bwe_exc) */ + /* i/o: exc16kWhtnd (Q_exc16kWhtnd) */ + /* i/o: tbe_premph (Q_exc16kWhtnd) */ } ELSE { @@ -4813,11 +4812,10 @@ void GenShapedSHBExcitation_ivas_dec_fx( FOR( j = 0; j < lSubFr; j++ ) { /*exc16kWhtnd[k+j] = temp1 * exc16kWhtnd[k+j] + temp2 * White_exc16k[k+j]; */ - L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc-NOISE_QADJ)*/ - L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ + L_tmp = L_mult( temp2, White_exc16k[k + j] ); exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); move16(); - /* Q_bwe_exc */ + /* Q_exc16kWhtnd */ } k = add( k, lSubFr ); @@ -4831,19 +4829,18 @@ void GenShapedSHBExcitation_ivas_dec_fx( temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */ temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); - /* exc16kWhtnd: Q_bwe_exc; - tbe_premph: Q_bwe_exc*/ + /* exc16kWhtnd: Q_exc16kWhtnd; + tbe_premph: Q_exc16kWhtnd*/ } } } + *tbe_premph = shl_sat( *tbe_premph, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); + move16(); + Scale_sig( White_exc16k, L_FRAME16k, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); + Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); -#if 1 // def ADD_IVAS_TBE_CODE IF( LT_32( extl_brate, SWB_TBE_2k8 ) ) -#else - IF( LT_32( bitrate, ACELP_24k40 ) ) -#endif { Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 ); /* i: exc16kWhtnd in Q_bwe_exc */ @@ -5087,7 +5084,6 @@ void GenSHBSynth_fx32( Word32 speech_buf_32k[L_FRAME32k]; Word16 i; -#ifdef FIX_881_HILBERT_FILTER Word16 shift = 0; Word32 maxm32, input_synspeech_temp[L_FRAME16k]; move16(); @@ -5123,9 +5119,6 @@ void GenSHBSynth_fx32( } Interpolate_allpass_steep_fx32( input_synspeech_temp, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k ); -#else - Interpolate_allpass_steep_fx32( input_synspeech, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k ); -#endif IF( EQ_16( L_frame, L_FRAME ) ) { @@ -5148,14 +5141,12 @@ void GenSHBSynth_fx32( } } -#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; } 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_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/tools.c b/lib_com/tools.c index e4ccd9955ff0ec12a935b289f98e151da54c2be2..b1a9f4d13f29a8e3b9e0d7e53c8cd5b0b51bfb6f 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -628,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(); } @@ -687,45 +665,22 @@ 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(); } diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 8a4322f8d275b58272b49f7b524021f7a423ac81..59918a1eae80fa53cd600b229d26bcdca91dc1ee 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -463,26 +463,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: @@ -504,26 +495,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( @@ -560,28 +542,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: @@ -603,23 +576,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( @@ -668,7 +632,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++ ) @@ -676,26 +639,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; } @@ -781,7 +724,6 @@ void Copy_Scale_sig_16_32_DEPREC( } return; } -#ifdef FIX_ISSUE_1237 #ifdef DEBUGGING if ( exp0 >= 16 ) { @@ -789,7 +731,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++ ) @@ -3618,8 +3559,8 @@ Word16 erb_diff_search_fx( Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif } ELSE { - dh = sub( dif_erb[i + offset], cb_fx[j * cb_dim + i] ); /* Q13 */ - Ltemp1 = L_mult( dh, dh ); /* Q27 */ + dh = sub_sat( dif_erb[i + offset], cb_fx[j * cb_dim + i] ); /* Q13 */ + Ltemp1 = L_mult_sat( dh, dh ); /* Q27 */ dh = extract_h( Ltemp1 ); dl = extract_l( Ltemp1 ); @@ -4565,3 +4506,167 @@ void v_add_fixed_me( return; } + +Word16 find_guarded_bits_fx( Word32 n ) +{ + // return n <= 1 ? 0 : n <= 2 ? 1 + // : n <= 4 ? 2 + // : n <= 8 ? 3 + // : n <= 16 ? 4 + // : n <= 32 ? 5 + // : n <= 64 ? 6 + // : n <= 128 ? 7 + // : n <= 256 ? 8 + // : n <= 512 ? 9 + // : n <= 1024 ? 10 + // : n <= 2048 ? 11 + // : n <= 4096 ? 12 + // : n <= 8192 ? 13 + // : n <= 16384 ? 14 + // : 15; + /*Word16 val = 0; + move32(); + test(); + WHILE( GT_32( n, L_shl( 1, val ) ) && LT_32( val, 16 ) ) + { + val = add( val, 1 ); + }*/ + IF( LE_32( n, 1 ) ) + { + return 0; + } + ELSE + { + + return sub( 31, norm_l( L_sub( n, 1 ) ) ); + } +} + +Word16 L_norm_arr( const Word32 *arr, Word16 size ) +{ + Word16 q = 31; + move16(); + FOR( Word16 i = 0; i < size; i++ ) + { + Word16 q_tst; + + q_tst = norm_l( arr[i] ); + if ( arr[i] != 0 ) + { + q = s_min( q, q_tst ); + } + } + + return q; +} + +Word16 norm_arr( Word16 *arr, Word16 size ) +{ + Word16 q = 15; + Word16 exp = 0; + move16(); + move16(); + FOR( Word16 i = 0; i < size; i++ ) + { + if ( arr[i] != 0 ) + { + exp = norm_s( arr[i] ); + } + if ( arr[i] != 0 ) + { + q = s_min( q, exp ); + } + } + return q; +} + +Word16 W_norm_arr( Word64 *arr, Word16 size ) +{ + Word16 q = 63; + Word16 exp = 0; + move16(); + move16(); + FOR( Word16 i = 0; i < size; i++ ) + { + if ( arr[i] != 0 ) + { + exp = W_norm( arr[i] ); + } + if ( arr[i] != 0 ) + { + q = s_min( q, exp ); + } + } + return q; +} + +Word16 get_min_scalefactor( Word32 x, Word32 y ) +{ + Word16 scf_y; + Word16 scf = Q31; + move16(); + + test(); + if ( x == 0 && y == 0 ) + { + scf = 0; + move16(); + } + + if ( x != 0 ) + { + scf = norm_l( x ); + } + + scf_y = norm_l( y ); + if ( y != 0 ) + { + scf = s_min( scf_y, scf ); + } + + return scf; +} + + +Flag is_zero_arr( Word32 *arr, Word16 size ) +{ + FOR( Word16 i = 0; i < size; i++ ) + IF( arr[i] != 0 ) + { + return 0; + } + + return 1; +} + +Flag is_zero_arr16( Word16 *arr, Word16 size ) +{ + FOR( Word16 i = 0; i < size; i++ ) + IF( arr[i] != 0 ) + { + return 0; + } + + return 1; +} + +void Scale_sig64( + Word64 x[], /* i/o: signal to scale Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp /* i : exponent: x = round(x << exp) Qx exp */ +) +{ + Word16 i; + assert( exp <= 63 && exp >= -63 ); + IF( exp == 0 ) + { + return; + } + + FOR( i = 0; i < len; i++ ) + { + /* saturation can occur here */ + x[i] = W_shl( x[i], exp ); + move64(); + } +} 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 0033e2c9e5d37a44f7ca4989d041c25881c5d0af..0683e266ce67faea01f2768f6b51a98bd56f3ab4 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -515,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 ); @@ -996,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/wi_fx.c b/lib_com/wi_fx.c index 7df4cb3f04098dfa42ec0d36e8885daab0e2326c..591645017b05fddc498af77d499f50e1433571a5 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -2901,11 +2901,11 @@ void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, W Ltemp1 = log10_fx( Ltemp1 ); /* subtract 10log10(2)*(2Q-13), Q23 */ - Ltemp1 = L_sub( Ltemp1, Ltemp3 ); + Ltemp1 = L_sub_sat( Ltemp1, Ltemp3 ); Ltemp1 = L_max( 0, Ltemp1 ); Ltemp2 = getSpEngyFromResAmp_fx( X_fx, 2828, X_fx->upper_cut_off_freq_fx, curr_lpc, sin_tab, cos_tab ); - Ltemp2 = log10_fx( Ltemp2 ); /* Ltemp1=10log10(eng_hb), Q23, need to adjust for Q factor of energy (2Q-13) */ - Ltemp2 = L_sub( Ltemp2, Ltemp3 ); /* Ltemp2 in Q23 */ + Ltemp2 = log10_fx( Ltemp2 ); /* Ltemp1=10log10(eng_hb), Q23, need to adjust for Q factor of energy (2Q-13) */ + Ltemp2 = L_sub_sat( Ltemp2, Ltemp3 ); /* Ltemp2 in Q23 */ Ltemp2 = L_max( 0, Ltemp2 ); @@ -2929,10 +2929,10 @@ void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, W tmp = round_fx( Ltemp ); /* tmp in Q(22-n) */ Ltemp1 = Mult_32_16( Ltemp1, tmp ); /* Q(30-n) */ n = sub( 8, exp ); - w[0] = round_fx( L_shl( Ltemp1, n ) ); /* w[0] in Q15 */ + w[0] = round_fx_sat( L_shl_sat( Ltemp1, n ) ); /* w[0] in Q15 */ move16(); Ltemp2 = Mult_32_16( Ltemp2, tmp ); - w[1] = round_fx( L_shl( Ltemp2, n ) ); /* w[1] in Q15 */ + w[1] = round_fx_sat( L_shl_sat( Ltemp2, n ) ); /* w[1] in Q15 */ move16(); logLag = log10_fx( X_fx->lag_fx ); /* logLag=10*log10(lag), Q23 */ diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 34d01d7fe0ea41b37e77e9096bfc0ebedb3f5128..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(); @@ -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 ); @@ -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_add( L_tmp, L_shr( Mpy_32_16_1( L_deposit_h( *pt6++ ), q2 ), Q_old_out ) ); /*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(); } 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/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index e50abddd6e25c43a74c5daa081dff5c2292dd242..e820f1399780d3fca13070925d67b8d76e443140 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -76,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; @@ -94,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 ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index b9170f5705dd904c515ef813888f406a10cae6ca..495ca5c006ecc49b9d7f3108d72d7bc55ef09912 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -113,7 +113,6 @@ ivas_error acelp_core_dec_fx( 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 ); @@ -125,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; @@ -666,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 } } diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 2ca524bb0f94e076b37665ba671474a2a87ab0a9..38999e99e4f462d9b9c0af182a5532afb935d672 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -77,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; @@ -133,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; @@ -178,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 ); @@ -188,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++ ) { @@ -621,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(); @@ -642,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 */ @@ -688,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) @@ -746,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 ) { @@ -781,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 ); @@ -804,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 } } @@ -848,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 } } @@ -944,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 ) { @@ -1129,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 @@ -1291,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 */ @@ -1340,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 ) @@ -1766,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(); @@ -1803,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 @@ -1903,16 +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) + 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++ ) { @@ -1932,16 +1835,18 @@ ivas_error acelp_core_dec_ivas_fx( } } -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#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 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#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++ ) { @@ -1953,18 +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(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#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 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ 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 { @@ -2003,20 +1911,13 @@ ivas_error acelp_core_dec_ivas_fx( #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 -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#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 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ -#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 +#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(); @@ -2030,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(); @@ -2057,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 @@ -2111,29 +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 } +#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) + 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 */ -#ifndef MSAN_FIX - Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); -#endif +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifdef OPT_SBA_AVOID_SPAR_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 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ - -#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 +#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 @@ -2146,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*/ @@ -2173,24 +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 ); -#ifdef MSAN_FIX 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 } } @@ -2225,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 } @@ -2270,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_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 6a1e60b06dac404bef32af8e4fbf91f2f690fb9c..7657491885adbc296ef9f41cfad150842b149f7e 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -128,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 ); @@ -819,11 +815,7 @@ 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; @@ -840,20 +832,25 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } /*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*/ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), 0, st_fx->cldfbSyn ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), st_fx->cldfbSyn ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#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/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 1f6b0dd5178407824010789fac18653a76897de7..ba7c73741751664b8b8545bcdb85a0d66fc6f557 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -898,9 +898,7 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; -#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; @@ -2058,11 +2056,11 @@ static void core_switch_lb_upsamp_fx( } /* synthesis of the combined signal */ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#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 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), st->cldfbSyn ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ /*rescaling whole buffer to a common Q*/ no_col = st->cldfbSyn->no_col; @@ -2100,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 ); @@ -2241,10 +2234,8 @@ ivas_error core_switching_pre_dec_ivas_fx( 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; @@ -2262,9 +2253,7 @@ ivas_error core_switching_pre_dec_ivas_fx( 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 ) @@ -2379,11 +2368,11 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#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 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, st->cldfbSyn ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#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 ); @@ -2587,9 +2576,7 @@ ivas_error core_switching_pre_dec_ivas_fx( 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 ) @@ -2639,9 +2626,7 @@ ivas_error core_switching_pre_dec_ivas_fx( 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 ) @@ -2662,11 +2647,7 @@ ivas_error core_switching_pre_dec_ivas_fx( { 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(); diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index 07750469f1515adef0f16688151631db8c2fef4b..51cbef624c6ea7d74e2a0b70cd7c4e6727ef2ba8 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -169,6 +169,7 @@ void D_ACELP_indexing_fx( pulses = pulsestrack[0]; move16(); +#ifndef FIX_1378_ACELP_OUT_OF_BOUNDS /* safety check in case of bit errors */ IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) { @@ -177,9 +178,20 @@ void D_ACELP_indexing_fx( move16(); return; } +#endif IF( pulses ) { +#ifdef FIX_1378_ACELP_OUT_OF_BOUNDS + /* safety check in case of bit errors */ + IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) + { + set16_fx( code, 0, L_SUBFR ); + *BER_detect = 1; + move16(); + return; + } +#endif D_ACELP_decode_arithtrack_fx( code, s, pulses, num_tracks, 16 ); } ELSE 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_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 8ff50f8a521a84f1561dcd9fd3ed0d64be9eadae..af80ee1f54e8672c19b05e6c29432d91639ccd3f 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2636,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(); } } @@ -2682,11 +2682,7 @@ void IMDCT_ivas_fx( } move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE set16_fx( win_fx, 0, ( L_FRAME_PLUS + L_MDCT_OVLP_MAX ) >> 1 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - set16_fx( win_fx, 0, shr( add( L_FRAME_PLUS, L_MDCT_OVLP_MAX ), 1 ) ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ 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 */ @@ -2865,16 +2861,10 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = q_xn_buf_fx_32; move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE Word16 diff = sub( q_tmp_fx_32, q_win ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - old_out_fx_32[ind] = L_shl( old_out_fx[ind], sub( q_tmp_fx_32, q_win ) ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ move32(); } @@ -2882,13 +2872,8 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE 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 ) ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - 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 ) ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ move16(); move16(); } @@ -2912,39 +2897,24 @@ 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 ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE xn_buf_fx[( ind + ( overlap / 2 ) ) + nz] = extract_l( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - 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 ) ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ 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 ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE q_diff = sub( q_old_out, q_win ); Word16 diff = sub( q_tmp_fx_32, q_win ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); move16(); xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff ); move16(); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - old_out_fx[ind] = shr_sat( old_out_fx[ind], sub( q_old_out, q_win ) ); - move16(); - xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], sub( q_tmp_fx_32, q_win ) ); - move16(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ } } aldo = 1; @@ -4441,11 +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 ) ) { -#ifdef NONBE_FIX_1402_WAVEADJUST st->hPlcInfo->subframe_fx = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) ); -#else - st->hPlcInfo->subframe = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) ); -#endif move16(); } } diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index f9833e80a85cc38309828ee2b6f2d0764df82741..0bc7794dc7b8322b5e9f670b889945c80aebebdf 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -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/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index c509d5d1028b46af70fc21b31ddc1953b2e8fd10..4c42a795997fa4bcc4b1372ce91ec35361e16bb3 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -187,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; } @@ -1320,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 ); @@ -1536,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);*/ @@ -1687,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(); } @@ -1761,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(); } @@ -5069,7 +5067,14 @@ void FdCng_decodeSID_ivas_fx( } scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + 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 ); @@ -5275,24 +5280,16 @@ void generate_stereo_masking_noise_fx( 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*/ + 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_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 ) { diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 6c63377fd4798954750060a7477bcf5bf9ad161e..8f29eb9d13ce53f72ad042cec7c6fe757ca09f7d 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -92,11 +92,7 @@ void decod_audio_fx( } /* set bit-allocation */ -#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 /*---------------------------------------------------------------* * Decode energy dynamics @@ -522,11 +518,7 @@ void decod_audio_ivas_fx( } /* set bit-allocation */ -#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 /*---------------------------------------------------------------* * Decode energy dynamics @@ -1372,14 +1364,10 @@ void gsc_dec_ivas_fx( } 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(); @@ -1435,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 } } diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 714245514e4e3987f3e51f53e8e8aa2a4ca99834..4d1ef677471054485e43ff9c2a27c3b2058f86d3 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -627,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; @@ -951,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 ); diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index d72f0ec452223ac8c1d4ae9b65ea060f164b043a..89864bc3b7f272c2c992b4f253242c0d7217b5e5 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -100,7 +100,6 @@ void hq_pred_hb_bws_fx( } ELSE { -#ifdef EVS_FUNC_MODIFIED st_fx->prev_ener_shb_fx = 0; move16(); L_tmp = L_deposit_l( 0 ); @@ -111,15 +110,6 @@ void hq_pred_hb_bws_fx( L_tmp = Mpy_32_16_1( L_tmp, 2979 ); // Q1 st_fx->prev_ener_shb_fx = extract_l( L_tmp ); /*Q1*/ move16(); -#else - st_fx->prev_ener_shb_fx = 0; - move16(); - FOR( i = 0; i < SWB_FENV - 3; i++ ) - { - st_fx->prev_ener_shb_fx = add( st_fx->prev_ener_shb_fx, SWB_fenv[i] ); /*Q1*/ - } - st_fx->prev_ener_shb_fx = mult( st_fx->prev_ener_shb_fx, 2979 ); /*Q1*/ -#endif } } diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index efb00234e7403de53c1953c094fb709103ba7be9..5c2bff4e734aaae0f107ec51e57e00d68e294e14 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -123,8 +123,8 @@ return noise; } static Word16 ivas_IGF_replaceTCXNoise_1_fx( /**< out: Q0 | number of noise bands */ - const Word32 *in, /**< in: Q31 | MDCT spectrum */ - Word16 s_l, /**< in: Q0 | noise headroom */ + const Word32 *in, /**< in: in_exp | MDCT spectrum */ + Word16 in_exp, /**< in: Q0 | noise headroom */ const Word16 *TCXNoise, /**< in: Q0 | tcx noise indicator vector */ const Word16 start, /**< in: Q0 | start MDCT subband index */ const Word16 stop, /**< in: Q0 | stop MDCT subband index */ @@ -132,41 +132,44 @@ static Word16 ivas_IGF_replaceTCXNoise_1_fx( /**< out: Q Word16 *totalNoiseNrg_exp ) { Word16 sb; - Word16 tmp16; + Word16 tmp16, shift; Word16 noise; + Word32 tmp32; Word64 nE; - tmp16 = 0; + shift = 2; move16(); noise = 0; move16(); - s_l = sub( s_l, 5 ); nE = 0; move64(); + *totalNoiseNrg = 0; + move32(); + *totalNoiseNrg_exp = 0; + move16(); + FOR( sb = start; sb < stop; sb++ ) { IF( TCXNoise[sb] ) { - tmp16 = extract_h( L_shl( in[sb], s_l ) ); // Q31 + s_l - } - IF( TCXNoise[sb] ) - { - nE = W_mac_16_16( nE, tmp16, tmp16 ); // Q31 + s_l - } - IF( TCXNoise[sb] ) - { - noise = add( noise, 1 ); // Q0 + tmp32 = L_shr( in[sb], shift ); + nE = W_mac_32_32( nE, tmp32, tmp32 ); // 62 - (in_exp + shift + in_exp + shift + 1) + noise = add( noise, 1 ); } } - tmp16 = W_norm( nE ); - nE = W_shl( nE, tmp16 ); - *totalNoiseNrg = W_extract_h( nE ); - move32(); - *totalNoiseNrg_exp = sub( tmp16, 32 ); - move16(); + IF( nE ) + { + tmp16 = W_norm( nE ); + nE = W_shl( nE, tmp16 ); + *totalNoiseNrg = W_extract_h( nE ); + move32(); + *totalNoiseNrg_exp = sub( add( shl( shift, 1 ), shl( in_exp, 1 ) ), tmp16 ); + move16(); + } + return noise; } @@ -2883,9 +2886,6 @@ static void IGF_getWhiteSpectralData_ivas( Word16 j; Word32 ak; Word16 ak_e; -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Word16 tmp_16; -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ Word16 tmp_e; Word16 out_e_arr[IGF_START_MX + MAX_IGF_SFB_LEN]; Word16 max_out_e; @@ -2904,23 +2904,18 @@ static void IGF_getWhiteSpectralData_ivas( Word16 guard_bits = add( find_guarded_bits_fx( add( i_mult( 2, level ), 1 ) ), 1 ) / 2; s_l = sub( s_l, guard_bits ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE Word16 shift = sub( shl( s_l, 1 ), 32 ); Word16 eff_e = sub( shl( sub( in_e, s_l ), 1 ), 15 ); Word16 diff = add( 21, in_e ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ Word16 quo = BASOP_Util_Divide3216_Scale( ONE_IN_Q30, add( shl( level, 1 ), 1 ), &tmp_e ); tmp_e = add( tmp_e, 1 ); ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 -#ifdef OPT_SBA_AVOID_SPAR_RESCALE ak_e = sub( ak_e, 1 ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( i = start; i < stop - level; i++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE Word64 temp = 0; move64(); FOR( j = i - level; j < i + level + 1; j++ ) @@ -2935,30 +2930,11 @@ static void IGF_getWhiteSpectralData_ivas( out_e_arr[i] = sub( diff, n ); move16(); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - ak = 0; - move32(); - move32(); - FOR( j = i - level; j < i + level + 1; j++ ) - { - tmp_16 = extract_h( L_shl( in[j], s_l ) ); // e: in_e - s_l - ak = L_mac( ak, tmp_16, tmp_16 ); // e: 2 * (in_e - s_l) - } - ak = Mult_32_16( ak, quo ); // add( shl( level, 1 ), 1 ), &tmp_e ) ); - - - n = sub( 30, add( norm_l( ak ), sub( 31, ak_e ) ) ); - n = shr( n, 1 ); - - out_e_arr[i] = add( sub( 21, n ), in_e ); - move16(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ max_out_e = s_max( max_out_e, out_e_arr[i] ); } FOR( ; i < stop; i++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE Word64 temp = 0; move64(); @@ -2974,24 +2950,6 @@ static void IGF_getWhiteSpectralData_ivas( out_e_arr[i] = sub( diff, n ); move16(); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - ak = 0; - move32(); - - FOR( j = i - level; j < stop; j++ ) - { - tmp_16 = extract_h( L_shl( in[j], s_l ) ); // e: in_e - s_l - ak = L_mac( ak, tmp_16, tmp_16 ); // e: 2 * (in_e - s_l) - } - ak = L_deposit_h( BASOP_Util_Divide3216_Scale( ak, sub( stop, sub( i, level ) ), &tmp_e ) ); - ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 - - n = sub( 30, add( norm_l( ak ), sub( 31, ak_e ) ) ); - n = shr( n, 1 ); - - out_e_arr[i] = add( sub( 21, n ), in_e ); - move16(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ max_out_e = s_max( max_out_e, out_e_arr[i] ); } @@ -3578,14 +3536,8 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in specMed_e = igf_spec_e[i]; move16(); - /*14 seems to be precise enough*/ - hPrivateData->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( - hInstance->infoTCXNoise_ptr, - igf_spec + hGrid->minSrcSubband, - sub( hGrid->startLine, hGrid->minSrcSubband ) ); - move16(); hPrivateData->n_noise_bands = ivas_IGF_replaceTCXNoise_1_fx( igf_spec, - hPrivateData->headroom_TCX_noise_white, + igf_spec_e[i], hInstance->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, @@ -3593,9 +3545,6 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in &hPrivateData->totalNoiseNrg_exp ); move16(); - hPrivateData->totalNoiseNrg_exp = sub( shl( sub( igf_spec_e[i], sub( hPrivateData->headroom_TCX_noise_white, 5 ) ), 1 ), hPrivateData->totalNoiseNrg_exp ); - move16(); - BREAK; } } @@ -3605,22 +3554,15 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in { IF( EQ_16( hPrivateData->currWhiteningLevel[i], IGF_WHITENING_OFF ) ) { - hPrivateData->headroom_TCX_noise = IGF_getScaleFactor32Cond( - hInstance->infoTCXNoise_ptr, - hPrivateData->pSpecFlat + hGrid->minSrcSubband, - sub( hGrid->startLine, hGrid->minSrcSubband ) ); - move16(); hPrivateData->n_noise_bands_off = ivas_IGF_replaceTCXNoise_1_fx( hPrivateData->pSpecFlat, - hPrivateData->headroom_TCX_noise, + hPrivateData->pSpecFlat_exp, hInstance->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg_off, &hPrivateData->totalNoiseNrg_off_exp ); move16(); - hPrivateData->totalNoiseNrg_off_exp = sub( shl( sub( hPrivateData->pSpecFlat_exp, sub( hPrivateData->headroom_TCX_noise, 5 ) ), 1 ), hPrivateData->totalNoiseNrg_off_exp ); - move16(); BREAK; } } @@ -3805,12 +3747,9 @@ void IGFDecApplyStereo( move16(); } - hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_ptr + hGrid->minSrcSubband, - igf_specL_fx + hGrid->minSrcSubband, - sub( hGrid->startLine, hGrid->minSrcSubband ) ); - move16(); + hPrivateDataL->n_noise_bands = ivas_IGF_replaceTCXNoise_1_fx( igf_specL_fx, - hPrivateDataL->headroom_TCX_noise_white, + specMedL_e, hIGFDecL->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, @@ -3818,9 +3757,6 @@ void IGFDecApplyStereo( &hPrivateDataL->totalNoiseNrg_exp ); move16(); - hPrivateDataL->totalNoiseNrg_exp = sub( shl( sub( specMedL_e, sub( hPrivateDataL->headroom_TCX_noise_white, 5 ) ), 1 ), hPrivateDataL->totalNoiseNrg_exp ); - move16(); - IF( !bfi ) { s_l = getScaleFactor32( hPrivateDataR->pSpecFlat + hGrid->minSrcSubband - whiteningLevel, @@ -3841,21 +3777,14 @@ void IGFDecApplyStereo( move16(); } - hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_ptr, - igf_specR_fx + hGrid->minSrcSubband, - sub( hGrid->startLine, hGrid->minSrcSubband ) ); - move16(); hPrivateDataR->n_noise_bands = ivas_IGF_replaceTCXNoise_1_fx( igf_specR_fx, - hPrivateDataR->headroom_TCX_noise_white, + specMedR_e, hIGFDecR->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg, &hPrivateDataR->totalNoiseNrg_exp ); move16(); - hPrivateDataR->totalNoiseNrg_exp = sub( shl( sub( specMedR_e, sub( hPrivateDataR->headroom_TCX_noise_white, 5 ) ), 1 ), hPrivateDataR->totalNoiseNrg_exp ); - move16(); - BREAK; } } @@ -3865,37 +3794,23 @@ void IGFDecApplyStereo( test(); IF( EQ_16( hPrivateDataL->currWhiteningLevel[i], IGF_WHITENING_OFF ) || EQ_16( hPrivateDataR->currWhiteningLevel[i], IGF_WHITENING_OFF ) ) { - hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_ptr + hGrid->minSrcSubband, - hPrivateDataL->pSpecFlat + hGrid->minSrcSubband, - sub( hGrid->startLine, hGrid->minSrcSubband ) ); hPrivateDataL->n_noise_bands_off = ivas_IGF_replaceTCXNoise_1_fx( hPrivateDataL->pSpecFlat, - hPrivateDataL->headroom_TCX_noise_white, + hPrivateDataL->pSpecFlat_exp, hIGFDecL->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataL->totalNoiseNrg_off, &hPrivateDataL->totalNoiseNrg_off_exp ); - hPrivateDataL->totalNoiseNrg_off_exp = sub( shl( sub( hPrivateDataL->pSpecFlat_exp, sub( hPrivateDataL->headroom_TCX_noise_white, 5 ) ), 1 ), hPrivateDataL->totalNoiseNrg_off_exp ); - move16(); - move16(); move16(); - hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_ptr, - hPrivateDataR->pSpecFlat + hGrid->minSrcSubband, - sub( hGrid->startLine, hGrid->minSrcSubband ) ); hPrivateDataR->n_noise_bands_off = ivas_IGF_replaceTCXNoise_1_fx( hPrivateDataR->pSpecFlat, - hPrivateDataR->headroom_TCX_noise_white, + hPrivateDataR->pSpecFlat_exp, hIGFDecR->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg_off, &hPrivateDataR->totalNoiseNrg_off_exp ); - hPrivateDataR->totalNoiseNrg_off_exp = sub( shl( sub( hPrivateDataR->pSpecFlat_exp, sub( hPrivateDataR->headroom_TCX_noise_white, 5 ) ), 1 ), hPrivateDataR->totalNoiseNrg_off_exp ); - move16(); move16(); - move16(); - - BREAK; } } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 934433132a702fb29af374d0d171bda50ca6c123..b588fdce1bd047a957cc644092befc7ee5368519 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -315,10 +315,8 @@ ivas_error init_decoder_fx( move16(); /*1; Q15*/ st_fx->exc_pe_fx = 0; // Q_stat_noise move16(); -#ifdef MSAN_FIX st_fx->Q_stat_noise = 31; move16(); -#endif // MSAN_FIX /*-----------------------------------------------------------------* * LD music post-filter *-----------------------------------------------------------------*/ @@ -1036,10 +1034,8 @@ ivas_error init_decoder_ivas_fx( move16(); st_fx->exc_pe_fx = 0; move16(); -#ifdef MSAN_FIX st_fx->Q_stat_noise = 31; move16(); -#endif st_fx->prev_coder_type = GENERIC; move16(); @@ -1139,9 +1135,7 @@ ivas_error init_decoder_ivas_fx( } hf_synth_init_fx( st_fx->hBWE_zero ); -#ifdef MSAN_FIX set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif } ELSE { diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 6f550eab943ab95933937dbda06e4c3093ad169d..0709c6b7543533648436a277a56ea2ff6ab4fac5 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -71,23 +71,15 @@ static void ivas_binRenderer_filterModule_fx( { Word16 bandIdx, k, chIdx, tapIdx; Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; -#ifdef OPT_BASOP_ADD_v1 Word16 Q_filterStates; -#else /* OPT_BASOP_ADD_v1 */ - Word16 *Q_filterStates; -#endif /* OPT_BASOP_ADD_v1 */ const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; Word16 shift_q; #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef OPT_BASOP_ADD_v1 Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; move16(); -#endif /* OPT_BASOP_ADD_v1 */ #else -#ifdef OPT_BASOP_ADD_v1 Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; move16(); -#endif /* OPT_BASOP_ADD_v1 */ #endif FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) @@ -97,15 +89,9 @@ static void ivas_binRenderer_filterModule_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); -#ifndef OPT_BASOP_ADD_v1 - Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx][0] ); -#endif #else filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); -#ifndef OPT_BASOP_ADD_v1 - Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx][0] ); -#endif /* OPT_BASOP_ADD_v1 */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 @@ -128,13 +114,6 @@ static void ivas_binRenderer_filterModule_fx( filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; move32(); -#ifndef OPT_BASOP_ADD_v1 - shift_q = sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ); - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); -#endif /* OPT_BASOP_ADD_v1 */ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates @@ -147,27 +126,16 @@ static void ivas_binRenderer_filterModule_fx( outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates -#ifndef OPT_BASOP_ADD_v1 - Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1]; - move16(); -#endif /* OPT_BASOP_ADD_v1 */ } -#ifdef OPT_BASOP_ADD_v1 shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); -#else /* OPT_BASOP_ADD_v1 */ - shift_q = add( sub( Q_filterStates[1], Q_curr ), 1 ); -#endif /* OPT_BASOP_ADD_v1 */ -#ifdef OPT_BASOP_ADD_v1 IF( shift_q != 0 ) { -#endif /* OPT_BASOP_ADD_v1 */ outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr -#ifdef OPT_BASOP_ADD_v1 #ifdef SPLIT_REND_WITH_HEAD_ROT hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; #else @@ -175,16 +143,11 @@ static void ivas_binRenderer_filterModule_fx( #endif move16(); } -#endif /* OPT_BASOP_ADD_v1 */ filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; move32(); filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; move32(); -#ifndef OPT_BASOP_ADD_v1 - Q_filterStates[0] = Q_curr; - move16(); -#endif /* OPT_BASOP_ADD_v1 */ /* Left Real and Imag */ @@ -379,17 +342,10 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifdef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#else - IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { @@ -403,12 +359,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -422,12 +372,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -440,13 +384,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -462,12 +399,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -481,12 +412,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -499,13 +424,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ } } #endif @@ -552,12 +470,8 @@ static ivas_error ivas_binRenderer_convModuleOpen( #ifndef SPLIT_REND_WITH_HEAD_ROT set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); -#ifdef OPT_BASOP_ADD_v1 hBinRenConvModule->Q_filterStatesLeft = 31; move16(); -#else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); -#endif /* OPT_BASOP_ADD_v1 */ #endif /* !SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { @@ -573,12 +487,8 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); -#ifdef OPT_BASOP_ADD_v1 hBinRenConvModule->Q_filterStatesLeft = 31; move16(); -#else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); -#endif /* OPT_BASOP_ADD_v1 */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { @@ -627,10 +537,8 @@ static ivas_error ivas_binRenderer_convModuleOpen( { for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { -#ifdef OPT_BASOP_ADD_v1 hBinRenConvModule->Q_filterStates[pos_idx] = 31; move16(); -#endif for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) @@ -638,9 +546,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); -#ifndef OPT_BASOP_ADD_v1 - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); -#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -649,10 +554,8 @@ static ivas_error ivas_binRenderer_convModuleOpen( { for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { -#ifdef OPT_BASOP_ADD_v1 hBinRenConvModule->Q_filterStates[pos_idx] = 31; move16(); -#endif for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) @@ -660,9 +563,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); -#ifndef OPT_BASOP_ADD_v1 - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); -#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -1652,11 +1552,6 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; -#ifndef OPT_BASOP_ADD_v1 - - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; -#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); @@ -1664,22 +1559,12 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; -#ifndef OPT_BASOP_ADD_v1 - - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; -#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; -#ifndef OPT_BASOP_ADD_v1 - - free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; -#endif /* OPT_BASOP_ADD_v1 */ } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) @@ -1691,11 +1576,6 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] = NULL; - -#ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] ); - hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] = NULL; -#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] ); @@ -1703,11 +1583,6 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] = NULL; - -#ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft[bandIdx] = NULL; -#endif /* OPT_BASOP_ADD_v1 */ } #endif free( hBinRenConvModule->filterStatesLeftReal_fx ); @@ -1716,10 +1591,6 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx ); hBinRenConvModule->filterStatesLeftImag_fx = NULL; -#ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft ); - hBinRenConvModule->Q_filterStatesLeft = NULL; -#endif /* OPT_BASOP_ADD_v1 */ free( ( *hBinRenderer )->hBinRenConvModule ); ( *hBinRenderer )->hBinRenConvModule = NULL; diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 37c32a8b1b48043bd560da49d386c2a3321ff54f..03f0e4b40a7904afa92be4f0e71e70df0845e214 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -73,6 +73,8 @@ ivas_error ivas_core_dec_fx( Word16 tmp16, tmp16_2, j; Word16 Q_white_exc; + set16_fx( tmp_buffer_fx, 0, L_FRAME48k ); + Word16 tmps, incr; Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; @@ -336,11 +338,7 @@ ivas_error ivas_core_dec_fx( Word16 ovl, fade_len; IF( NE_16( sts[0]->L_frame, sts[0]->last_L_frame ) ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 -#endif L_lerp_fx_q11( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->L_frame, sts[0]->last_L_frame ); Copy_Scale_sig_32_16( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( sts[0]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB } @@ -527,12 +525,8 @@ ivas_error ivas_core_dec_fx( return error; } -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 -#else - Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 -#endif - Scale_sig( output_16_fx[n], L_FRAME48k, negate( st->Q_syn2 ) ); // Q0 + Scale_sig( output_16_fx[n], L_FRAME48k, negate( st->Q_syn2 ) ); // Q0 IF( st->cldfbAna ) { scale_sig32( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, Q10 - Q11 ); /* 9 * (Word16)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f) , Q10 */ @@ -551,9 +545,6 @@ ivas_error ivas_core_dec_fx( st->cldfbSyn->Q_cldfb_state = Q11; move16(); } -#ifndef FIX_ISSUE_1279 /* the update of prev_Q_syn is already done inside rescale_mem( ) */ - st->prev_Q_syn = st->Q_syn; -#endif move16(); IF( save_hb_synth_32_fx ) @@ -641,12 +632,8 @@ ivas_error ivas_core_dec_fx( ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_16_fx[n], &Q_output ); Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_output ) ); // Q11 -#ifdef MSAN_FIX - Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); // Q0 -#else - Scale_sig( synth_16_fx[n], L_FRAME48k, negate( Q_synth ) ); -#endif - Scale_sig( output_16_fx[n], L_FRAME48k, negate( Q_output ) ); // Q0 + Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); // Q0 + Scale_sig( output_16_fx[n], L_FRAME48k, negate( Q_output ) ); // Q0 } /*---------------------------------------------------------------------* @@ -660,11 +647,7 @@ ivas_error ivas_core_dec_fx( td_stereo_param_updt_fx( st->lsp_old_fx, st->lsf_old_fx, st->old_pitch_buf_16_fx + st->nb_subfr, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, hStereoTD->tdm_Pri_pitch_buf_fx, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, add( imult1616( 2, NB_SUBFR16k ), 2 ), Q10 ); // Q16 -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, add( imult1616( 2, NB_SUBFR16k ), 2 ), Q10 ); // Q16 -#endif } } /* n_channels loop */ @@ -910,19 +893,11 @@ ivas_error ivas_core_dec_fx( /* Memories Re-Scaling */ IF( hBWE_TD != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, hBWE_TD->prev_Q_bwe_syn2 ) ); // Q11 Copy_Scale_sig_16_32_no_sat( hBWE_TD->old_tbe_synth_fx, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, hBWE_TD->prev_Qx ) ); // Q11 Copy_Scale_sig_16_32_no_sat( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, hBWE_TD->prev_Qx ) ); // Q11 Copy_Scale_sig_16_32_no_sat( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, hBWE_TD->prev_Qx ) ); // Q11 Copy_Scale_sig_16_32_no_sat( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, hBWE_TD->prev_Qx ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, st->prev_Q_bwe_syn2 ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( hBWE_TD->old_tbe_synth_fx, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, st->prev_Qx ) ); // Q11 -#endif Copy( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->state_32and48k_WB_upsample_fx, ( 2 * ALLPASSSECTIONS_STEEP ) ); } @@ -936,11 +911,7 @@ ivas_error ivas_core_dec_fx( test(); IF( sba_dirac_stereo_flag && NE_16( st->element_mode, IVAS_CPE_MDCT ) && !( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx -#else - Copy_Scale_sig_16_32_DEPREC( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx -#endif } IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) @@ -954,11 +925,7 @@ ivas_error ivas_core_dec_fx( test(); IF( sba_dirac_stereo_flag && hSCE && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx -#else - Copy_Scale_sig_16_32_DEPREC( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx -#endif } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ @@ -985,11 +952,7 @@ ivas_error ivas_core_dec_fx( } ELSE { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( st->delay_buf_out_fx, st->delay_buf_out32_fx, ( HQ_DELTA_MAX * HQ_DELAY_COMP ), sub( Q11, st->hHQ_core->Q_old_postdec ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( st->delay_buf_out_fx, st->delay_buf_out32_fx, ( HQ_DELTA_MAX * HQ_DELAY_COMP ), sub( Q11, st->hHQ_core->Q_old_postdec ) ); // Q11 -#endif } Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 @@ -1003,16 +966,12 @@ ivas_error ivas_core_dec_fx( move16(); } -#ifdef MSAN_FIX IF( Q_synth > 0 ) { Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); // Q0 Q_synth = 0; move16(); } -#else - Scale_sig( synth_16_fx[n], L_FRAME48k, negate( Q_synth ) ); -#endif /*------------------reset-code-start---------------------*/ @@ -1078,31 +1037,17 @@ ivas_error ivas_core_dec_fx( } /* Memories Re-Scaling */ -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], L_FRAME48k, sub( Q11, Q_synth_fx ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( synth_16_fx[n], synth_32_fx[n], L_FRAME48k, sub( Q11, Q_synth_fx ) ); // Q11 -#endif IF( hBWE_FD != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hBWE_FD->L_old_wtda_swb_fx, hBWE_FD->L_old_wtda_swb_fx32, L_FRAME48k, sub( Q11, hBWE_FD->old_wtda_swb_fx_exp ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hBWE_FD->L_old_wtda_swb_fx, hBWE_FD->L_old_wtda_swb_fx32, L_FRAME48k, sub( Q11, hBWE_FD->old_wtda_swb_fx_exp ) ); // Q11 -#endif } IF( hBWE_TD != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hBWE_TD->old_tbe_synth_fx, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, hBWE_TD->prev_Qx ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hBWE_TD->old_tbe_synth_fx, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, hBWE_TD->prev_Qx ) ); // Q11 -#endif } /*---------------------------------------------------------------------* @@ -1204,12 +1149,8 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 -#ifdef MSAN_FIX - Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 -#else - Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, L_FRAME48k, negate( add( Q11, q ) ) ); -#endif + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 @@ -1242,7 +1183,6 @@ ivas_error ivas_core_dec_fx( move32(); } stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); -#ifdef MSAN_FIX test(); test(); test(); @@ -1254,10 +1194,6 @@ ivas_error ivas_core_dec_fx( Scale_sig32( hb_synth_32_fx[0], output_frame, sub( Q11, q ) ); // Q11 Scale_sig32( hb_synth_32_fx[1], output_frame, sub( Q11, q ) ); // Q11 } -#else - Scale_sig32( hb_synth_32_fx[0], L_FRAME48k, sub( Q11, q ) ); - Scale_sig32( hb_synth_32_fx[1], L_FRAME48k, sub( Q11, q ) ); -#endif } IF( EQ_16( st->element_mode, EVS_MONO ) ) @@ -1286,11 +1222,7 @@ ivas_error ivas_core_dec_fx( } waveform_adj2_fix( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth_16_fx[n] + tmps, tmps, add( st->hPlcInfo->nbLostCmpt, 1 ), st->bfi ); -#ifdef NONBE_FIX_1402_WAVEADJUST st->hPlcInfo->Pitch_fx = 0; -#else - st->hPlcInfo->Pitch = 0; -#endif move16(); } } @@ -1476,13 +1408,8 @@ ivas_error ivas_core_dec_fx( IF( st->hHQ_core != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, st->hHQ_core->Q_old_wtda_LB ) ); // Q11 Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, st->hHQ_core->Q_old_wtda ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, st->hHQ_core->Q_old_wtda_LB ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, st->hHQ_core->Q_old_wtda ) ); // Q11 -#endif } IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 05fec7736b263716311dfd87dec696ec4fa5aae0..c10c6beda022acd7c4dbefdb47d957741647b4c4 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -124,22 +124,14 @@ ivas_error ivas_cpe_dec_fx( test(); IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda ) ); // Q11 -#endif } } FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 -#endif hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = Q11; move16(); } diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 67af183d07d6c75bde50da560fa09eb4da61b6c1..44a024e549e94a5e1d49a59ba8c2233206dc2bdc 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2177,11 +2177,7 @@ void ivas_dirac_dec_render_fx( FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { -#ifdef MSAN_FIX ivas_dirac_dec_render_sf_fx( st_ivas, output_f_local_fx, nchan_transport, NULL, NULL ); -#else - ivas_dirac_dec_render_sf_fx( st_ivas, output_f_local, nchan_transport, NULL, NULL ); -#endif // MSAN_FIX n_samples_sf = i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slot_size ); @@ -2293,7 +2289,12 @@ void ivas_dirac_dec_render_sf_fx( DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; Word16 num_channels_dir, exp; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 q_diffuseness_vector = Q31, q_reference_power_smooth[2] = { Q31, Q31 }; + move16(); +#else Word16 q_diffuseness_vector = Q31, q_reference_power_smooth = Q31; +#endif move16(); move16(); Word16 proto_power_smooth_len = 0; @@ -2533,10 +2534,37 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev+ tmp1) hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp1 ); move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + tmp1 = 31; + move16(); + FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + tmp1 = s_min( tmp1, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + } + FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], tmp1 ); + move16(); + tmp1 = 31; + move16(); + FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + tmp1 = s_min( tmp1, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + } + FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], tmp1 ); + move16(); +#else tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, tmp1 ); move16(); +#endif IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) { tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); @@ -2655,7 +2683,7 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i] = L_add( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], surCohEner_fx ); // Q29 move32(); - surCohRatio_fx[i] = BASOP_Util_Divide3232_Scale_cadence( surCohEner_fx, ( L_add( EPSILLON_FX, L_add( dirEne_fx, surCohEner_fx ) ) ), &temp_q ); + surCohRatio_fx[i] = BASOP_Util_Divide3232_Scale_newton( surCohEner_fx, ( L_add( EPSILLON_FX, L_add( dirEne_fx, surCohEner_fx ) ) ), &temp_q ); move32(); surCohRatio_fx[i] = L_shl( surCohRatio_fx[i], sub( temp_q, 16 ) ); // Q15 move32(); @@ -2881,7 +2909,11 @@ void ivas_dirac_dec_render_sf_fx( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_fx, DirAC_mem.reference_power_q, +#else reference_power_fx, &DirAC_mem.reference_power_q, +#endif slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, @@ -2894,7 +2926,11 @@ void ivas_dirac_dec_render_sf_fx( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_fx, DirAC_mem.reference_power_q, +#else reference_power_fx, &DirAC_mem.reference_power_q, +#endif slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, @@ -2913,9 +2949,17 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, reference_power_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect, q_cldfb ); @@ -2939,9 +2983,17 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, reference_power_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif slot_idx, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, hDirACRend->hoa_decoder, @@ -2956,9 +3008,17 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, reference_power_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif hDirACRend->hOutSetup.is_loudspeaker_setup, slot_idx, hSpatParamRendCom->num_freq_bands, @@ -2981,9 +3041,17 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, reference_power_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif slot_idx, hDirACRend->num_protos_diff, hSpatParamRendCom->num_freq_bands, q_cldfb ); @@ -3046,7 +3114,12 @@ void ivas_dirac_dec_render_sf_fx( num_freq_bands, azimuth, elevation ); Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); +#ifdef FIX_867_CLDFB_NRG_SCALE + Scale_sig32( &( hDirACRend->buffer_energy_fx[add( i_mult( sub( index, 1 ), num_freq_bands ), CLDFB_NO_CHANNELS_HALF )] ), s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_q[1] ) ); + hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0]; +#else hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q; +#endif move16(); computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); @@ -3278,6 +3351,18 @@ void ivas_dirac_dec_render_sf_fx( IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + v_add_fixed_me( reference_power_fx, sub( 31, DirAC_mem.reference_power_q[0] ), + reference_power_smooth_fx, sub( 31, q_reference_power_smooth[0] ), + reference_power_smooth_fx, &temp_q, + s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 1 ); + q_reference_power_smooth[0] = sub( 31, temp_q ); + v_add_fixed_me( reference_power_fx + CLDFB_NO_CHANNELS_HALF, sub( 31, DirAC_mem.reference_power_q[1] ), + reference_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, sub( 31, q_reference_power_smooth[1] ), + reference_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, &temp_q, + s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), 1 ); + q_reference_power_smooth[1] = sub( 31, temp_q ); +#else IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) ) { Word32 temp; @@ -3320,6 +3405,7 @@ void ivas_dirac_dec_render_sf_fx( } v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 ); q_reference_power_smooth = sub( q_reference_power_smooth, 1 ); +#endif } } @@ -3518,6 +3604,51 @@ void ivas_dirac_dec_render_sf_fx( Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); // Q31 } +#ifdef FIX_867_CLDFB_NRG_SCALE + exp = L_norm_arr( reference_power_smooth_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ); + scale_sig32( reference_power_smooth_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), exp ); // q_reference_power_smooth[0] + exp + q_reference_power_smooth[0] = add( q_reference_power_smooth[0], exp ); + IF( LT_16( q_reference_power_smooth[0], hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_reference_power_smooth[0], hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // q_reference_power_smooth[0] + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = q_reference_power_smooth[0]; + move16(); + } + ELSE + { + Word32 temp; + FOR( i = 0; i < s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ); i++ ) + { + temp = L_shl( reference_power_smooth_fx[i], sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], q_reference_power_smooth[0] ) ); + reference_power_smooth_fx[i] = L_max( temp, L_min( reference_power_smooth_fx[i], 1 ) ); + move32(); + } + q_reference_power_smooth[0] = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0]; + move16(); + } + + exp = L_norm_arr( reference_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + scale_sig32( reference_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), exp ); // q_reference_power_smooth + exp + q_reference_power_smooth[1] = add( q_reference_power_smooth[1], exp ); + IF( LT_16( q_reference_power_smooth[1], hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_reference_power_smooth[1], hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // q_reference_power_smooth + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] = q_reference_power_smooth[1]; + move16(); + } + ELSE + { + Word32 temp; + FOR( i = CLDFB_NO_CHANNELS_HALF; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + temp = L_shl( reference_power_smooth_fx[i], sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], q_reference_power_smooth[1] ) ); + reference_power_smooth_fx[i] = L_max( temp, L_min( reference_power_smooth_fx[i], 1 ) ); + move32(); + } + q_reference_power_smooth[1] = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1]; + move16(); + } +#else exp = L_norm_arr( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); // q_reference_power_smooth + exp q_reference_power_smooth = add( q_reference_power_smooth, exp ); @@ -3548,6 +3679,7 @@ void ivas_dirac_dec_render_sf_fx( q_reference_power_smooth = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q; move16(); } +#endif IF( hDirACRend->masa_stereo_type_detect != NULL ) { @@ -3567,6 +3699,69 @@ void ivas_dirac_dec_render_sf_fx( } } +#ifdef FIX_867_CLDFB_NRG_SCALE + exp = 31; + move16(); + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + exp = s_min( exp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ) ) ); + } + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], exp ); + move16(); + exp = 31; + move16(); + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + exp = s_min( exp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + } + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], exp ); + move16(); + + IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) ) + { + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) ); // proto_power_smooth_q + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0]; + move16(); + } + ELSE + { + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) ); // proto_power_smooth_prev_q + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0]; + move16(); + } + IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ) + { + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // proto_power_smooth_q + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1]; + move16(); + } + ELSE + { + FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // proto_power_smooth_prev_q + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1]; + move16(); + } +#else exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len, exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, exp ); @@ -3583,6 +3778,7 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q; move16(); } +#endif exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + exp) @@ -3626,11 +3822,37 @@ void ivas_dirac_dec_render_sf_fx( hSpatParamRendCom->subframe_nbslots[subframe_idx], diffuseness_vector_fx, reference_power_smooth_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + q_reference_power_smooth, +#else &q_reference_power_smooth, +#endif qualityBasedSmFactor_fx, hDirAC->hConfig->enc_param_start_band, &q_Cldfb ); +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 allZero = 1; + move16(); + FOR( i = 0; i < proto_power_smooth_len; i++ ) + { + if ( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx[i] != 0 ) + { + allZero = 0; + move16(); + } + } + if ( allZero ) + { + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = 31; + move16(); + } + if ( allZero ) + { + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = 31; + move16(); + } +#else Word16 sh = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q; move16(); hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = 31; @@ -3643,6 +3865,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); } } +#endif FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) { @@ -3869,11 +4092,11 @@ void ivas_dirac_dec_render_sf_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col; move16(); @@ -3976,11 +4199,11 @@ void ivas_dirac_dec_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; move32(); } -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, 0, st_ivas->cldfbSynDec[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ IF( !st_ivas->hLsSetupCustom->separate_ch_found ) { @@ -4020,11 +4243,11 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); // Q6-1 st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[cldfbSynIdx] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ // Calculating length of output Word16 no_col = st_ivas->cldfbSynDec[cldfbSynIdx]->no_col; @@ -4092,12 +4315,11 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = ( Q6 - 1 ); move16(); - -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scaling output from Q6-1 to Q11 Scale_sig32( p_out, out_len, ( Q11 - ( Q6 - 1 ) ) ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index b247fd6531c63eec9e3d7291599349bc28feed98..6d367538d26d575e27d55756a9222a5c96d5c322 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -723,11 +723,7 @@ Word16 computeMixingMatrices_fx( Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; Word16 G_hat_buff_e[MAX_OUTPUT_CHANNELS]; -#ifdef OPT_BASOP_ADD_v1 Word16 mat_mult_buffer2_e, mat_mult_buffer3_e; -#else /* OPT_BASOP_ADD_v1 */ - Word16 mat_mult_buffer1_e, mat_mult_buffer2_e, mat_mult_buffer3_e; -#endif /* OPT_BASOP_ADD_v1 */ Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; @@ -777,9 +773,7 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); -#ifdef OPT_BASOP_ADD_v1 Word16 max_e = -32; -#endif /* OPT_BASOP_ADD_v1 */ /* Computing Ky */ FOR( i = 0; i < lengthCy; ++i ) { @@ -792,12 +786,9 @@ Word16 computeMixingMatrices_fx( move32(); Ky_fx_e[i + ( j * lengthCy )] = tmp_e; move16(); -#ifdef OPT_BASOP_ADD_v1 max_e = s_max( max_e, tmp_e ); -#endif /* OPT_BASOP_ADD_v1 */ } } -#ifdef OPT_BASOP_ADD_v1 FOR( i = 0; i < lengthCy * lengthCy; ++i ) { Ky_fx[i] = L_shr( Ky_fx[i], sub( max_e, Ky_fx_e[i] ) ); @@ -805,7 +796,6 @@ Word16 computeMixingMatrices_fx( Ky_fx_e[i] = max_e; move16(); } -#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Decomposition of Cx @@ -816,9 +806,7 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cx_fx, svd_in_buffer_fx, lengthCx, lengthCx, 0 ); svd_fx( svd_in_buffer_fx, Cx_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCx, lengthCx ); -#ifdef OPT_BASOP_ADD_v1 max_e = -32; -#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { FOR( j = 0; j < lengthCx; ++j ) @@ -830,12 +818,9 @@ Word16 computeMixingMatrices_fx( move32(); Kx_fx_e[( i + ( j * lengthCx ) )] = tmp_e; move16(); -#ifdef OPT_BASOP_ADD_v1 max_e = s_max( max_e, tmp_e ); -#endif /* OPT_BASOP_ADD_v1 */ } } -#ifdef OPT_BASOP_ADD_v1 FOR( i = 0; i < lengthCx * lengthCx; ++i ) { Kx_fx[i] = L_shr( Kx_fx[i], sub( max_e, Kx_fx_e[i] ) ); @@ -843,7 +828,6 @@ Word16 computeMixingMatrices_fx( Kx_fx_e[i] = max_e; move16(); } -#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { @@ -967,49 +951,15 @@ Word16 computeMixingMatrices_fx( /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ -#ifdef OPT_BASOP_ADD_v1 Word16 mat_mult_buffer1_fx_e; -#else /* OPT_BASOP_ADD_v1 */ - Word16 mat_mult_buffer1_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word16 Q_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; - set16_fx( Q_e_arr, Q_e, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); - - matrix_product_mant_exp( Kx_fx, Kx_fx_e, lengthCx, lengthCx, 1, Q_fx, Q_e_arr, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); -#endif /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer2_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; -#ifdef OPT_BASOP_ADD_v1 matrix_product_mant_exp_fx( Kx_fx, Kx_fx_e[0], lengthCx, lengthCx, 1, Q_fx, Q_e, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); matrix_diag_product_fx_2( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); matrix_product_mant_exp_fx( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e[0], lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); -#else /* OPT_BASOP_ADD_v1 */ - matrix_diag_product_fx_1( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); - - matrix_product_mant_exp( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e, lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); - - exp = mat_mult_buffer1_fx_e[0]; - move16(); - FOR( i = 1; i < lengthCy * lengthCx; i++ ) - { - if ( LT_16( exp, mat_mult_buffer1_fx_e[i] ) ) - { - exp = mat_mult_buffer1_fx_e[i]; - move16(); - } - } - - FOR( i = 0; i < lengthCy * lengthCx; i++ ) - { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_fx_e[i] ) ); // Q(31-exp) - move32(); - } - - mat_mult_buffer1_e = exp; - move16(); -#endif /* OPT_BASOP_ADD_v1 */ IF( LT_16( lengthCx, lengthCy ) ) { @@ -1018,11 +968,7 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCx; move16(); -#ifdef OPT_BASOP_ADD_v1 svd_fx( svd_in_buffer_fx, mat_mult_buffer1_fx_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); -#else /* OPT_BASOP_ADD_v1 */ - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); -#endif /* OPT_BASOP_ADD_v1 */ } ELSE { @@ -1031,11 +977,7 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCy; move16(); -#ifdef OPT_BASOP_ADD_v1 svd_fx( svd_in_buffer_fx, mat_mult_buffer1_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); -#else /* OPT_BASOP_ADD_v1 */ - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); -#endif /* OPT_BASOP_ADD_v1 */ } /* Actually Processing P */ @@ -1046,46 +988,25 @@ Word16 computeMixingMatrices_fx( svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); -#ifdef OPT_BASOP_ADD_v1 mat_mult_buffer1_fx_e = 0; -#else /* OPT_BASOP_ADD_v1 */ - mat_mult_buffer1_e = 0; -#endif /* OPT_BASOP_ADD_v1 */ move16(); mat_mult_buffer2_e = 0; move16(); -#ifdef OPT_BASOP_ADD_v1 matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); -#else /* OPT_BASOP_ADD_v1 */ - matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, - mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, - mat_mult_buffer3_fx, &mat_mult_buffer3_e ); -#endif /* OPT_BASOP_ADD_v1 */ /************************ Formulate M **********************/ -#ifdef OPT_BASOP_ADD_v1 matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); -#else /* OPT_BASOP_ADD_v1 */ - Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); - - matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); -#endif /* OPT_BASOP_ADD_v1 */ Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#ifdef OPT_BASOP_ADD_v1 Word16 mat_mult_buffer1_fx_e1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; set16_fx( mat_mult_buffer1_fx_e1, mat_mult_buffer1_fx_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); -#else /* OPT_BASOP_ADD_v1 */ - matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); -#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Formulate Cr @@ -1096,15 +1017,9 @@ Word16 computeMixingMatrices_fx( Word16 Cx_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; set16_fx( Cx_e_arr, Cx_fx_e, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); -#ifdef OPT_BASOP_ADD_v1 matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1 ); matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); -#else /* OPT_BASOP_ADD_v1 */ - matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); - - matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); -#endif /* OPT_BASOP_ADD_v1 */ exp = mixing_matrix_fx_e[0]; move16(); @@ -1143,11 +1058,7 @@ Word16 computeMixingMatrices_fx( } /* Avoid Meaningless negative main diagonal elements */ -#ifdef OPT_BASOP_ADD_v1 IF( Cr_fx[i + ( i * lengthCy )] < 0 ) -#else /* OPT_BASOP_ADD_v1 */ - IF( BASOP_Util_Cmp_Mant32Exp( Cr_fx[i + ( i * lengthCy )], exp, 0, 0 ) < 0 ) -#endif /* OPT_BASOP_ADD_v1 */ { Cr_fx[i + ( i * lengthCy )] = 0; move32(); @@ -1209,11 +1120,7 @@ Word16 computeMixingMatrices_fx( { /* Avoid correction for very small energies, main diagonal elements of Cy_tilde_p may be negative */ -#ifdef OPT_BASOP_ADD_v1 IF( Cy_tilde_p_fx[i + ( i * lengthCy )] < 0 ) -#else /* OPT_BASOP_ADD_v1 */ - IF( BASOP_Util_Cmp_Mant32Exp( Cy_tilde_p_fx[i + ( i * lengthCy )], mat_mult_buffer2_e, 0, 0 ) < 0 ) -#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1232,12 +1139,8 @@ Word16 computeMixingMatrices_fx( move16(); } -#ifdef OPT_BASOP_ADD_v1 Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, adj_e[i] ) ); IF( GT_32( adj_fx_p[i], temp ) ) -#else /* OPT_BASOP_ADD_v1 */ - IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], adj_e[i], 1073741824, 3 ) > 0 ) -#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1322,11 +1225,7 @@ Word16 computeMixingMatricesResidual_fx( Word16 mixing_matrix_e = 0, mat_mult_buffer1_e, adj_e, mat_mult_buffer3_e, mat_mult_buffer2_e; move16(); -#ifdef MSAN_FIX Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS] = { 0 }; -#else - Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; -#endif Word16 svd_s_buffer_e[MAX_OUTPUT_CHANNELS]; Word32 L_tmp; Word16 tmp_e; @@ -1370,9 +1269,7 @@ Word16 computeMixingMatricesResidual_fx( svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); /* Computing Ky */ -#ifdef OPT_BASOP_ADD_v1 Word16 max_e = -32; -#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCy; ++i ) { FOR( j = 0; j < lengthCy; ++j ) @@ -1384,13 +1281,10 @@ Word16 computeMixingMatricesResidual_fx( move32(); Ky_fx_e[i + j * lengthCy] = tmp_e; move16(); -#ifdef OPT_BASOP_ADD_v1 max_e = s_max( max_e, tmp_e ); -#endif /* OPT_BASOP_ADD_v1 */ } } -#ifdef OPT_BASOP_ADD_v1 FOR( i = 0; i < lengthCy * lengthCy; ++i ) { Ky_fx[i] = L_shr( Ky_fx[i], sub( max_e, Ky_fx_e[i] ) ); @@ -1398,7 +1292,6 @@ Word16 computeMixingMatricesResidual_fx( Ky_fx_e[i] = max_e; move16(); } -#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Decomposition of Cx @@ -1410,9 +1303,7 @@ Word16 computeMixingMatricesResidual_fx( * square root of the diagonal of Cx */ /* Computing Kx */ -#ifdef OPT_BASOP_ADD_v1 max_e = -32; -#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { exp = Cx_e; @@ -1421,12 +1312,9 @@ Word16 computeMixingMatricesResidual_fx( move32(); Kx_fx_e[i] = exp; move16(); -#ifdef OPT_BASOP_ADD_v1 max_e = s_max( max_e, exp ); -#endif /* OPT_BASOP_ADD_v1 */ } -#ifdef OPT_BASOP_ADD_v1 FOR( i = 0; i < lengthCx; ++i ) { Kx_fx[i] = L_shr( Kx_fx[i], sub( max_e, Kx_fx_e[i] ) ); @@ -1434,7 +1322,6 @@ Word16 computeMixingMatricesResidual_fx( Kx_fx_e[i] = max_e; move16(); } -#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Regularization of Sx @@ -1442,25 +1329,13 @@ Word16 computeMixingMatricesResidual_fx( limit_fx = Kx_fx[0]; move32(); -#ifndef OPT_BASOP_ADD_v1 - limit_e = Kx_fx_e[0]; - move16(); -#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 1; i < lengthCx; i++ ) { -#ifdef OPT_BASOP_ADD_v1 IF( GT_32( Kx_fx[i], limit_fx ) ) -#else /* OPT_BASOP_ADD_v1 */ - IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) -#endif /* OPT_BASOP_ADD_v1 */ { limit_fx = Kx_fx[i]; move32(); -#ifndef OPT_BASOP_ADD_v1 - limit_e = Kx_fx_e[i]; - move16(); -#endif /* OPT_BASOP_ADD_v1 */ } } @@ -1468,11 +1343,7 @@ Word16 computeMixingMatricesResidual_fx( L_tmp = L_add( L_tmp, EPSILLON_FX ); limit_fx = L_tmp; move16(); -#ifdef OPT_BASOP_ADD_v1 limit_e = add( Kx_fx_e[0], reg_Sx_e ); -#else /* OPT_BASOP_ADD_v1 */ - limit_e = add( limit_e, reg_Sx_e ); -#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { @@ -1622,15 +1493,8 @@ Word16 computeMixingMatricesResidual_fx( *-----------------------------------------------------------------*/ -#ifdef OPT_BASOP_ADD_v1 matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); set16_fx( mat_mult_buffer1_buff_e, mat_mult_buffer1_buff_e[0], MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); -#else /* OPT_BASOP_ADD_v1 */ - Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); - - matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); -#endif /* OPT_BASOP_ADD_v1 */ Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; @@ -1715,12 +1579,8 @@ Word16 computeMixingMatricesResidual_fx( move32(); adj_buff_e[i] = scale; move16(); -#ifdef OPT_BASOP_ADD_v1 Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, scale ) ); IF( GT_32( adj_fx_p[i], temp ) ) // 1073741824 -> 1.0f in Q30 -#else /* OPT_BASOP_ADD_v1 */ - IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], scale, 1073741824, 3 ) > 0 ) // 1073741824 -> 1.0f in Q30 -#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1891,7 +1751,7 @@ Word16 computeMixingMatricesISM_fx( IF( svd_s_buffer_fx[i] ) { Word32 reg_fac; - reg_fac = BASOP_Util_Divide3232_Scale_cadence( MAX_32, svd_s_buffer_fx[i], &temp_e[i] ); + reg_fac = BASOP_Util_Divide3232_Scale_newton( MAX_32, svd_s_buffer_fx[i], &temp_e[i] ); Kx_reg_inv_fx[i] = reg_fac; move32(); temp_e[i] = sub( temp_e[i], svd_s_buffer_fx_e ); @@ -1900,7 +1760,7 @@ Word16 computeMixingMatricesISM_fx( ELSE { Word32 reg_fac; - reg_fac = BASOP_Util_Divide3232_Scale_cadence( MAX_32, EPSILON_FX_M, &temp_e[i] ); + reg_fac = BASOP_Util_Divide3232_Scale_newton( MAX_32, EPSILON_FX_M, &temp_e[i] ); Kx_reg_inv_fx[i] = reg_fac; move32(); temp_e[i] = sub( temp_e[i], EPSILON_FX_E ); @@ -1977,7 +1837,7 @@ Word16 computeMixingMatricesISM_fx( { IF( Cy_hat_diag_fx[i] ) { - G_hat_fx[i] = BASOP_Util_Divide3232_Scale_cadence( Cy_diag_fx[i], Cy_hat_diag_fx[i], &temp_e[i] ); + G_hat_fx[i] = BASOP_Util_Divide3232_Scale_newton( Cy_diag_fx[i], Cy_hat_diag_fx[i], &temp_e[i] ); move32(); temp_e[i] = add( temp_e[i], sub( Cy_diag_e, Cy_hat_diag_e ) ); move16(); @@ -1986,7 +1846,7 @@ Word16 computeMixingMatricesISM_fx( } ELSE { - G_hat_fx[i] = BASOP_Util_Divide3232_Scale_cadence( Cy_diag_fx[i], EPSILON_FX_M, &temp_e[i] ); + G_hat_fx[i] = BASOP_Util_Divide3232_Scale_newton( Cy_diag_fx[i], EPSILON_FX_M, &temp_e[i] ); move32(); temp_e[i] = add( temp_e[i], sub( Cy_diag_e, EPSILON_FX_E ) ); move16(); @@ -2089,7 +1949,7 @@ Word16 computeMixingMatricesISM_fx( { IF( Cy_tilde_p_fx[i + ( i * lengthCy )] ) { - adj_fx[i] = BASOP_Util_Divide3232_Scale_cadence( Cy_diag_fx[i], Cy_tilde_p_fx[i + ( i * lengthCy )], &temp_e[i] ); + adj_fx[i] = BASOP_Util_Divide3232_Scale_newton( Cy_diag_fx[i], Cy_tilde_p_fx[i + ( i * lengthCy )], &temp_e[i] ); move32(); temp_e[i] = add( temp_e[i], sub( Cy_diag_e, mat_mult_buffer2_e ) ); move16(); @@ -2098,7 +1958,7 @@ Word16 computeMixingMatricesISM_fx( } ELSE { - adj_fx[i] = BASOP_Util_Divide3232_Scale_cadence( Cy_diag_fx[i], EPSILON_FX_M, &temp_e[i] ); + adj_fx[i] = BASOP_Util_Divide3232_Scale_newton( Cy_diag_fx[i], EPSILON_FX_M, &temp_e[i] ); move32(); temp_e[i] = add( temp_e[i], sub( Cy_diag_e, EPSILON_FX_E ) ); move16(); @@ -2115,12 +1975,8 @@ Word16 computeMixingMatricesISM_fx( } } -#ifdef OPT_BASOP_ADD_v1 Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, temp_e[i] ) ); IF( GT_32( adj_fx[i], temp ) ) -#else /* OPT_BASOP_ADD_v1 */ - IF( BASOP_Util_Cmp_Mant32Exp( adj_fx[i], temp_e[i], MAX_32, 2 ) > 0 ) -#endif /* OPT_BASOP_ADD_v1 */ { adj_fx[i] = MAX_32; move32(); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ed716f743231402ff7ea9a0403aa7f9144b7d0d3..ba49051897aea72fdf720be956a9bcace9489d77 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1513,9 +1513,7 @@ ivas_error ivas_init_decoder_fx( { return error; } -#ifdef MSAN_FIX set16_fx( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 0, CLDFB_NO_COL_MAX ); -#endif test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup ) { diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 0f023a7efd080f499328b709895092c92b8c95fc..73ea5cd1f27289546002cddce0f3de1f71654c66 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -181,7 +181,12 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( cng_noise_nrg_obj_fx = dotp_fixed_o( hFdCngCom->cngNoiseLevel, hFdCngCom->cngNoiseLevel, cng_noise_level_len, 9, &Q_cng_noise_nrg_obj ); /*Resultant Q_cng_noise_nrg_obj= (Q_cng_noise_nrg_obj-x)<=31*/ IF( GT_32( cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx ) ) { - Word32 temp = divide3232( L_shr( cng_noise_nrg_dominant_fx, 1 ), cng_noise_nrg_obj_fx ); /*Stores value of cng_noise_nrg_dominant_fx/cng_noise_nrg_obj_fx*/ + Word32 temp = 0; + move32(); + IF( L_shr( cng_noise_nrg_dominant_fx, 1 ) ) + { + temp = divide3232( L_shr( cng_noise_nrg_dominant_fx, 1 ), cng_noise_nrg_obj_fx ); /*Stores value of cng_noise_nrg_dominant_fx/cng_noise_nrg_obj_fx*/ + } Word16 Q_temp = add( sub( sub( Q_cng_noise_nrg_dominant, 1 ), Q_cng_noise_nrg_obj ), 15 ); /*Stores resultant Q after divide3232 operation above*/ IF( EQ_16( Q_temp % 2, 1 ) ) /*Making Q_temp even for sqrt function*/ { diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 8a2b977eb95ed8b68eb54a1ee5586312735bffc3..d7ec5b6e7a803ad763c0e3231dff91866beefd6f 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -511,9 +511,7 @@ static ivas_error ivas_param_ism_rendering_init_fx( { set32_fx( hParamIsmRendering->mixing_matrix_lin_old_fx[bin_idx], 0, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX ); } -#ifdef MSAN_FIX set16_fx( hParamIsmRendering->exp_mixing_matrix_lin_old_fx, 0, CLDFB_NO_CHANNELS_MAX ); -#endif /* memory allocation for proto matrix and interpolator */ IF( ( hParamIsmRendering->proto_matrix_fx = (Word16 *) malloc( hOutSetup.nchan_out_woLFE * nchan_transport * sizeof( Word16 ) ) ) == NULL ) @@ -1548,11 +1546,11 @@ static void ivas_ism_param_dec_render_sf_fx( Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) ); // Q_real-1 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 ); move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f0c56503b8e0341fef2f79c497321efca5720916..0aeefc667d03c6d0400af8141d14d5d007c0bf62 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -129,10 +129,8 @@ ivas_error ivas_jbm_dec_tc_fx( set_zero_fx( st_ivas->p_output_fx[n], L_FRAME48k ); st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; } -#ifdef MSAN_FIX st_ivas->hTcBuffer->no_channels = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); move16(); -#endif } Word16 ch; @@ -434,19 +432,13 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( hCPE->hCoreCoder[0] != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#endif hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); } IF( hCPE->hStereoDft != NULL ) { -#ifdef MSAN_FIX IF( LE_16( st_ivas->nchan_transport, 1 ) ) { st = hCPE->hCoreCoder[0]; @@ -494,9 +486,6 @@ ivas_error ivas_jbm_dec_tc_fx( } } } -#else - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); -#endif scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; move16(); @@ -517,14 +506,10 @@ ivas_error ivas_jbm_dec_tc_fx( hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; move16(); } -#ifdef MSAN_FIX FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx } -#else - Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); -#endif ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -532,14 +517,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } -#ifdef MSAN_FIX FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } -#else - Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); -#endif scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -555,7 +536,6 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( hCPE->hStereoDft != NULL ) { -#ifdef MSAN_FIX IF( LE_16( st_ivas->nchan_transport, 1 ) ) { st = hCPE->hCoreCoder[0]; @@ -603,9 +583,6 @@ ivas_error ivas_jbm_dec_tc_fx( } } } -#else - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 -#endif scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; test(); @@ -971,13 +948,8 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( hCPE->hCoreCoder[0] != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q -#endif hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); } @@ -1004,24 +976,16 @@ ivas_error ivas_jbm_dec_tc_fx( hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; move16(); } -#ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx -#else - Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); -#endif ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); } -#ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 -#else - Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); -#endif scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -1288,18 +1252,7 @@ ivas_error ivas_jbm_dec_tc_fx( test(); IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - s = Q16 - Q11; - move16(); - s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, s ); - } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); - } } } ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) @@ -1431,13 +1384,8 @@ ivas_error ivas_jbm_dec_tc_fx( IF( hCPE->hCoreCoder[0] != NULL ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#endif hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); } @@ -1469,23 +1417,15 @@ ivas_error ivas_jbm_dec_tc_fx( hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; move16(); } -#ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx -#else - Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); -#endif ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } -#ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 -#else - Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); -#endif // MSAN_FIX scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -1941,10 +1881,8 @@ ivas_error ivas_jbm_dec_render_fx( } } -#ifdef MSAN_FIX st_ivas->hTcBuffer->no_channels = st_ivas->hTcBuffer->nchan_buffer_full; move16(); -#endif // MSAN_FIX /*----------------------------------------------------------------* * Update combined orientation access index *----------------------------------------------------------------*/ @@ -2039,7 +1977,6 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */ -#ifdef MSAN_FIX FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { FOR( j = 0; j < 16; j++ ) @@ -2050,16 +1987,6 @@ ivas_error ivas_jbm_dec_render_fx( move32(); } } -#else - FOR( i = 0; i < 15; i++ ) - { - FOR( j = 0; j < 16; j++ ) - { - st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29 - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29 - } - } -#endif ivas_ism2sba_sf_fx( st_ivas->hTcBuffer->tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) ); FOR( j = 0; j < sba_num_chans; j++ ) @@ -2068,7 +1995,6 @@ ivas_error ivas_jbm_dec_render_fx( } -#ifdef MSAN_FIX FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { FOR( j = 0; j < 16; j++ ) @@ -2079,16 +2005,6 @@ ivas_error ivas_jbm_dec_render_fx( move32(); } } -#else - FOR( i = 0; i < 15; i++ ) - { - FOR( j = 0; j < 16; j++ ) - { - st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q29 -> Q30 - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q29 -> Q30 - } - } -#endif } #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -2191,11 +2107,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } @@ -2243,11 +2155,7 @@ ivas_error ivas_jbm_dec_render_fx( hSpar->hMdDec->Q_mixer_mat = 30; move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } @@ -2285,11 +2193,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/ { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism] ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism], 960 ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } @@ -2301,11 +2205,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } @@ -2317,11 +2217,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } @@ -2750,8 +2646,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 n_slots_still_available; Word16 n_samples_to_render; DECODER_TC_BUFFER_HANDLE hTcBuffer; - Word32 output_fx[MAX_CICP_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *p_output_fx[MAX_CICP_CHANNELS]; + Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; IF( !st_ivas->hDecoderConfig->Opt_tsm ) { @@ -2992,11 +2888,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); /* render the last subframe */ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx, L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index d98603d2a567052962051810bce287bbb9e3cedb..a480ce7bebdcb58eb606d72f4f76374b1747370a 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -225,7 +225,7 @@ static Word16 lfeplc_lev_dur_fx( a_out_q_fx[0] = 30; move16(); - rc_fx[0] = BASOP_Util_Divide3232_Scale_cadence( -r_fx[1], r_fx[0], &temp_q2 ); + rc_fx[0] = BASOP_Util_Divide3232_Scale_newton( -r_fx[1], r_fx[0], &temp_q2 ); move32(); rc_q_fx[0] = add( sub( r_q_fx[1], r_q_fx[0] ), sub( 31, temp_q2 ) ); move16(); @@ -387,7 +387,7 @@ static Word16 lfeplc_lev_dur_fx( s = W_extract_h( W_shl( s_fx, exp1 ) ); s_q_fx = sub( add( s_q_fx, exp1 ), 32 ); - rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate( s ), err_fx, &temp_q2 ), 1 ); + rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_newton( L_negate( s ), err_fx, &temp_q2 ), 1 ); move32(); rc_q_fx[i - 1] = sub( add( sub( s_q_fx, err_q_fx ), sub( 31, temp_q2 ) ), 1 ); move16(); diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 37423885fcee45262efae92d504c34b1be3b55b7..b5962311337b000a9acb56faddd40ba4853fdaa2 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -123,7 +123,7 @@ ivas_error ivas_param_mc_dec_open_fx( Word16 nchan_out_transport; Word16 nchan_out_cov; Word32 proto_matrix_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; - Word32 proto_mtx_norm_fx; + Word32 proto_mtx_norm_fx, tmp32; Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; Word16 max_param_band_residual; UWord16 config_index; @@ -374,20 +374,27 @@ ivas_error ivas_param_mc_dec_open_fx( Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, imult1616( nchan_out_transport, nchan_out_cov ), 4 ); /*Q.26*/ IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - proto_mtx_norm_fx = ONE_IN_Q26; /*Q26*/ + tmp32 = ONE_IN_Q26; /*Q26*/ move32(); FOR( k = 0; k < nchan_transport * nchan_out_cov; k++ ) { - proto_mtx_norm_fx = L_max( L_abs( proto_mtx_norm_fx ), L_abs( proto_matrix_fx[k] ) ); /*Q.26*/ + tmp32 = L_max( L_abs( tmp32 ), L_abs( proto_matrix_fx[k] ) ); /*Q.26*/ } - proto_mtx_norm_fx = divide3232( ONE_IN_Q26, proto_mtx_norm_fx ); /*Q15*/ + proto_mtx_norm_fx = divide3232( ONE_IN_Q26, tmp32 ); /*Q15*/ /* transfer flattened proto_matrix to 2D in hLsSetupConversion->dmxMtx */ FOR( k = 0; k < nchan_transport; k++ ) { FOR( Word16 i = 0; i < nchan_out_cov; i++ ) { - st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl( Mult_32_16( proto_matrix_fx[k * nchan_out_cov + i], extract_l( proto_mtx_norm_fx ) ), 4 ); /*Q.30*/ + IF( EQ_32( proto_matrix_fx[k * nchan_out_cov + i], tmp32 ) ) + { + st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = ONE_IN_Q30; // Q30 + } + ELSE + { + st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl( Mult_32_16( proto_matrix_fx[k * nchan_out_cov + i], extract_l( proto_mtx_norm_fx ) ), 4 ); /*Q.30*/ + } move32(); } } @@ -1860,9 +1867,6 @@ void ivas_param_mc_dec_render_fx( /* format converter */ Word16 channel_active[MAX_OUTPUT_CHANNELS]; UWord16 nband_synth; -#ifndef MSAN_FIX - UWord16 nchan_out_init, nbands_to_zero; -#endif UWord32 output_Fs; Word16 tmp_q = 0; move16(); @@ -1876,10 +1880,6 @@ void ivas_param_mc_dec_render_fx( nchan_transport = st_ivas->nchan_transport; move16(); nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); -#ifndef MSAN_FIX - nchan_out_init = nchan_out_transport; - move16(); -#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); @@ -1889,12 +1889,6 @@ void ivas_param_mc_dec_render_fx( { nchan_out_cldfb = BINAURAL_CHANNELS; set16_fx( channel_active, 1, nchan_out_cldfb ); -#ifndef MSAN_FIX - IF( st_ivas->hCombinedOrientationData ) - { - nchan_out_init = MAX_INTERN_CHANNELS; - } -#endif nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); } ELSE IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) @@ -1922,21 +1916,12 @@ void ivas_param_mc_dec_render_fx( /* set everything to zero that will not be decoded */ nband_synth = hParamMC->band_grouping[hParamMC->num_param_bands_synth]; move16(); -#ifdef MSAN_FIX FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) -#else - FOR( ch = 0; ch < nchan_out_init; ch++ ) -#endif { FOR( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) { -#ifdef MSAN_FIX set32_fx( &( Cldfb_RealBuffer_fx[ch][slot_idx][0] ), 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( &( Cldfb_ImagBuffer_fx[ch][slot_idx][0] ), 0, CLDFB_NO_CHANNELS_MAX ); -#else - set32_fx( &( Cldfb_RealBuffer_fx[ch][slot_idx][nband_synth] ), 0, nbands_to_zero ); - set32_fx( &( Cldfb_ImagBuffer_fx[ch][slot_idx][nband_synth] ), 0, nbands_to_zero ); -#endif } } @@ -1971,31 +1956,8 @@ void ivas_param_mc_dec_render_fx( slot_idx_start_cldfb_synth = 0; move16(); -#ifndef FIX_1009_OPT_PARAMMC_RENDER - Flag is_zero = 1; - move32(); -#endif FOR( j = 0; j < st_ivas->hParamMC->hMetadataPMC->nbands_coded; j++ ) { -#ifndef FIX_1009_OPT_PARAMMC_RENDER - is_zero = 1; - move16(); - FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_len; i++ ) - { - IF( hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[j][i] != 0 ) - { - is_zero = 0; - move16(); - } - } - IF( is_zero ) - { - hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[j] = 0; - move16(); - } - is_zero = 1; - move16(); -#else Flag is_zero = is_zero_arr( hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[j], hParamMC->h_output_synthesis_cov_state.mixing_matrix_len ); { if ( is_zero != 0 ) @@ -2004,23 +1966,10 @@ void ivas_param_mc_dec_render_fx( move16(); } } -#endif IF( LT_16( st_ivas->hParamMC->band_grouping[j], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) { -#ifndef FIX_1009_OPT_PARAMMC_RENDER - FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len; i++ ) - { - IF( NE_32( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[j][i], 0 ) ) - { - is_zero = 0; - move16(); - } - } - IF( is_zero ) -#else is_zero = is_zero_arr( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[j], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len ); if ( is_zero != 0 ) -#endif { hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[j] = 0; move16(); @@ -2305,13 +2254,13 @@ void ivas_param_mc_dec_render_fx( Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); scale_sig32( output_f_fx[ch], len, 5 - 11 ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), - imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ + imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), - imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ + imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( output_f_fx[ch], len, 11 - 5 ); // Q11 } @@ -2800,9 +2749,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( set_zero_fx( mat_mult_buffer1_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero_fx( proto_matrix_noLFE_fx, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); set_zero_fx( mixing_matrix_local_fx, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); -#ifdef MSAN_FIX set_zero_fx( mixing_matrix_res_local_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); -#endif Word16 proto_matrix_noLFE_e = 0; move16(); @@ -2999,11 +2946,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( FOR( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) { -#ifdef OPT_BASOP_ADD_v1 if ( Cproto_diag_fx[ch_idx1] < 0 ) -#else /* OPT_BASOP_ADD_v1 */ - if ( BASOP_Util_Cmp_Mant32Exp( Cproto_diag_fx[ch_idx1], Cproto_diag_e, 0, 0 ) < 0 ) -#endif /* OPT_BASOP_ADD_v1 */ { Cproto_diag_fx[ch_idx1] = 0; move16(); diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index e70908f5eddf22a94468c5680f1124c7bc6b260e..a8995d8e96d4f354de91cd78f531f41aa823357f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -716,13 +716,8 @@ static void ivas_mc_paramupmix_dec_sf( Word16 noparamupmix_delay, n_samples_rendered; MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; Word16 subframeIdx, idx_in, maxBand; -#ifdef MSAN_FIX Word32 Cldfb_RealBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; Word32 Cldfb_ImagBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; -#else - Word32 Cldfb_RealBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif // MSAN_FIX #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -941,26 +936,32 @@ static void ivas_mc_paramupmix_dec_sf( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 #else - RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; // Q6 - ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 + RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; // Q6 + ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 #endif } +#ifndef OPT_AVOID_STATE_BUF_RESCALE scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); // Q11 -> Q5 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q5 -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q5 -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6, 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q11 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifndef OPT_AVOID_STATE_BUF_RESCALE + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } + +#ifndef OPT_AVOID_STATE_BUF_RESCALE FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { Scale_sig32( output_fx[ch], imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6 ); // Q5 -> Q11 } +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -986,14 +987,13 @@ static void ivas_mc_paramupmix_dec_sf( ptr_re_fx[0] = Cldfb_RealBuffer_fx[ch][slot_idx]; // Q6 ptr_im_fx[0] = Cldfb_ImagBuffer_fx[ch][slot_idx]; // Q6 - -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), - hMCParamUpmix->num_freq_bands, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ + hMCParamUpmix->num_freq_bands, 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), - hMCParamUpmix->num_freq_bands, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ + hMCParamUpmix->num_freq_bands, 0, st_ivas->cldfbSynDec[ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6 -> Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index bf21753bfd982b3bfb671feaa7517c85dac3ea2a..db9cddc39b60321ed51c9394b12e19a518e38286 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -84,10 +84,8 @@ ivas_error ivas_mct_dec_fx( set16_fx( x_len[0], 0, NB_DIV ); set16_fx( x_len[1], 0, NB_DIV ); Decoder_State **sts; -#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS Word32 *p_output_orig_fx[2]; Word32 synth_32_fx[CPE_CHANNELS][L_FRAME_PLUS]; -#endif Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth) Word32 ivas_total_brate; ivas_error error; @@ -164,7 +162,6 @@ ivas_error ivas_mct_dec_fx( /* MCT side bits decoder */ ivas_mct_side_bits_fx( hMCT, st_ivas->hCPE, nCPE, st_ivas->hCPE[0]->hCoreCoder[0], st_ivas->bfi, st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream, ivas_total_brate, nb_bits_metadata ); -#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS /* in case of switching from an SID frame (with ACELP core) to MCT, buffer of L_FRAME_PLUS samples is needed -> use synth[] as a temporary buffer */ IF( st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE ) { @@ -174,7 +171,6 @@ ivas_error ivas_mct_dec_fx( output_fx[n] = synth_32_fx[n]; } } -#endif FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { @@ -348,13 +344,8 @@ ivas_error ivas_mct_dec_fx( x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 } -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ); - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ); -#endif ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); Word16 hdrm, sh; @@ -385,7 +376,6 @@ ivas_error ivas_mct_dec_fx( } } -#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS /* set pointers back */ test(); IF( cpe_id == 0 && st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE ) @@ -396,7 +386,6 @@ ivas_error ivas_mct_dec_fx( } } -#endif /*----------------------------------------------------------------* * CoreCoder Post-processing and updates @@ -409,19 +398,10 @@ ivas_error ivas_mct_dec_fx( test(); IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( synth_fx[n], synth_fx_32[n], L_FRAME48k, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->old_out_fx32, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) ); -#else - Copy_Scale_sig_16_32_DEPREC( synth_fx[n], synth_fx_32[n], L_FRAME48k, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->old_out_fx32, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) ); -#endif ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 ); -#ifdef MSAN_FIX Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, sub( sub( 15, e_sig[n] ), Q11 ) ); // Q0 -#else - Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], L_FRAME48k, 0 - Q11 ); -#endif } /* Postprocessing for ACELP/MDCT core switching and synchronization */ @@ -452,11 +432,7 @@ ivas_error ivas_mct_dec_fx( { return error; } -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_frame, sub( Q11, Q_synth ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_frame, sub( Q11, Q_synth ) ); // Q11 -#endif /* Save synthesis for HQ FEC */ Word32 output_fx_[L_FRAME48k]; Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 @@ -476,11 +452,7 @@ ivas_error ivas_mct_dec_fx( { IF( hCPE->hCoreCoder[n] ) { -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->delay_buf_out_fx, hCPE->hCoreCoder[n]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11 ); // Q0 -> Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[n]->delay_buf_out_fx, hCPE->hCoreCoder[n]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11 ); // Q0 -> Q11 -#endif } } @@ -1358,7 +1330,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( new_brate_SCE = 0; move32(); Word16 temp_e; - Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e ); + Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e ); L_temp = L_shr( L_temp, sub( 31, temp_e ) ); new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/; } @@ -1367,7 +1339,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( new_brate_SCE = 0; move32(); Word16 temp_e; - Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e ); + Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e ); L_temp = L_shr( L_temp, sub( 31, temp_e ) ); new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/; } @@ -1376,7 +1348,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( new_brate_SCE = 0; /* ivas_total_brate / st_ivas->nchan_transport;*/ move32(); Word16 temp_e; - Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( ivas_total_brate, st_ivas->nchan_transport, &temp_e ); + Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( ivas_total_brate, st_ivas->nchan_transport, &temp_e ); L_temp = L_shr( L_temp, sub( 31, temp_e ) ); new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/; } diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index c275820fbcf25cb352d72c029c7965843fa29090..0f20c1ec0fbdd12dc61b9d97a6d8bf256733fbb5 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -313,17 +313,6 @@ void mctStereoIGF_dec_fx( test(); IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[k], SMDCT_DUAL_MONO ) || NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[k], SMDCT_DUAL_MONO ) ) { -#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC - tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxCfg->tcx_coded_lines, nSubframes, &tmp_e ); - L_spec[0] = shr( tmp, add( 15, negate( tmp_e ) ) ); - move16(); - - tmp = BASOP_Util_Divide1616_Scale( sts[0]->L_frame, nSubframes, &tmp_e ); - L_frame_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) ); - - tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxDec->L_frameTCX, nSubframes, &tmp_e ); - L_frameTCX_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) ); -#else Word16 shr_div, shr_k; assert( nSubframes == 1 || nSubframes == 2 ); @@ -334,7 +323,6 @@ void mctStereoIGF_dec_fx( move16(); L_frame_nSubframe = shr( sts[0]->L_frame, shr_div ); L_frameTCX_nSubframe = shr( sts[0]->hTcxDec->L_frameTCX, shr_div ); -#endif init_tcx_info_fx( sts[0], L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] ); @@ -344,28 +332,16 @@ void mctStereoIGF_dec_fx( decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ ); // Shifting output with variable exponent back to Q12 -#ifdef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC shr_k = sub( 31 - Q12, p_x_e[0][k] ); -#endif FOR( Word16 i = 0; i < p_x_len[0][k]; i++ ) { -#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC - p_x[0][k][i] = L_shr( p_x[0][k][i], sub( 31 - Q12, p_x_e[0][k] ) ); -#else p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k ); -#endif move32(); } -#ifdef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC shr_k = sub( 31 - Q12, p_x_e[1][k] ); -#endif FOR( Word16 i = 0; i < p_x_len[1][k]; i++ ) { -#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC - p_x[1][k][i] = L_shr( p_x[1][k][i], sub( 31 - Q12, p_x_e[1][k] ) ); -#else p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k ); -#endif move32(); } } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 1899c8bea485a504c671ac909b1840d61025bd77..fabebede4e6e468526331188d065f9086d1715c9 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -684,10 +684,8 @@ void ivas_mdct_core_invQ_fx( { spectralData_tmp[k] = malloc( N_MAX * sizeof( Word32 ) ); } -#ifdef MSAN_FIX set32_fx( spectralData_tmp[0], 0, L_FRAME_MAX ); set32_fx( spectralData_tmp[1], 0, L_FRAME_MAX ); -#endif // MSAN_FIX push_wmops( "mdct_core_invQ" ); sts = hCPE->hCoreCoder; @@ -728,18 +726,8 @@ void ivas_mdct_core_invQ_fx( common_exp = s_max( sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ); -#ifdef MSAN_FIX -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[0], L_frameTCX[0], sub( 15, sub( common_exp, sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ) ); // 30 - spectral_exp1 Copy_Scale_sig_16_32_no_sat( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_frameTCX[1], sub( 15, sub( common_exp, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ) ); // 30 - spectral_exp2 -#else - Copy_Scale_sig_16_32_DEPREC( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[0], L_frameTCX[0], sub( 15, sub( common_exp, sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ) ); // 30 - spectral_exp1 - Copy_Scale_sig_16_32_DEPREC( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_frameTCX[1], sub( 15, sub( common_exp, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ) ); // 30 - spectral_exp2 -#endif -#else - Copy_Scale_sig_16_32_DEPREC( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[0], L_FRAME_MAX, 15 - ( common_exp - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp1 - Copy_Scale_sig_16_32_DEPREC( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_FRAME_MAX, 15 - ( common_exp - sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp2 -#endif // MSAN_FIX sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp = sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp = common_exp; move16(); @@ -751,13 +739,8 @@ void ivas_mdct_core_invQ_fx( /* both input in same Q */ stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l ); -#ifdef MSAN_FIX Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15 Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15 -#else - Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_FRAME_MAX, -15 ); - Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_FRAME_MAX, -15 ); -#endif sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp = sub( 30, q_l ); sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp = sub( 30, q_r ); move16(); @@ -1189,18 +1172,13 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win st->hTcxDec->Q_old_syn_Overl = q_win; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win -#ifdef MSAN_FIX + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win -#else - Scale_sig( synth_buf_fx, 3136, sub( q_win, q_syn ) ); - Scale_sig( synth_bufFB_fx, 3136, sub( q_win, q_syn ) ); -#endif - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win + Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win FOR( k = 0; k < nSubframes[ch]; k++ ) { init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], @@ -1263,13 +1241,8 @@ void ivas_mdct_core_reconstruct_fx( move16(); Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); -#ifdef MSAN_FIX Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn -#else - Scale_sig( synth_buf_fx, 3136, sub( q_syn, q_win ) ); - Scale_sig( synth_bufFB_fx, 3136, sub( q_syn, q_win ) ); -#endif Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn @@ -1400,11 +1373,7 @@ void ivas_mdct_core_reconstruct_fx( move16(); st->last_coder_type = st->coder_type; move16(); -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, q_syn ) ); // q_syn -> Q_x -#else - Copy_Scale_sig_16_32_DEPREC( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, q_syn ) ); // q_syn -> Q_x -#endif } IF( GT_16( e_sig[0], e_sig[1] ) ) @@ -1508,9 +1477,7 @@ void ivas_mdct_core_tns_ns_fx( move16(); set32_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); -#ifdef MSAN_FIX set32_fx( sns_int_scf_fx, 0, FDNS_NPTS ); -#endif /* TNS, ITF, IMDCT and updates */ @@ -1656,6 +1623,8 @@ void ivas_mdct_core_tns_ns_fx( } q_2 = q_x; move16(); + Word16 length2 = length; + move16(); sns_shape_spectrum_fx( x_fx[ch][k], &q_x, st->hTcxCfg->psychParamsCurrent, sns_int_scf_fx, q_sns_int_scf, st->hTcxCfg->psychParamsCurrent->nBins, &length ); IF( LT_16( q_2, add( q_x, 1 ) ) ) /*scaling to q_2*/ { @@ -1665,7 +1634,7 @@ void ivas_mdct_core_tns_ns_fx( } ELSE /*scaling to q_x+1*/ { - Scale_sig32( &x_fx[ch][k][0] + length, sub( L_spec[ch], length ), sub( add( q_x, 1 ), q_2 ) ); + Scale_sig32( &x_fx[ch][k][0] + length, sub( length2, length ), sub( add( q_x, 1 ), q_2 ) ); q_x = add( q_x, 1 ); } x_e[ch][k] = sub( 31, q_x ); diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 2c0707b667e7f77d8b257f6aa41cfb257f31ae20..2e7d5e47b54055e1d71515e3a2b4b0b8590a42ea 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -720,22 +720,14 @@ void ivas_omasa_dirac_rend_jbm_fx( ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); -#ifdef MSAN_FIX FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) -#else - FOR( Word16 ind1 = 0; ind1 < MAX_CICP_CHANNELS - 1; ind1++ ) -#endif // MSAN_FIX { scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29 } ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); -#ifdef MSAN_FIX FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) -#else - FOR( Word16 ind1 = 0; ind1 < MAX_CICP_CHANNELS - 1; ind1++ ) -#endif // MSAN_FIX { scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, 1 ); // Q29 -> Q30 } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 0cc55e8c327ec8268eb192f70ca08d970d241df1..c96a91d5815fbd78752717eefacc6ca25ff20c8f 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -130,10 +130,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( 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 Q11*/ -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - , - Word16 out_len /*Store the length of values in each channel*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ) { Word16 n; @@ -148,6 +144,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( move16(); #endif + FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) + { + set32_fx( output_separated_objects_fx[i], 0, L_FRAME48k ); + } + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { p_sepobj_fx[n] = &output_separated_objects_fx[n][0]; @@ -156,11 +157,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( channel_offset = st_ivas->nchan_ism; move16(); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_fx[channel_offset] ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_fx[channel_offset], out_len ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } @@ -305,11 +302,7 @@ ivas_error ivas_osba_render_sf_fx( v_shr( p_output[n], Q11 - Q11, output_ism[n], nSamplesAsked ); // Q11 } -#ifdef OPT_SBA_AVOID_SPAR_RESCALE IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ), IVAS_ERR_OK ) ) -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output, 960 ) ), IVAS_ERR_OK ) ) -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ { return error; } diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index c7bf0655d9ea765be0f1310a09229b8f553203a0..93a7c204e891f5b88d5519612e7a876a70a2a320 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -479,12 +479,10 @@ ivas_error ivas_ls_setup_conversion_open_fx( set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[0], 0, MAX_SFB + 2 ); set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[0], 0, MAX_SFB + 2 ); -#ifdef MSAN_FIX hLsSetUpConversion->te_prev_exp[0] = 0; hLsSetUpConversion->dmx_prev_exp[0] = 0; move16(); move16(); -#endif } /* Initialize the DMX conversion matrix */ @@ -586,14 +584,14 @@ void ivas_ls_setup_conversion_fx( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ const Word16 input_chans, /* i : number of input channels to the renderer */ const Word16 output_frame, /* i : frame length */ - Word32 *input[], /* i : LS input/output synthesis signal Q16*/ - Word32 *output[] /* i/o: LS input/output synthesis signal Q16*/ + Word32 *input[], /* i : LS input/output synthesis signal Qx*/ + Word32 *output[] /* i/o: LS input/output synthesis signal Qx*/ ) { Word16 chInIdx, chOutIdx, idx; LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; Word32 dmxCoeff, tmpVal; - Word32 output_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // Q16 + Word32 output_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // Qx push_wmops( "LS_Renderer" ); @@ -659,6 +657,7 @@ void ivas_ls_setup_conversion_process_mdct_fx( Word16 transform_type[MAX_CICP_CHANNELS][2]; Word16 frameSize; Word32 targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2]; + Word16 dmxEnergy_exp[MAX_SFB + 2], dmxEnergy_exp_temp; Word32 dmxCoeff; Word32 dmxSignalReal[L_FRAME48k], dmxSignalImag[L_FRAME48k]; Word32 eqGain; @@ -741,6 +740,9 @@ void ivas_ls_setup_conversion_process_mdct_fx( set32_fx( targetEnergy, 0, MAX_SFB + 2 ); set32_fx( dmxEnergy, 0, MAX_SFB + 2 ); + set16_fx( dmxEnergy_exp, 0, MAX_SFB + 2 ); + dmxEnergy_exp_temp = 0; + move16(); FOR( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) { @@ -831,6 +833,7 @@ void ivas_ls_setup_conversion_process_mdct_fx( FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { Word32 tmpReal, tmpImag, DMXEne; + Word16 DMXEne_exp; start = hLsSetUpConversion->sfbOffset[bandIdx]; move16(); @@ -840,6 +843,8 @@ void ivas_ls_setup_conversion_process_mdct_fx( /* Loop over all the bins in the band */ DMXEne = 0; move32(); + DMXEne_exp = 0; + move16(); FOR( binIdx = start; binIdx < stop; binIdx++ ) { tmpReal = dmxSignalReal[binIdx]; @@ -847,13 +852,20 @@ void ivas_ls_setup_conversion_process_mdct_fx( tmpImag = dmxSignalImag[binIdx]; move32(); - DMXEne = L_add( DMXEne, L_add( Mpy_32_32( tmpReal, tmpReal ), Mpy_32_32( tmpImag, tmpImag ) ) ); + DMXEne = BASOP_Util_Add_Mant32Exp( DMXEne, DMXEne_exp, L_add( Mpy_32_32( tmpReal, tmpReal ), Mpy_32_32( tmpImag, tmpImag ) ), sub( 40, shl( q_output, 1 ) ), &DMXEne_exp ); } - dmxEnergy[bandIdx] = L_add( dmxEnergy[bandIdx], DMXEne ); + dmxEnergy[bandIdx] = BASOP_Util_Add_Mant32Exp( dmxEnergy[bandIdx], dmxEnergy_exp[bandIdx], DMXEne, DMXEne_exp, &dmxEnergy_exp[bandIdx] ); move32(); + dmxEnergy_exp_temp = s_max( dmxEnergy_exp_temp, dmxEnergy_exp[bandIdx] ); } } /* end of out channel loop */ + /* Scaling to common exponent */ + FOR( bandIdx = 0; bandIdx < MAX_SFB + 2; bandIdx++ ) + { + dmxEnergy[bandIdx] = L_shl( dmxEnergy[bandIdx], sub( dmxEnergy_exp[bandIdx], dmxEnergy_exp_temp ) ); + move32(); + } /* Step 3: Peform energy smoothing */ Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt ); @@ -862,13 +874,13 @@ void ivas_ls_setup_conversion_process_mdct_fx( scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, dmx_sacle ); Word16 te_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) ); - Word16 dmx_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ); + Word16 dmx_max_e = s_max( dmxEnergy_exp_temp, sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ); FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[bandIdx], sub( te_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) ) ) ) ); move32(); - dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[bandIdx], sub( dmx_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ) ) ) ); + dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[bandIdx], sub( dmx_max_e, dmxEnergy_exp_temp ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ) ) ) ); move32(); hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; /* te_prev_exp = 40 - 2*q_output */ move32(); diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 03fe4063ad13e3f19610201a8f66e306556a9622..c0e69b91663e2275b0398e4dec3439df3baf5c1b 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -243,12 +243,6 @@ void stereo_dft_dec_core_switching_fx( move16(); } -#ifndef MSAN_FIX - IF( st->p_bpf_noise_buf_32 ) - { - Scale_sig32( st->p_bpf_noise_buf_32, L_FRAME16k, sub( *q, Q11 ) ); - } -#endif test(); test(); @@ -273,9 +267,7 @@ void stereo_dft_dec_core_switching_fx( test(); IF( st->p_bpf_noise_buf_32 && NE_16( st->core, HQ_CORE ) ) { -#ifdef MSAN_FIX Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/ -#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 2, 0, q, q_DFT ); } /* st->p_bpf_noise_buf not updated FOR HQ core -> skip analysis and set input memory to zero */ @@ -294,11 +286,7 @@ void stereo_dft_dec_core_switching_fx( { Word16 mem_len = NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /*Q0*/ move16(); -#ifdef MSAN_FIX Word32 mem_len_inv = mem_len_inv_tbl[( mem_len / 25 ) - 1]; -#else - Word32 mem_len_inv = mem_len_inv_tbl[( mem_len / 25 )]; -#endif move32(); Word16 qmem_len = norm_l( mem_len ); Word32 mem_len_fx = L_shl( mem_len, qmem_len ); @@ -441,9 +429,7 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { -#ifdef MSAN_FIX Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/ -#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT ); } } @@ -472,9 +458,7 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { -#ifdef MSAN_FIX Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/ -#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT ); } @@ -549,9 +533,7 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { -#ifdef MSAN_FIX Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/ -#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT ); } @@ -723,12 +705,6 @@ void stereo_dft_dec_core_switching_fx( } } -#ifndef MSAN_FIX - IF( st->p_bpf_noise_buf_32 ) - { - Scale_sig32( st->p_bpf_noise_buf_32, L_FRAME16k, negate( sub( *q, Q11 ) ) ); - } -#endif return; } diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index c9d9bc2cb2918d6248916e43353031b2b48804ea..266389ea107fd4e6379448a03718d7bb03a6b543 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -1113,7 +1113,6 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( } } -#ifdef MSAN_FIX FOR( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { FOR( m = 0; m < hQMetaData->q_direction[0].cfg.nblocks; m++ ) @@ -1122,19 +1121,8 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( move32(); } } -#else - FOR( b = 0; b < MASA_MAXIMUM_CODING_SUBBANDS; b++ ) - { - FOR( m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES; m++ ) - { - hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[m] = W_round64_L( W_nrg_ratio[0][b][m] ); - move32(); - } - } -#endif // MSAN_FIX IF( EQ_32( hQMetaData->no_directions, 2 ) ) { -#ifdef MSAN_FIX FOR( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { FOR( m = 0; m < hQMetaData->q_direction[0].cfg.nblocks; m++ ) @@ -1143,16 +1131,6 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( move32(); } } -#else - FOR( b = 0; b < MASA_MAXIMUM_CODING_SUBBANDS; b++ ) - { - FOR( m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES; m++ ) - { - hQMetaData->q_direction[1].band_data[b].energy_ratio_fx[m] = W_round64_L( W_nrg_ratio[1][b][m] ); - move32(); - } - } -#endif // MSAN_FIX } /* Store status information for renderer use */ hQMetaData->ec_flag = 0; diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index abc275e9001210ad4081aa0d4fd1d999282ed5c6..fdbcdef48b53768d6ba50d4ec54ff5bdfa5c4a2b 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -904,10 +904,6 @@ ivas_error ivas_sba_dec_render_fx( UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered Q0*/ UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render Q0*/ Word32 *output_fx[] /* o : rendered time signal Q11*/ -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - , - Word16 out_len /*Store the length of values in each channel*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ) { Word16 slots_to_render, first_sf, last_sf, subframe_idx; @@ -916,15 +912,8 @@ ivas_error ivas_sba_dec_render_fx( SPAR_DEC_HANDLE hSpar; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word32 *output_f_local_fx[MAX_OUTPUT_CHANNELS]; -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Word16 output_f_local_len; -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ivas_error error; -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - output_f_local_len = out_len; - move16(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -956,18 +945,11 @@ ivas_error ivas_sba_dec_render_fx( { Word16 n_samples_sf = imult1616( slot_size, hSpar->subframe_nbslots[subframe_idx] ); /*Q0*/ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE ivas_spar_dec_upmixer_sf_fx( st_ivas, output_f_local_fx, nchan_internal ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - ivas_spar_dec_upmixer_sf_fx( st_ivas, output_f_local_fx, nchan_internal, output_f_local_len ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( ch = 0; ch < nchan_out; ch++ ) { output_f_local_fx[ch] = output_f_local_fx[ch] + n_samples_sf; /*Q11*/ } -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - output_f_local_len = sub( output_f_local_len, n_samples_sf ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 892751057e4b82ace13ceefa493e74810b398411..e20e2df9ae0359478f56eb02f199311218e21177 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -727,12 +727,10 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( ELSE { set32_fx( hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, 0, output_frame ); -#ifdef MSAN_FIX hStereoDft->hb_nrg_subr_fx[0] = 0; move32(); hStereoDft->hb_nrg_subr_fx[1] = 0; move32(); -#endif // MSAN_FIX } hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/ move32(); @@ -1242,12 +1240,10 @@ void ivas_sba_dirac_stereo_dec_fx( CPE_DEC_HANDLE hCPE; STEREO_DFT_DEC_DATA_HANDLE hStereoDft; -#ifdef MSAN_FIX FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX ); } -#endif hSCE = st_ivas->hSCE[0]; hCPE = st_ivas->hCPE[0]; @@ -1259,18 +1255,10 @@ void ivas_sba_dirac_stereo_dec_fx( q_dft[1] = hCPE->hStereoDft->q_dft; move16(); -#ifdef MSAN_FIX Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ -#else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); -#endif IF( hSCE != NULL ) { -#ifdef MSAN_FIX Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ -#else - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); -#endif // MSAN_FIX hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft; move16(); } @@ -1400,18 +1388,10 @@ void ivas_sba_dirac_stereo_dec_fx( set32_fx( output[ch], 0, output_frame ); } -#ifdef MSAN_FIX Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ -#else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); -#endif IF( hSCE != NULL ) { -#ifdef MSAN_FIX Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ -#else - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); -#endif // MSAN_FIX hSCE->q_prev_hb_synth_fx = Q11; move16(); } diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 6c4d7a9ac9c830818877e0731d1d8abedc87275e..38b403606647791cede76f1d1ab907a18089bed4 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -787,11 +787,11 @@ void ivas_spar_get_cldfb_gains_fx( cldfbAnalysis_ts_fx_fixed_q( ts_inout_fx, ts_re_fx, ts_im_fx, num_cldfb_bands, cldfbAnaDec0, &q_cldfb ); cldfb_reset_memory_fx( cldfbSynDec0 ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, 0, cldfbSynDec0 ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, cldfbSynDec0 ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, cldfbSynDec0 ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( sample = 0; sample < stride; sample++ ) { T_fx[( ( slot * stride ) + sample )][slot] = ts_inout_fx[sample]; /*Q21*/ @@ -1161,10 +1161,8 @@ void ivas_spar_get_parameters_fx( split_band = SPAR_DIRAC_SPLIT_START_BAND; move16(); -#ifdef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS Word16 add_weight_fx = sub( MAX_WORD16, weight_fx ); Word16 add_weight_20ms_fx = sub( MAX_WORD16, weight_20ms_fx ); -#endif FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ ) @@ -1179,13 +1177,8 @@ void ivas_spar_get_parameters_fx( { IF( GT_16( hSpar->i_subframe, 3 ) ) { -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS - par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_fx ) ), - Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ) ); /*hSpar->hMdDec->Q_mixer_mat*/ -#else par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ), hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], add_weight_fx ); -#endif move32(); } ELSE @@ -1202,12 +1195,8 @@ void ivas_spar_get_parameters_fx( /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ move16(); -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS - par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_20ms_fx ) ), Mpy_32_16_1( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ) ); /*hSpar->hMdDec->Q_mixer_mat*/ -#else par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], add_weight_20ms_fx ), hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ); /*hSpar->hMdDec->Q_mixer_mat*/ -#endif move32(); } } @@ -1367,17 +1356,10 @@ static void ivas_spar_calc_smooth_facs_fx( smooth_long_avg_fx[b] = L_add( smooth_long_avg_fx[b], smooth_buf_fx[b][i] ); // Q0 move32(); } -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_HQ_CONSTANTS - smooth_short_avg_fx[b] = Mpy_32_16_1( smooth_short_avg_fx[b], 5461 /*(1/6 in Q15)*/ ); // Q0 - move32(); - smooth_long_avg_fx[b] = Mpy_32_16_1( smooth_long_avg_fx[b], 1639 /*(1/20 in Q15)*/ ); // Q0 - move32(); -#else - smooth_short_avg_fx[b] = Mpy_32_32( smooth_short_avg_fx[b], 357913941 /*(1/6 in Q31)*/ ); // Q0 + smooth_short_avg_fx[b] = Mpy_32_32( smooth_short_avg_fx[b], 357913941 /*(1/6 in Q31)*/ ); // Q0 move32(); smooth_long_avg_fx[b] = Mpy_32_32( smooth_long_avg_fx[b], 107374182 /*(1/20 in Q31)*/ ); // Q0 move32(); -#endif /* calculate smoothing factor based on energy averages */ /* reduce factor for higher short-term energy */ @@ -1689,10 +1671,6 @@ void ivas_spar_dec_upmixer_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Word32 *output_fx[], /* o : output audio channels Q11*/ const Word16 nchan_internal /* i : number of internal channels Q0*/ -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - , - Word16 out_len -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ ) { Word16 cldfb_band, num_cldfb_bands, numch_in, numch_out; @@ -1793,9 +1771,7 @@ void ivas_spar_dec_upmixer_sf_fx( * Prepare CLDFB buffers *---------------------------------------------------------------------*/ -#ifdef MSAN_FIX set_zero_fx( &Pcm_tmp_fx[0][0], ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ) * L_FRAME48k ); -#endif // MSAN_FIX /* set-up pointers */ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) { @@ -1871,9 +1847,7 @@ void ivas_spar_dec_upmixer_sf_fx( ivas_spar_calc_smooth_facs_fx( cldfb_in_ts_re_fx[0], cldfb_in_ts_im_fx[0], q_cldfb, num_spar_bands, hSpar->subframe_nbslots[hSpar->subframes_rendered], hSpar->subframes_rendered == 0, &hSpar->hFbMixer->pFb->fb_bin_to_band, hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_buf_fx ); } -#ifdef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL Word16 sh_l = sub( 31, q1 ); -#endif FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { md_idx = hSpar->render_to_md_map[( ts + slot_idx_start )]; /*Q0*/ @@ -1889,18 +1863,12 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE Word16 diff = sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) { FOR( in_ch = 0; in_ch < numch_in; in_ch++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE mixer_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], diff ), hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ); /*q1*/ -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - mixer_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ) ), hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ); /*q1*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ move32(); hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band] = mixer_mat_fx[out_ch][in_ch][spar_band]; /*q1*/ move32(); @@ -1908,68 +1876,6 @@ void ivas_spar_dec_upmixer_sf_fx( } } } -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS - FOR( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) - { - Word32 out_re_fx[IVAS_SPAR_MAX_CH]; - Word32 out_im_fx[IVAS_SPAR_MAX_CH]; - Word32 cldfb_par_fx; /*q1*/ - ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - - FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) - { - out_re_fx[out_ch] = 0; - move32(); - out_im_fx[out_ch] = 0; - move32(); - FOR( in_ch = 0; in_ch < numch_in; in_ch++ ) - { - IF( b_skip_mat[out_ch][in_ch] == 0 ) - { - IF( LT_16( cldfb_band, CLDFB_PAR_WEIGHT_START_BAND ) ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ - { - spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; /*Q0*/ - move16(); - cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band]; /*q1*/ - move32(); - } - ELSE - { - Word64 acc = 0; - move64(); - FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) - { - /* accumulate contributions from all SPAR bands */ - acc = W_mac_32_32( acc, mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ); // q1+ Q23 - } - cldfb_par_fx = W_shl_sat_l( acc, -23 ); // q1 - } - - out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/ - move32(); - out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/ - move32(); - } - } - } - - /*update CLDFB data with the parameter-modified data*/ - FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) - { -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL - cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/ - move32(); - cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/ - move32(); -#else - cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sh_l ); /*Q=6*/ - move32(); - cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sh_l ); /*Q=6*/ - move32(); -#endif - } - } -#else /* FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS */ /* Note: This version splits the cldfb band loop into 2 loops, removing some inner-loop IF_statements */ Word16 min_cldf_band = s_min( CLDFB_PAR_WEIGHT_START_BAND, num_cldfb_bands ); Word32 out_re_fx[IVAS_SPAR_MAX_CH]; @@ -2004,17 +1910,10 @@ void ivas_spar_dec_upmixer_sf_fx( /*update CLDFB data with the parameter-modified data*/ FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) { -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL - cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/ - move32(); - cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/ - move32(); -#else cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sh_l ); /*Q=6*/ move32(); cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sh_l ); /*Q=6*/ move32(); -#endif } } @@ -2052,20 +1951,12 @@ void ivas_spar_dec_upmixer_sf_fx( /*update CLDFB data with the parameter-modified data*/ FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) { -#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL - cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/ - move32(); - cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/ - move32(); -#else cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sh_l ); /*Q=6*/ move32(); cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sh_l ); /*Q=6*/ move32(); -#endif } } -#endif /* FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS */ test(); IF( ( EQ_16( ( add( add( slot_idx_start, ts ), 1 ) ), hSpar->num_slots ) ) || ( NE_16( ( shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */ ), ( hSpar->render_to_md_map[( ( slot_idx_start + ts ) + 1 )] / JBM_CLDFB_SLOTS_IN_SUBFRAME /*It's value is 4*/ ) ) ) ) { @@ -2080,12 +1971,6 @@ void ivas_spar_dec_upmixer_sf_fx( } IF( LT_16( split_band, IVAS_MAX_NUM_BANDS ) ) { -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], hSpar->hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[4][0][0], hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) { @@ -2093,7 +1978,6 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( b = 0; b < num_spar_bands; b++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE hSpar->hMdDec->mixer_mat_prev_fx[0][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_prev_fx[1][out_ch][in_ch][b]; hSpar->hMdDec->mixer_mat_prev_fx[1][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_prev_fx[2][out_ch][in_ch][b]; hSpar->hMdDec->mixer_mat_prev_fx[2][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_prev_fx[3][out_ch][in_ch][b]; @@ -2102,7 +1986,6 @@ void ivas_spar_dec_upmixer_sf_fx( move32(); move32(); move32(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][( b + ( md_sf * IVAS_MAX_NUM_BANDS ) )]; /*hSpar->hMdDec->Q_mixer_mat*/ move32(); @@ -2161,26 +2044,14 @@ void ivas_spar_dec_upmixer_sf_fx( !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) #endif { -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, -6 ); /*st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state-6*/ - st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 ); - move16(); - Scale_sig32( output_fx[ch], out_len, -6 ); /*Q5*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Scale_sig32( output_fx[ch], out_len, 6 ); /*Q11*/ - Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, 6 ); /*st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state+6*/ - st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = add( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 ); - move16(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ } idx_in = add( idx_in, 1 ); @@ -2192,26 +2063,14 @@ void ivas_spar_dec_upmixer_sf_fx( /* CLDFB to time synthesis (overwrite mixer output) */ FOR( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, -6 ); /*st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state-6*/ - st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state, 6 ); - move16(); - Scale_sig32( output_fx[out_ch], out_len, -6 ); /*Q5*/ -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[out_ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[out_ch] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, st_ivas->cldfbSynDec[out_ch] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } -#ifndef OPT_SBA_AVOID_SPAR_RESCALE - Scale_sig32( output_fx[out_ch], out_len, 6 ); /*Q11*/ - Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, 6 ); /*st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state+6*/ - st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state = add( st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state, 6 ); - move16(); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index f893c4b31e4edf1b9a8c9c0b84f06541f5f1f555..d86ece7c87df0deb8a3a03bc1c84074ff185bae5 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -996,9 +996,7 @@ typedef struct decoder_tc_buffer_structure Word32 *tc_buffer_fx; /* the buffer itself */ Word16 tc_buff_len; /*stores memory length of tc buffer*/ Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ // VE2SB: TBV -#ifdef MSAN_FIX - Word16 no_channels; /*Stores no of channels in tc_fx with values*/ -#endif + Word16 no_channels; /*Stores no of channels in tc_fx with values*/ Word16 q_tc_fx; TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ Word16 nchan_transport_jbm; /* number of TCs after TC decoding */ diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 223860db0f18067279a25906c3832a1673cdbac2..6b8a8f949435c9e234e51f8e02128cb8ba4073de 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -316,7 +316,7 @@ static void stereo_dft_generate_comfort_noise_fx( // lp_ener_fx will be in Q6 at this point. // So applying appropriate left shift on the denominator. - factor = L_shr( BASOP_Util_Divide3232_Scale_cadence( st->lp_ener_fx, L_shl( st->L_frame, Q6 ), &q_div ), 1 ); /* fixed factor in the loop below */ /* q_div */ + factor = L_shr( BASOP_Util_Divide3232_Scale_newton( st->lp_ener_fx, L_shl( st->L_frame, Q6 ), &q_div ), 1 ); /* fixed factor in the loop below */ /* q_div */ factor = Sqrt32( factor, &q_div ); q_div = add( q_div, 1 ); @@ -399,7 +399,7 @@ static void stereo_dft_generate_comfort_noise_fx( assert( ftmp > 0 ); q_div = 0; move16(); - ftmp = BASOP_Util_Divide3232_Scale_cadence( L_shl( 1, q_tmp ), ftmp, &q_div ); /* q_div */ + ftmp = BASOP_Util_Divide3232_Scale_newton( L_shl( 1, q_tmp ), ftmp, &q_div ); /* q_div */ /* in float: both a = "div"=(1/(x^2+y^2) and sqrt(a) is used and summed up in the same loop. @@ -672,7 +672,7 @@ static void stereo_dft_generate_comfort_noise_fx( move16(); FOR( k = 0; k < ( hFdCngCom->nFFTpart - 2 ); k++ ) { - factor = BASOP_Util_Divide3232_Scale_cadence( L_add( hFdCngCom->sidNoiseEstLp[k], DELTA_FX ), L_add( st->hFdCngDec->partNoiseShape[k], DELTA_FX ), &q_div ); /* q_div */ + factor = BASOP_Util_Divide3232_Scale_newton( L_add( hFdCngCom->sidNoiseEstLp[k], DELTA_FX ), L_add( st->hFdCngDec->partNoiseShape[k], DELTA_FX ), &q_div ); /* q_div */ q_div = add( q_div, sub( hFdCngCom->sidNoiseEstExp, st->hFdCngDec->partNoiseShape_exp ) ); IF( q_div < 0 ) { @@ -683,12 +683,8 @@ static void stereo_dft_generate_comfort_noise_fx( factor = L_min( L_add( L_shl( hStereoDft->scale_fx, sub( 16, q_div ) ), W_extract_l( W_mult0_32_32( Mpy_32_16_1( L_sub( factor, L_shl( hStereoDft->scale_fx, sub( 16, q_div ) ) ), ONE_BY_MAX_K ), hStereoCng->xfade_frame_counter ) ) ), factor ); /* q_div */ 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 */ hFdCngCom->cngNoiseLevel[j] = L_shl_sat( Mpy_32_32( st->hFdCngDec->bandNoiseShape[j], factor ), q_div ); /* exp(st->hFdCngDec->bandNoiseShape_exp) */ -#else - hFdCngCom->cngNoiseLevel[j] = L_shl( Mpy_32_32( st->hFdCngDec->bandNoiseShape[j], factor ), q_div ); /* exp(st->hFdCngDec->bandNoiseShape_exp) */ -#endif move32(); } } diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index f0fd1978b2e03862de5a38a572aff48efa0c3002..92ae9159cd99b32fcbf18839bed6508bc7bcbe70 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -281,7 +281,7 @@ void stereo_dft_dec_analyze_fx( move16(); NFFT = NS2SA_FX2( inputFs, STEREO_DFT32MS_N_NS ); Word16 qfac_fx; - fac_fx = BASOP_Util_Divide3232_Scale_cadence( hStereoDft->NFFT, NFFT, &qfac_fx ); /* qfac_fx */ + fac_fx = BASOP_Util_Divide3232_Scale_newton( hStereoDft->NFFT, NFFT, &qfac_fx ); /* qfac_fx */ qfac_fx = sub( 31, qfac_fx ); ovl2 = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL2_NS ); move16(); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 9c1b488cb7e16ef342cd149ab9fba129ffb0b3e1..324f2b7f3a07c34f698ba7c232b91052895d4661 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -96,9 +96,7 @@ void stereo_dft_dec_reset_fx( { Word16 i; Word16 j, b; -#ifdef MSAN_FIX set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); -#endif /*Configuration*/ set16_fx( hStereoDft->prm_res, hStereoDft->hConfig->prm_res, STEREO_DFT_DEC_DFT_NB ); @@ -122,25 +120,13 @@ void stereo_dft_dec_reset_fx( set16_fx( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX ); -#ifdef MSAN_FIX FOR( i = 0; i < STEREO_DFT_BAND_MAX * 2; i++ ) { hStereoDft->res_gains_ind_fx[0][i] = 1006632960; /* 15.0f in Q26 */ move32(); } -#else - FOR( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) - { - hStereoDft->res_gains_ind_fx[0][i] = 1006632960; /* 15.0f in Q26 */ - move32(); - } -#endif -#ifdef MSAN_FIX set32_fx( hStereoDft->res_gains_ind_fx[1], 0, STEREO_DFT_BAND_MAX * 2 ); -#else - set32_fx( hStereoDft->res_gains_ind_fx[1], 0, STEREO_DFT_BAND_MAX ); -#endif /*residual coding*/ set16_fx( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB ); @@ -260,7 +246,6 @@ void stereo_dft_dec_reset_fx( move32(); hStereoDft->frame_sid_nodata = 0; move16(); -#ifdef MSAN_FIX FOR( b = 0; b < 2 * IVAS_MAX_NUM_BANDS; b++ ) { FOR( i = 0; i < 2; i++ ) @@ -272,19 +257,6 @@ void stereo_dft_dec_reset_fx( } } } -#else - FOR( b = 0; b < hStereoDft->nbands; b++ ) - { - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; - move32(); - } - } - } -#endif hStereoDft->first_frame = 1; move16(); hStereoDft->g_L_prev_fx = 0; @@ -429,9 +401,7 @@ ivas_error stereo_dft_dec_create_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); } -#ifdef MSAN_FIX set_zero_fx( hStereoDft_loc->hb_nrg_subr_fx, STEREO_DFT_NBDIV ); /*Setting hb_nrg_subr_fx to zero*/ -#endif // MSAN_FIX hStereoDft_loc->hConfig->force_mono_transmission = 0; move16(); @@ -1436,11 +1406,7 @@ void stereo_dft_dec_res_fx( move32(); } } -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ -#else - Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ -#endif IF( res_bpf_flag ) { v_sub_32( output, bpf_error_signal_8k, output, L_FRAME8k ); @@ -1451,20 +1417,12 @@ void stereo_dft_dec_res_fx( set16_fx( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k ); hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; move16(); -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ -#else - Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ -#endif } ELSE { /* This step is needed to ensure output is properly populated with scaled values in all cases*/ -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ -#else - Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ -#endif } return; diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 694aad0b4a921922562c30f727dfa570e52d3dc2..73cf9ccd0c779ab296f375a180d893068f3020a2 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -59,13 +59,8 @@ void stereo_tca_dec_fx( ) { /* Buffers, input Left and right channels @ input_Fs*/ -#ifdef MSAN_FIX Word32 bufChanL_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k] = { 0 }; Word32 bufChanR_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k] = { 0 }; -#else - Word32 bufChanL_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k]; - Word32 bufChanR_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k]; -#endif Word32 *ptrChanL_fx, *ptrChanR_fx; Word32 *target_fx; Word16 target_idx, prevNCShift, currentNCShift, l_shift_adapt; diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 04aeccbb525f0af2ccf95974b6d878db3f3c4332..c7bc98566326d456bc85283242ad1137e28fb4c6 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -234,12 +234,10 @@ void stereo_icBWE_dec_fx( ELSE { set32_fx( hCPE->hStereoDft->hb_stefi_sig_fx + hCPE->hStereoDft->hb_stefi_delay, 0, output_frame ); -#ifdef MSAN_FIX hCPE->hStereoDft->hb_nrg_subr_fx[0] = 0; move32(); hCPE->hStereoDft->hb_nrg_subr_fx[1] = 0; move32(); -#endif // MSAN_FIX } hCPE->hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( hCPE->hStereoDft->hb_nrg_subr_fx[0], shl( shr( hCPE->hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (Qsynth + SynthRef_shift) - 40 // 2 * (Qx + SynthRef_shift) - 31 - 15 move32(); @@ -613,7 +611,7 @@ void stereo_icBWE_dec_fx( Q_syn_shb = tmp; move16(); - deemph_fx_32( 0, shb_synth_nonref_fx + L_SHB_LAHEAD, specMapping_fx, L_FRAME16k, &( hStereoICBWE->memShbSpecMapping_fx ) ); + deemph_fx_32( shb_synth_nonref_fx + L_SHB_LAHEAD, specMapping_fx, L_FRAME16k, &( hStereoICBWE->memShbSpecMapping_fx ) ); hStereoICBWE->prev_Q_memshbspec = Q_syn_shb; move16(); Copy32( shb_synth_nonref_fx + L_FRAME16k, hStereoICBWE->mem_syn_shb_nonref_fx, L_SHB_LAHEAD ); /* Q_syn_shb */ @@ -719,13 +717,9 @@ void stereo_icBWE_dec_fx( { IF( LE_16( ratio_L_fx, 29490 /* 0.9 in Q15*/ ) ) { -#ifdef FIX_TMP_714 tmp = mult_r( ratio_L_fx, ratio_L_fx ); // Q15 -#else - tmp = mult_r( sub( 32767, ratio_L_fx ), sub( 32767, ratio_L_fx ) ); // Q15 -#endif - tmp = mult_r( tmp, gsMapping_fx ); // Q14 - tmp = mult_r( tmp, gsMapping_fx ); // Q13 + tmp = mult_r( tmp, gsMapping_fx ); // Q14 + tmp = mult_r( tmp, gsMapping_fx ); // Q13 IF( LT_16( tmp, 4096 /* 0.5 in Q13*/ ) ) { temp1_fx = 0; @@ -819,11 +813,7 @@ void stereo_icBWE_dec_fx( hStereoICBWE->prev_Q_fsout = tmp; move16(); } -#ifndef MSAN_FIX - Scale_sig32( synth_fx, L_FRAME48k, sub( *Q_syn, add( 1, tmp ) ) ); -#else - Scale_sig32( synth_fx, output_frame, sub( *Q_syn, add( 1, tmp ) ) ); /* Qsyn - 1 */ -#endif + Scale_sig32( synth_fx, output_frame, sub( *Q_syn, add( 1, tmp ) ) ); /* Qsyn - 1 */ *Q_syn = sub( *Q_syn, 1 ); @@ -886,13 +876,9 @@ void stereo_icBWE_dec_fx( { IF( LE_16( ratio_L_fx, 29490 /* 0.9 in Q15*/ ) ) { -#ifdef FIX_TMP_714 tmp = mult_r( ratio_L_fx, ratio_L_fx ); // Q15 -#else - tmp = mult_r( sub( 32767, ratio_L_fx ), sub( 32767, ratio_L_fx ) ); // Q15 -#endif - tmp = mult_r( tmp, gsMapping_fx ); // Q14 - tmp = mult_r( tmp, gsMapping_fx ); // Q13 + tmp = mult_r( tmp, gsMapping_fx ); // Q14 + tmp = mult_r( tmp, gsMapping_fx ); // Q13 IF( LT_16( tmp, 4096 /* 0.5 in Q13*/ ) ) { temp1_fx = 0; diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index a6b350d3301a38c47499587c69b988d1fa1b3abf..890e5fc9ef6db902a60454e094612449ceac424c 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -469,6 +469,14 @@ void stereo_mdct_core_dec_fx( move16(); move16(); + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + if ( NE_16( hCPE->hCoreCoder[ch]->core, TCX_20_CORE ) ) + { + x_e[ch][1] = x_e[ch][0]; + move16(); + } + } stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0, &q_x_1, &q_x_0 ); } @@ -540,13 +548,8 @@ void stereo_mdct_core_dec_fx( move16(); } } -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) ); /* Q28 */ - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0] - 1 ) ) ); /* Q28 */ -#endif ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, e_sigFB ); Copy32( signal_out_tmp_fx[0], signal_out_fx[0], L_FRAME48k ); /* Q11 */ diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 5b1378a894fead3f6efabcef3e7746132dccad56..8842a6792a8c866cbcc17e6b0b0a9f1a32f7392d 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -433,7 +433,7 @@ void stereo_decoder_tcx_fx( IF( !mct_on ) { - tmp_32 = BASOP_Util_Divide3232_Scale_cadence( SMDCT_ILD_RANGE << 16, L_deposit_h( hStereoMdct->global_ild[k] ), &tmp_e ); + tmp_32 = BASOP_Util_Divide3232_Scale_newton( SMDCT_ILD_RANGE << 16, L_deposit_h( hStereoMdct->global_ild[k] ), &tmp_e ); tmp_32 = L_shr( tmp_32, sub( 5, tmp_e ) ); /* nrgRatio = nrg[1]/nrg[0] */ // Q26 nrgRatio = L_sub( tmp_32, ONE_IN_Q26 ); // Q26 @@ -488,7 +488,7 @@ void stereo_decoder_tcx_fx( } ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) ) { - inv_nrgRatio = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q26, nrgRatio, &tmp_e ); + inv_nrgRatio = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q26, nrgRatio, &tmp_e ); shift = sub( 5, tmp_e ); v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */ Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */ @@ -904,13 +904,8 @@ void updateBuffersForDmxMdctStereo_fx( move16(); sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = add( sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, 1 ); move16(); -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( &sts[0]->hTcxLtpDec->tcxltp_mem_in[0], &sts[0]->hTcxLtpDec->tcxltp_mem_in_32[0], TCXLTP_MAX_DELAY, sub( 11, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in ) ) ); // Q11 Copy_Scale_sig_16_32_no_sat( &sts[0]->hTcxLtpDec->tcxltp_mem_out[0], &sts[0]->hTcxLtpDec->tcxltp_mem_out_32[0], TCXLTP_MAX_DELAY, sub( 11, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out ) ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( &sts[0]->hTcxLtpDec->tcxltp_mem_in[0], &sts[0]->hTcxLtpDec->tcxltp_mem_in_32[0], TCXLTP_MAX_DELAY, sub( 11, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in ) ) ); // Q11 - Copy_Scale_sig_16_32_DEPREC( &sts[0]->hTcxLtpDec->tcxltp_mem_out[0], &sts[0]->hTcxLtpDec->tcxltp_mem_out_32[0], TCXLTP_MAX_DELAY, sub( 11, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out ) ) ); // Q11 -#endif } return; diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 6c2ad055c02f74fed3a8bf773bc70983246c9915..bcf714352d2e72e7f4c890d442651bd05648976f 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -197,9 +197,7 @@ static ivas_error allocate_CoreCoder_fx( } hf_synth_init_fx( st->hBWE_zero ); -#ifdef MSAN_FIX set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif } IF( st->cldfbAna == NULL ) @@ -2153,21 +2151,13 @@ void stereo_td2dft_update_fx( /* update buffers used for fading when switching to DFT Stereo */ v_add_fx( sts[0]->hHQ_core->old_out_LB_fx32 + nsLB, sts[1]->hHQ_core->old_out_LB_fx32 + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); -#ifndef MSAN_FIX - for ( i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) -#else FOR( i = 0; i < old_outLB_len; i++ ) -#endif { hCPE->old_outLB_mdct_fx[i] = L_shr( hCPE->old_outLB_mdct_fx[i], 1 ); /* Q11 */ move32(); } v_add_fx( sts[0]->hHQ_core->old_out_fx32 + ns, sts[1]->hHQ_core->old_out_fx32 + ns, hCPE->old_out_mdct_fx, old_out_len ); /* exp(exp_old_out) */ -#ifndef MSAN_FIX - for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) -#else FOR( i = 0; i < old_out_len; i++ ) -#endif { hCPE->old_out_mdct_fx[i] = L_shr( hCPE->old_out_mdct_fx[i], 1 ); /* q_old_out_mdct */ move32(); @@ -2371,7 +2361,7 @@ static Word32 ncross_corr_self_fx( Word16 q_cc = W_norm( c_c_fx ); Word32 num = W_extract_h( W_shl( c_c_fx, q_cc ) ); // Q(23 + q_cc - 32) -> e(40 - q_cc) Word16 quo_e; - num = BASOP_Util_Divide3232_Scale_cadence( num, energy, &quo_e ); + num = BASOP_Util_Divide3232_Scale_newton( num, energy, &quo_e ); quo_e = add( sub( sub( 40, q_cc ), q_prod ), quo_e ); c_c_fx_return = L_shl_sat( num, quo_e ); // Q31 } diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index 1467687d8b49a576e6b28bbc4ac58a7ccdd2065d..4b052288430d888a2b29857d24ec105999397042 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -70,11 +70,7 @@ static void biDiagonalReductionLeft_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 *singularVectors_e, -#else Word16 singularVectors2_e[][MAX_OUTPUT_CHANNELS], -#endif Word16 singularValues_e[MAX_OUTPUT_CHANNELS], Word16 *secDiag_e, const Word16 nChannelsL, /* Q0 */ @@ -88,11 +84,7 @@ static void biDiagonalReductionLeft_fx( static void biDiagonalReductionRight_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 *singularVectors_e, -#else Word16 singularVectors2_e[][MAX_OUTPUT_CHANNELS], -#endif Word16 *secDiag_e, const Word16 nChannelsL, /* Q0 */ const Word16 nChannelsC, /* Q0 */ @@ -105,11 +97,7 @@ static void biDiagonalReductionRight_fx( static void singularVectorsAccumulationLeft_fx( Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) as Input, Q31 as output */ Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 singularVectors_e, -#else Word16 singularVectors_Left_e[][MAX_OUTPUT_CHANNELS], -#endif Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ const Word16 nChannelsC /* Q0 */ @@ -119,16 +107,8 @@ static void singularVectorsAccumulationRight_fx( Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* singularVectors_e */ Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* singularVectors_e */ Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 singularVectors_e, -#else Word16 singularVectors_Left_e[][MAX_OUTPUT_CHANNELS], -#endif -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 secDiag_e, -#else Word16 *secDiag_e, -#endif const Word16 nChannelsC /* Q0 */ ); @@ -168,7 +148,6 @@ static void ApplyRotation_fx( const Word16 nChannels /* Q0 */ ); -#ifdef FIX_1010_OPT_GIVENS_INV static void GivensRotation2_fx( const Word32 x, /* exp(x_e) */ const Word16 x_e, @@ -178,7 +157,6 @@ static void GivensRotation2_fx( Word32 *resultInv, Word16 *out_e, Word16 *outInv_e ); -#endif static Word32 GivensRotation_fx( const Word32 x, /* exp(x_e) */ @@ -306,11 +284,7 @@ Word16 svd_fx( Word16 lengthSingularValues; Word16 errorMessage, condition; Word32 secDiag_fx[MAX_OUTPUT_CHANNELS]; -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 secDiag_fx_e = 0; -#else Word16 secDiag_fx_e[MAX_OUTPUT_CHANNELS]; -#endif move16(); Word32 eps_x_fx = 0, temp_fx; move16(); @@ -320,11 +294,6 @@ Word16 svd_fx( push_wmops( "svd_fx" ); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - set32_fx( secDiag_fx, 0, MAX_OUTPUT_CHANNELS ); - set16_fx( singularValues_fx_e, 0, MAX_OUTPUT_CHANNELS ); -#endif - /* Collecting Values */ FOR( iCh = 0; iCh < nChannelsL; iCh++ ) { @@ -336,22 +305,14 @@ Word16 svd_fx( } /* Householder reduction */ -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - HouseholderReduction_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, InputMatrix_e, singularValues_fx_e, &secDiag_fx_e, nChannelsL, nChannelsC, &eps_x_fx, &eps_x_fx_e ); -#else HouseholderReduction_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, InputMatrix_e, singularValues_fx_e, secDiag_fx_e, nChannelsL, nChannelsC, &eps_x_fx, &eps_x_fx_e ); -#endif /* Set extremely small values to zero if needed */ // flushToZeroArray(singularValues, max_length); // flushToZeroMat(singularVectors_Left, nChannelsL, nChannelsL); // flushToZeroMat(singularVectors_Right, nChannelsC, nChannelsC); /* BidagonalDiagonalisation */ -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - errorMessage = BidagonalDiagonalisation_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, singularValues_fx_e, &secDiag_fx_e, nChannelsL, nChannelsC, eps_x_fx, eps_x_fx_e ); /* Q0 */ -#else errorMessage = BidagonalDiagonalisation_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, singularValues_fx_e, secDiag_fx_e, nChannelsL, nChannelsC, eps_x_fx, eps_x_fx_e ); /* Q0 */ -#endif /* Sort the singular values descending order */ lengthSingularValues = s_min( nChannelsL, nChannelsC ); /* Q0 */ @@ -423,15 +384,11 @@ static Word16 BidagonalDiagonalisation_fx( Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_fx_e*/ Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_fx_e*/ Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 *secDiag_fx_e, /* i/o: */ -#else - Word16 *secDiag_new_e, /* i/o: */ -#endif - const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ - const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed Q0*/ - const Word32 eps_x, /* i : eps_x_e*/ - const Word16 eps_x_e /* i : */ + Word16 *secDiag_new_e, /* i/o: */ + const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ + const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed Q0*/ + const Word32 eps_x, /* i : eps_x_e*/ + const Word16 eps_x_e /* i : */ ) { Word16 kCh, nCh, iCh, jCh, split; @@ -441,9 +398,7 @@ static Word16 BidagonalDiagonalisation_fx( move16(); move16(); Word16 temp_exp; -#ifdef FIX_1010_OPT_NORM_NOSAT Word16 temp_exp2; -#endif Word32 g = 0; move16(); Word16 g_e = 0; @@ -451,14 +406,8 @@ static Word16 BidagonalDiagonalisation_fx( Word16 convergence, iteration, found_split; Word16 error = 0; move16(); -#ifdef FIX_1010_OPT_GIVENS_INV Word32 temp; -#endif Word16 singularValues_new_e[MAX_OUTPUT_CHANNELS]; -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 secDiag_new_e[MAX_OUTPUT_CHANNELS]; - set16_fx( secDiag_new_e, *secDiag_fx_e, MAX_OUTPUT_CHANNELS ); -#endif Copy( singularValues_fx_e, singularValues_new_e, MAX_OUTPUT_CHANNELS ); FOR( iCh = nChannelsC - 1; iCh >= 0; iCh-- ) /* nChannelsC */ @@ -527,46 +476,17 @@ static Word16 BidagonalDiagonalisation_fx( c = singularValues_fx[kCh]; /* exp(singularValues_new_e) */ c_e = singularValues_new_e[kCh]; -#ifdef FIX_1010_OPT_GIVENS_INV GivensRotation2_fx( g, g_e, singularValues_fx[kCh], singularValues_new_e[kCh], &singularValues_fx[kCh], &temp, &singularValues_new_e[kCh], &temp_exp ); /* exp(singularValues_new_e) */ c = Mpy_32_32( c, temp ); c_e = add( c_e, temp_exp ); -#else - singularValues_fx[kCh] = GivensRotation_fx( g, g_e, singularValues_fx[kCh], singularValues_new_e[kCh], &singularValues_new_e[kCh] ); /* exp(singularValues_new_e) */ - c = BASOP_Util_Divide3232_Scale_cadence( c, maxWithSign_fx( singularValues_fx[kCh] ), &temp_exp ); /* exp(temp_exp + (c_e - singularValues_new_e)) */ - c_e = add( temp_exp, sub( c_e, singularValues_new_e[kCh] ) ); -#endif -#ifndef FIX_1010_OPT_NORM_NOSAT - IF( c_e > 0 ) - { - c = L_shl_sat( c, c_e ); // Q31 - c_e = 0; - move16(); - } -#else temp_exp2 = norm_l( c ); c = L_shl( c, temp_exp2 ); c_e = sub( c_e, temp_exp2 ); -#endif -#ifdef FIX_1010_OPT_GIVENS_INV s = Mpy_32_32( -g, temp ); s_e = add( g_e, temp_exp ); -#else - s = BASOP_Util_Divide3232_Scale_cadence( -g, maxWithSign_fx( singularValues_fx[kCh] ), &temp_exp ); /* exp(temp_exp + (g_e - singularValues_new_e))*/ - s_e = add( temp_exp, sub( g_e, singularValues_new_e[kCh] ) ); -#endif -#ifndef FIX_1010_OPT_NORM_NOSAT - IF( s_e > 0 ) - { - s = L_shl_sat( s, s_e ); // Q31 - s_e = 0; - move16(); - } -#else temp_exp2 = norm_l( s ); s = L_shl( s, temp_exp2 ); s_e = sub( s_e, temp_exp2 ); -#endif ApplyRotation_fx( singularVectors_Left_fx, c, c_e, s, s_e, 0, x11_e, 0, x12_e, &f1, &f1_e, &f2, &f2_e, kCh, split, nChannelsL ); /* nChannelsL */ } } @@ -617,24 +537,6 @@ static Word16 BidagonalDiagonalisation_fx( // rescaling block Copy( singularValues_new_e, singularValues_fx_e, MAX_OUTPUT_CHANNELS ); -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 max_exp = -31; - move16(); - FOR( iCh = 0; iCh < nChannelsC; iCh++ ) - { - if ( secDiag_fx[iCh] ) - { - max_exp = s_max( max_exp, secDiag_new_e[iCh] ); - } - } - *secDiag_fx_e = max_exp; - move16(); - FOR( iCh = 0; iCh < nChannelsC; iCh++ ) - { - secDiag_fx[iCh] = L_shr_r( secDiag_fx[iCh], sub( *secDiag_fx_e, secDiag_new_e[iCh] ) ); /* exp(secDiag_fx_e) */ - move32(); - } -#endif return ( error ); } @@ -658,13 +560,9 @@ static void ApplyQRTransform_fx( const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ ) { -#ifdef FIX_1010_OPT_GIVENS_INV Word32 temp; Word16 temp_e; -#endif -#ifdef FIX_1010_OPT_NORM_NOSAT Word16 temp_norm_e; -#endif Word16 ch, split; Word32 d = 0, g = 0, r = 0, x_ii = 0, x_split = 0, x_kk = 0, mu = 0, aux = 0; move32(); @@ -730,7 +628,7 @@ static void ApplyQRTransform_fx( L_temp1 = BASOP_Util_Add_Mant32Exp( r, r_e, r, r_e, &L_temp1_e ); /* exp(L_temp1_e) */ L_temp1 = maxWithSign_fx( Mpy_32_32( L_temp1, x_split ) ); /* exp(L_temp1_e + x_split_e) */ L_temp1_e = add( L_temp1_e, x_split_e ); - d = BASOP_Util_Divide3232_Scale_cadence( d, L_temp1, &temp_exp ); /* temp_exp + d_e - L_temp1_e */ + d = BASOP_Util_Divide3232_Scale_newton( d, L_temp1, &temp_exp ); /* temp_exp + d_e - L_temp1_e */ d_e = add( temp_exp, sub( d_e, L_temp1_e ) ); g = GivensRotation_fx( MAX_32, 0, d, d_e, &g_e ); @@ -748,7 +646,7 @@ static void ApplyQRTransform_fx( L_temp1_e = g_e; move16(); L_temp2 = maxWithSign_fx( BASOP_Util_Add_Mant32Exp( d, d_e, L_temp1, L_temp1_e, &L_temp2_e ) ); /* exp(L_temp2_e) */ - mu = BASOP_Util_Divide3232_Scale_cadence( x_split, L_temp2, &mu_e ); /* exp(mu_e + (x-plit_e - L_temp2_e)) */ + mu = BASOP_Util_Divide3232_Scale_newton( x_split, L_temp2, &mu_e ); /* exp(mu_e + (x-plit_e - L_temp2_e)) */ mu_e = add( mu_e, sub( x_split_e, L_temp2_e ) ); mu = BASOP_Util_Add_Mant32Exp( mu, mu_e, L_negate( r ), r_e, &mu_e ); /* exp(mu_e) */ @@ -756,7 +654,7 @@ static void ApplyQRTransform_fx( L_temp1 = BASOP_Util_Add_Mant32Exp( x_ii, x_ii_e, x_kk, x_kk_e, &L_temp1_e ); /* exp(L_temp1_e) */ L_temp2 = BASOP_Util_Add_Mant32Exp( x_ii, x_ii_e, L_negate( x_kk ), x_kk_e, &L_temp2_e ); /* exp(L_temp2_e) */ d = BASOP_Util_Add_Mant32Exp( Mpy_32_32( L_temp1, L_temp2 ), add( L_temp1_e, L_temp2_e ), Mpy_32_32( r, mu ), add( r_e, mu_e ), &d_e ); /* exp(d_e) */ - d = BASOP_Util_Divide3232_Scale_cadence( d, maxWithSign_fx( x_ii ), &temp_exp ); /* exp(temp_exp + (d_e - x_ii_e) */ + d = BASOP_Util_Divide3232_Scale_newton( d, maxWithSign_fx( x_ii ), &temp_exp ); /* exp(temp_exp + (d_e - x_ii_e) */ d_e = add( temp_exp, sub( d_e, x_ii_e ) ); /*QR transformation*/ @@ -767,47 +665,17 @@ static void ApplyQRTransform_fx( g = Mpy_32_32( c, secDiag[ch + 1] ); /* exp(c_e + secDiag_e) */ g_e = add( c_e, secDiag_e[ch + 1] ); -#ifdef FIX_1010_OPT_GIVENS_INV GivensRotation2_fx( d, d_e, r, r_e, &secDiag[ch], &temp, &secDiag_e[ch], &temp_e ); /* exp(secDiag_e) */ c = Mpy_32_32( d, temp ); c_e = add( temp_e, d_e ); -#else - secDiag[ch] = GivensRotation_fx( d, d_e, r, r_e, &secDiag_e[ch] ); /* exp(secDiag_e) */ - move32(); - c = BASOP_Util_Divide3232_Scale_cadence( d, maxWithSign_fx( secDiag[ch] ), &c_e ); /* exp(c_e + (d_e + secDiag_e)) */ - c_e = add( c_e, sub( d_e, secDiag_e[ch] ) ); -#endif -#ifndef FIX_1010_OPT_NORM_NOSAT - IF( c_e > 0 ) - { - c = L_shl_sat( c, c_e ); // Q31 - c_e = 0; - move16(); - } -#else temp_norm_e = norm_l( c ); c = L_shl( c, temp_norm_e ); c_e = sub( c_e, temp_norm_e ); -#endif -#ifdef FIX_1010_OPT_GIVENS_INV s = Mpy_32_32( r, temp ); s_e = add( r_e, temp_e ); -#else - s = BASOP_Util_Divide3232_Scale_cadence( r, maxWithSign_fx( secDiag[ch] ), &s_e ); /* exp(s_e + (r_e - sec_Diag_e))*/ - s_e = add( s_e, sub( r_e, secDiag_e[ch] ) ); -#endif -#ifndef FIX_1010_OPT_NORM_NOSAT - IF( s_e > 0 ) - { - s = L_shl_sat( s, s_e ); // Q31 - s_e = 0; - move16(); - } -#else temp_norm_e = norm_l( s ); s = L_shl( s, temp_norm_e ); s_e = sub( s_e, temp_norm_e ); -#endif r = Mpy_32_32( s, singularValues[ch + 1] ); /* exp(r_e + secDiag_e) */ r_e = add( s_e, singularValues_e[ch + 1] ); x_split = Mpy_32_32( c, singularValues[ch + 1] ); /* exp(c_e + secDiag_e) */ @@ -821,48 +689,21 @@ static void ApplyQRTransform_fx( // ApplyRotation(singularVectors_Right, c, s, x_ii, aux, &d, &g, ch + 1, ch, nChannelsC); ApplyRotation_fx( singularVectors_Right, c, c_e, s, s_e, x_ii, x_ii_e, aux, aux_e, &d, &d_e, &g, &g_e, ch + 1, ch, nChannelsC ); -#ifdef FIX_1010_OPT_GIVENS_INV GivensRotation2_fx( d, d_e, r, r_e, &singularValues[ch], &aux, &singularValues_e[ch], &aux_e ); /* exp(singularValues_e) */ -#else - singularValues[ch] = GivensRotation_fx( d, d_e, r, r_e, &singularValues_e[ch] ); /* exp(singularValues_e) */ - move32(); -#endif IF( singularValues[ch] != 0 ) { -#ifndef FIX_1010_OPT_GIVENS_INV - aux = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, singularValues[ch], &aux_e ); /* exp(aux_e + (1 - singularValues_e)) */ - aux_e = add( aux_e, sub( 1, singularValues_e[ch] ) ); -#endif c = Mpy_32_32( d, aux ); /* exp(d_e + aux_e) */ c_e = add( d_e, aux_e ); -#ifndef FIX_1010_OPT_NORM_NOSAT - IF( c_e > 0 ) - { - c = L_shl_sat( c, c_e ); // Q31 - c_e = 0; - move16(); - } -#else temp_norm_e = norm_l( c ); c = L_shl( c, temp_norm_e ); c_e = sub( c_e, temp_norm_e ); -#endif s = Mpy_32_32( r, aux ); /* exp(r_e + aux_e) */ s_e = add( r_e, aux_e ); -#ifndef FIX_1010_OPT_NORM_NOSAT - IF( s_e > 0 ) - { - s = L_shl_sat( s, s_e ); // Q31 - s_e = 0; - move16(); - } -#else temp_norm_e = norm_l( s ); s = L_shl( s, temp_norm_e ); s_e = sub( s_e, temp_norm_e ); -#endif } // ApplyRotation(singularVectors_Left, c, s, g, x_split, &d, &x_ii, ch + 1, ch, nChannelsL); @@ -915,7 +756,6 @@ static void ApplyRotation_fx( *g = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), add( c_e, x12_e ), Mpy_32_32( L_negate( s ), x11 ), add( s_e, x11_e ), g_e ); /* exp(g_e) */ move32(); -#ifdef SVD_WMOPS_OPT Word16 c_q = sub( 31, c_e ); Word16 s_q = sub( 31, s_e ); Word32 op1, op2; @@ -957,42 +797,6 @@ static void ApplyRotation_fx( singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) move32(); } -#else -#ifndef FIX_MINOR_SVD_WMOPS_MR1010X - FOR( ch = 0; ch < nChannels; ch++ ) - { - x11 = singularVector[ch][currentIndex2]; - move32(); - x12 = singularVector[ch][currentIndex1]; - move32(); - singularVector[ch][currentIndex2] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), c_e, Mpy_32_32( s, x12 ), s_e, &temp_exp ); /* exp(temp_exp) */ - move32(); - singularVector[ch][currentIndex2] = L_shl_sat( singularVector[ch][currentIndex2], temp_exp ); /* exp(temp_exp) */ - move32(); - singularVector[ch][currentIndex1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( L_negate( s ), x11 ), s_e, &temp_exp ); /* exp(temp_exp) */ - move32(); - singularVector[ch][currentIndex1] = L_shl_sat( singularVector[ch][currentIndex1], temp_exp ); /* exp(temp_exp) */ - move32(); - } -#else - Word32 s_neg = L_negate( s ); - Word32 temp; - FOR( ch = 0; ch < nChannels; ch++ ) - { - x11 = singularVector[ch][currentIndex2]; - move32(); - x12 = singularVector[ch][currentIndex1]; - move32(); - temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), c_e, Mpy_32_32( s, x12 ), s_e, &temp_exp ); /* exp(temp_exp) */ - singularVector[ch][currentIndex2] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ - move32(); - temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( s_neg, x11 ), s_e, &temp_exp ); /* exp(temp_exp) */ - singularVector[ch][currentIndex1] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ - move32(); - } - -#endif -#endif return; } @@ -1024,7 +828,6 @@ static void HouseholderReduction_fx( Word16 sig_x_fx_e = 0; move16(); -#ifdef FIX_1010_OPT_SINGLE_RESCALE Word16 iCh, jCh; Word16 singularVectors_Left_fx_e[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; FOR( jCh = 0; jCh < nChannelsL; jCh++ ) @@ -1035,25 +838,15 @@ static void HouseholderReduction_fx( move16(); } } -#endif /* Bidiagonal Reduction for every channel */ FOR( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - biDiagonalReductionLeft_fx( singularVectors_Left_fx, singularValues_fx, secDiag_fx, &singularVectors_Left_e, singularValues_fx_e, secDiag_fx_e, nChannelsL, nChannelsC, nCh, &sig_x_fx, &sig_x_fx_e, &g_fx ); - biDiagonalReductionRight_fx( singularVectors_Left_fx, secDiag_fx, &singularVectors_Left_e, secDiag_fx_e, nChannelsL, nChannelsC, nCh, &sig_x_fx, &sig_x_fx_e, &g_fx ); -#else biDiagonalReductionLeft_fx( singularVectors_Left_fx, singularValues_fx, secDiag_fx, singularVectors_Left_fx_e, singularValues_fx_e, secDiag_fx_e, nChannelsL, nChannelsC, nCh, &sig_x_fx, &sig_x_fx_e, &g_fx ); biDiagonalReductionRight_fx( singularVectors_Left_fx, secDiag_fx, singularVectors_Left_fx_e, secDiag_fx_e, nChannelsL, nChannelsC, nCh, &sig_x_fx, &sig_x_fx_e, &g_fx ); -#endif Word16 L_temp_e; -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), singularValues_fx_e[nCh], L_abs( secDiag_fx[nCh] ), *secDiag_fx_e, &L_temp_e ); /* exp(L_temp_e) */ -#else Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), singularValues_fx_e[nCh], L_abs( secDiag_fx[nCh] ), secDiag_fx_e[nCh], &L_temp_e ); /* exp(L_temp_e) */ -#endif IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, *eps_x_fx, *eps_x_fx_e ), 1 ) ) { *eps_x_fx = L_temp; /* exp(L_temp_e) */ @@ -1064,19 +857,10 @@ static void HouseholderReduction_fx( } /* SingularVecotr Accumulation */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_e, *secDiag_fx_e, nChannelsC ); - singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_e, singularValues_fx_e, nChannelsL, nChannelsC ); -#else -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_fx_e, *secDiag_fx_e, nChannelsC ); -#else singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_fx_e, secDiag_fx_e, nChannelsC ); -#endif singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_fx_e, singularValues_fx_e, nChannelsL, nChannelsC ); -#endif return; } @@ -1091,11 +875,7 @@ static void biDiagonalReductionLeft_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 *singularVectors_e, -#else Word16 singularVectors2_e[][MAX_OUTPUT_CHANNELS], -#endif Word16 singularValues_e[MAX_OUTPUT_CHANNELS], Word16 *secDiag_e, const Word16 nChannelsL, /* Q0 */ @@ -1111,227 +891,110 @@ static void biDiagonalReductionLeft_fx( Word16 norm_x_e, f_e, r_e; Word32 L_temp; Word16 L_temp_e; -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 sing_exp[MAX_OUTPUT_CHANNELS]; - Word16 sing_exp2[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 }; - FOR( jCh = 0; jCh < MAX_OUTPUT_CHANNELS; jCh++ ) - { - set16_fx( sing_exp2[jCh], *singularVectors_e, MAX_OUTPUT_CHANNELS ); - } -#endif secDiag[currChannel] = Mpy_32_32( *sig_x, *g ); /* exp(sig_x_e) */ move32(); -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - // rescaling block - IF( GT_16( *sig_x_e, *secDiag_e ) ) - { - FOR( Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++ ){ - IF( NE_16( i, currChannel ) ){ - secDiag[i] = L_shl( secDiag[i], sub( *secDiag_e, *sig_x_e ) ); /* sig_x_e */ - move32(); - } -} -*secDiag_e = *sig_x_e; -move16(); -} -ELSE IF( LT_16( *sig_x_e, *secDiag_e ) ) -{ - secDiag[currChannel] = L_shr_r( secDiag[currChannel], sub( *secDiag_e, *sig_x_e ) ); /* exp(secDiag_e) */ - move32(); -} -#else secDiag_e[currChannel] = *sig_x_e; move16(); -#endif -/* Setting values to 0 */ -( *sig_x ) = 0; -move32(); -( *g ) = 0; -move32(); - -IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ -{ - idx = currChannel; - move16(); - - FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ - { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[jCh][currChannel] ), *singularVectors_e, sig_x_e ); /* exp(sig_x_e) */ -#else - ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[jCh][currChannel] ), singularVectors2_e[jCh][currChannel], sig_x_e ); /* exp(sig_x_e) */ -#endif - } + /* Setting values to 0 */ + ( *sig_x ) = 0; + move32(); + ( *g ) = 0; + move32(); - IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ + IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ { -#ifdef FIX_1010_OPT_DIV - Word16 invVal_e; - Word32 invVal; - invVal = BASOP_Util_Divide3232_Scale_cadence( MAXVAL_WORD32, maxWithSign_fx( *sig_x ), &invVal_e ); -#endif - norm_x = 0; - move32(); - norm_x_e = 0; + idx = currChannel; move16(); + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { -#ifndef FIX_1010_OPT_DIV -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors[jCh][currChannel] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[jCh][currChannel], maxWithSign_fx( *sig_x ), &sing_exp[jCh] ); /* exp(sing_exp + (singularVectors_e - sig_x_e) */ - move32(); - sing_exp[jCh] = add( sing_exp[jCh], sub( *singularVectors_e, *sig_x_e ) ); - move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#else - singularVectors[jCh][currChannel] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[jCh][currChannel], maxWithSign_fx( *sig_x ), &L_temp_e ); /* exp(sing_exp + (singularVectors_e - sig_x_e) */ + ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[jCh][currChannel] ), singularVectors2_e[jCh][currChannel], sig_x_e ); /* exp(sig_x_e) */ + } + + IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ + { + Word16 invVal_e; + Word32 invVal; + invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( *sig_x ), &invVal_e ); + norm_x = 0; move32(); - singularVectors2_e[jCh][currChannel] = add( L_temp_e, sub( singularVectors2_e[jCh][currChannel], *sig_x_e ) ); + norm_x_e = 0; move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( singularVectors2_e[jCh][currChannel], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#endif -#else + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { Word16 temp_e = norm_l( singularVectors[jCh][currChannel] ); singularVectors[jCh][currChannel] = Mpy_32_32( L_shl( singularVectors[jCh][currChannel], temp_e ), invVal ); /* exp(sing_exp + (singularVectors_e - sig_x_e) */ move32(); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - sing_exp[jCh] = sub( add( invVal_e, sub( *singularVectors_e, *sig_x_e ) ), temp_e ); - move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#else singularVectors2_e[jCh][currChannel] = sub( add( invVal_e, sub( singularVectors2_e[jCh][currChannel], *sig_x_e ) ), temp_e ); move16(); norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( singularVectors2_e[jCh][currChannel], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#endif -#endif - } - IF( GT_16( norm_x_e, 0 ) ) - { - norm_x = MAX_32; - move32(); - norm_x_e = 0; + } + IF( GT_16( norm_x_e, 0 ) ) + { + norm_x = MAX_32; + move32(); + norm_x_e = 0; + move16(); + } + L_temp_e = norm_x_e; move16(); - } - L_temp_e = norm_x_e; - move16(); - L_temp = Sqrt32( norm_x, &L_temp_e ); - L_temp = L_shl_r( L_temp, L_temp_e ); // Q31 - //( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) ); -#ifndef FIX_MINOR_SVD_WMOPS_MR1010X - IF( singularVectors[currChannel][idx] >= 0 ) - { - ( *g ) = L_negate( L_temp ); - move32(); - } - ELSE - { - ( *g ) = L_negate( L_negate( L_temp ) ); - move32(); - } -#else + L_temp = Sqrt32( norm_x, &L_temp_e ); + L_temp = L_shl_r( L_temp, L_temp_e ); // Q31 + //( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) ); if ( singularVectors[currChannel][idx] >= 0 ) { L_temp = L_negate( L_temp ); } ( *g ) = L_temp; move32(); -#endif - -#ifndef FIX_1010_OPT_SINGLE_RESCALE - r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[currChannel], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */ - singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], sing_exp[currChannel], -( *g ), 0, &sing_exp[currChannel] ); /* sing_exp */ -#else - r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), singularVectors2_e[currChannel][idx], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */ - singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], singularVectors2_e[currChannel][idx], -( *g ), 0, &singularVectors2_e[currChannel][idx] ); /* sing_exp */ -#endif - move32(); -#ifdef FIX_1010_OPT_DIV - invVal = BASOP_Util_Divide3232_Scale_cadence( MAXVAL_WORD32, maxWithSign_fx( r ), &invVal_e ); -#endif - - FOR( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ - { - norm_x = 0; + r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), singularVectors2_e[currChannel][idx], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */ + singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], singularVectors2_e[currChannel][idx], -( *g ), 0, &singularVectors2_e[currChannel][idx] ); /* sing_exp */ move32(); - norm_x_e = 0; - move16(); - FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + + invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( r ), &invVal_e ); + + FOR( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( sing_exp[jCh], *singularVectors_e ), &norm_x_e ); /* exp(norm_x_e) */ -#else + norm_x = 0; + move32(); + norm_x_e = 0; + move16(); + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( singularVectors2_e[jCh][currChannel], singularVectors2_e[jCh][iCh] ), &norm_x_e ); /* exp(norm_x_e) */ -#endif - } + } -#ifndef FIX_1010_OPT_DIV - f = BASOP_Util_Divide3232_Scale_cadence( norm_x, maxWithSign_fx( r ), &f_e ); /* f_e + (norm_x_e - r_e) */ - f_e = add( f_e, sub( norm_x_e, r_e ) ); -#else - f = Mpy_32_32( norm_x, invVal ); /* invVal_e + (norm_x_e - r_e) */ + f = Mpy_32_32( norm_x, invVal ); /* invVal_e + (norm_x_e - r_e) */ f_e = add( invVal_e, sub( norm_x_e, r_e ) ); -#endif - FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ - { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors[jCh][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors[jCh][iCh], *singularVectors_e, Mpy_32_32( f, singularVectors[jCh][currChannel] ), add( f_e, sing_exp[jCh] ), &sing_exp2[jCh][iCh] ); /* exp( sing_exp2) */ -#else + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { singularVectors[jCh][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors[jCh][iCh], singularVectors2_e[jCh][iCh], Mpy_32_32( f, singularVectors[jCh][currChannel] ), add( f_e, singularVectors2_e[jCh][currChannel] ), &singularVectors2_e[jCh][iCh] ); -#endif - move32(); + move32(); + } } - } - - - FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ - { - singularVectors[jCh][currChannel] = Mpy_32_32( singularVectors[jCh][currChannel], ( *sig_x ) ); /* sing_exp + sig_x_e */ - move32(); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - sing_exp2[jCh][currChannel] = add( sing_exp[jCh], *sig_x_e ); -#else - singularVectors2_e[jCh][currChannel] = add( singularVectors2_e[jCh][currChannel], *sig_x_e ); -#endif - move16(); - } -#ifndef FIX_1010_OPT_SINGLE_RESCALE - // rescaling block - Word16 exp_max = *singularVectors_e; - move16(); - FOR( iCh = 0; iCh < nChannelsC; iCh++ ) - { - FOR( jCh = 0; jCh < nChannelsL; jCh++ ) - { - exp_max = s_max( exp_max, sing_exp2[jCh][iCh] ); - } - } - FOR( iCh = 0; iCh < nChannelsC; iCh++ ) - { - FOR( jCh = 0; jCh < nChannelsL; jCh++ ) + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { - singularVectors[jCh][iCh] = L_shr_r( singularVectors[jCh][iCh], sub( exp_max, sing_exp2[jCh][iCh] ) ); /* exp(exp_max) */ + singularVectors[jCh][currChannel] = Mpy_32_32( singularVectors[jCh][currChannel], ( *sig_x ) ); /* sing_exp + sig_x_e */ move32(); + singularVectors2_e[jCh][currChannel] = add( singularVectors2_e[jCh][currChannel], *sig_x_e ); + move16(); } } - *singularVectors_e = exp_max; + + // rescaling block + singularValues[currChannel] = Mpy_32_32( ( *sig_x ), ( *g ) ); /* sig_x_e */ + move32(); + singularValues_e[currChannel] = *sig_x_e; move16(); -#endif } - // rescaling block - singularValues[currChannel] = Mpy_32_32( ( *sig_x ), ( *g ) ); /* sig_x_e */ - move32(); - singularValues_e[currChannel] = *sig_x_e; - move16(); -} - -return; + return; } /*------------------------------------------------------------------------- @@ -1343,16 +1006,8 @@ return; static void biDiagonalReductionRight_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_exp[]) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 *singularVectors_e, -#else Word16 singularVectors2_e[][MAX_OUTPUT_CHANNELS], -#endif -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 *secDiag_e, -#else Word16 *secDiag_exp, -#endif const Word16 nChannelsL, /* Q0 */ const Word16 nChannelsC, /* Q0 */ const Word16 currChannel, /* Q0 */ @@ -1364,22 +1019,8 @@ static void biDiagonalReductionRight_fx( Word16 iCh, jCh, idx; Word32 norm_x, r; Word16 norm_x_e, r_e; -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 secDiag_exp[MAX_OUTPUT_CHANNELS]; -#endif Word32 L_temp; Word16 L_temp_e; -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 sing_exp[MAX_OUTPUT_CHANNELS]; - Word16 sing_exp2[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 }; - FOR( jCh = 0; jCh < MAX_OUTPUT_CHANNELS; jCh++ ) - { - set16_fx( sing_exp2[jCh], *singularVectors_e, MAX_OUTPUT_CHANNELS ); - } -#endif -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - set16_fx( secDiag_exp, *secDiag_e, MAX_OUTPUT_CHANNELS ); -#endif /* Setting values to 0 */ ( *sig_x ) = 0; @@ -1393,11 +1034,7 @@ static void biDiagonalReductionRight_fx( FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[currChannel][jCh] ), *singularVectors_e, sig_x_e ); /* exp(sig_x_e) */ -#else ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[currChannel][jCh] ), singularVectors2_e[currChannel][jCh], sig_x_e ); /* exp(sig_x_e) */ -#endif } IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ @@ -1407,41 +1044,17 @@ static void biDiagonalReductionRight_fx( norm_x_e = 0; move16(); -#ifdef FIX_1010_OPT_DIV Word16 invVal_e, temp_e; Word32 invVal; - invVal = BASOP_Util_Divide3232_Scale_cadence( MAXVAL_WORD32, maxWithSign_fx( *sig_x ), &invVal_e ); -#endif + invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( *sig_x ), &invVal_e ); FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */ { -#ifndef FIX_1010_OPT_DIV -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors[currChannel][jCh] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[currChannel][jCh], maxWithSign_fx( *sig_x ), &sing_exp[jCh] ); /* exp(sing_exp + (singularVectors_e - sig_x_e)) */ - move32(); - sing_exp[jCh] = add( sing_exp[jCh], sub( *singularVectors_e, *sig_x_e ) ); - move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[currChannel][jCh], singularVectors[currChannel][jCh] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#else - singularVectors[currChannel][jCh] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[currChannel][jCh], maxWithSign_fx( *sig_x ), &L_temp_e ); /* exp(sing_exp + (singularVectors_e - sig_x_e)) */ - move32(); - singularVectors2_e[currChannel][jCh] = add( L_temp_e, sub( singularVectors2_e[currChannel][jCh], *sig_x_e ) ); - move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[currChannel][jCh], singularVectors[currChannel][jCh] ), shl( singularVectors2_e[currChannel][jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#endif -#else temp_e = norm_l( singularVectors[currChannel][jCh] ); singularVectors[currChannel][jCh] = Mpy_32_32( L_shl( singularVectors[currChannel][jCh], temp_e ), invVal ); /* exp(sing_exp + (singularVectors_e - sig_x_e) */ move32(); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - sing_exp[jCh] = add( sub( invVal_e, temp_e ), sub( *singularVectors_e, *sig_x_e ) ); - move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[currChannel][jCh], singularVectors[currChannel][jCh] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#else singularVectors2_e[currChannel][jCh] = add( sub( invVal_e, temp_e ), sub( singularVectors2_e[currChannel][jCh], *sig_x_e ) ); move16(); norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[currChannel][jCh], singularVectors[currChannel][jCh] ), shl( singularVectors2_e[currChannel][jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ -#endif -#endif } IF( GT_16( norm_x_e, 0 ) ) { @@ -1465,44 +1078,19 @@ static void biDiagonalReductionRight_fx( move32(); } -#ifndef FIX_1010_OPT_SINGLE_RESCALE - r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[idx], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */ - singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], sing_exp[idx], -( *g ), 0, &sing_exp[idx] ); /* exp(sing_exp) */ -#else r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), singularVectors2_e[currChannel][idx], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */ singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], singularVectors2_e[currChannel][idx], -( *g ), 0, &singularVectors2_e[currChannel][idx] ); /* exp(sing_exp) */ -#endif move32(); -#ifdef FIX_1010_OPT_DIV - invVal = BASOP_Util_Divide3232_Scale_cadence( MAXVAL_WORD32, maxWithSign_fx( r ), &invVal_e ); -#endif + invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( r ), &invVal_e ); FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_DIV -#ifndef FIX_1010_OPT_SINGLE_RESCALE - secDiag[jCh] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[currChannel][jCh], maxWithSign_fx( r ), &secDiag_exp[jCh] ); /* exp(secDiag_exp + (sing_exp - r_e) */ - move32(); - secDiag_exp[jCh] = add( secDiag_exp[jCh], sub( sing_exp[jCh], r_e ) ); - move32(); -#else - secDiag[jCh] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[currChannel][jCh], maxWithSign_fx( r ), &secDiag_exp[jCh] ); /* exp(secDiag_exp + (sing_exp - r_e) */ - move32(); - secDiag_exp[jCh] = add( secDiag_exp[jCh], sub( singularVectors2_e[currChannel][jCh], r_e ) ); - move32(); -#endif -#else temp_e = norm_l( singularVectors[currChannel][jCh] ); secDiag[jCh] = Mpy_32_32( L_shl( singularVectors[currChannel][jCh], temp_e ), invVal ); /* exp(sing_exp + (singularVectors_e - sig_x_e) */ move32(); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - secDiag_exp[jCh] = add( sub( invVal_e, temp_e ), sub( sing_exp[jCh], r_e ) ); -#else secDiag_exp[jCh] = add( sub( invVal_e, temp_e ), sub( singularVectors2_e[currChannel][jCh], r_e ) ); -#endif move16(); -#endif } FOR( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */ @@ -1513,20 +1101,12 @@ static void biDiagonalReductionRight_fx( move16(); FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( *singularVectors_e, sing_exp[jCh] ), &norm_x_e ); /* exp(norm_x_e) */ -#else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( singularVectors2_e[iCh][jCh], singularVectors2_e[currChannel][jCh] ), &norm_x_e ); /* exp(norm_x_e) */ -#endif } FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors[iCh][jCh] = BASOP_Util_Add_Mant32Exp( singularVectors[iCh][jCh], *singularVectors_e, Mpy_32_32( norm_x, secDiag[jCh] ), add( norm_x_e, secDiag_exp[jCh] ), &sing_exp2[iCh][jCh] ); /* exp(sing_exp2) */ -#else - singularVectors[iCh][jCh] = BASOP_Util_Add_Mant32Exp( singularVectors[iCh][jCh], singularVectors2_e[iCh][jCh], Mpy_32_32( norm_x, secDiag[jCh] ), add( norm_x_e, secDiag_exp[jCh] ), &singularVectors2_e[iCh][jCh] ); /* exp(sing_exp2) */ -#endif + singularVectors[iCh][jCh] = BASOP_Util_Add_Mant32Exp( singularVectors[iCh][jCh], singularVectors2_e[iCh][jCh], Mpy_32_32( norm_x, secDiag[jCh] ), add( norm_x_e, secDiag_exp[jCh] ), &singularVectors2_e[iCh][jCh] ); /* exp(sing_exp2) */ move32(); } } @@ -1535,54 +1115,9 @@ static void biDiagonalReductionRight_fx( { singularVectors[currChannel][jCh] = Mpy_32_32( singularVectors[currChannel][jCh], ( *sig_x ) ); /* exp(sing_exp + sig_x_e) */ move32(); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - sing_exp2[currChannel][jCh] = add( sing_exp[jCh], *sig_x_e ); -#else singularVectors2_e[currChannel][jCh] = add( singularVectors2_e[currChannel][jCh], *sig_x_e ); -#endif move16(); } - -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - /*rescaling block*/ - Word16 exp_max = *secDiag_e; - move16(); - FOR( jCh = 0; jCh < nChannelsC; jCh++ ) - { - exp_max = s_max( exp_max, secDiag_exp[jCh] ); - } - FOR( jCh = 0; jCh < nChannelsC; jCh++ ) - { - secDiag[jCh] = L_shr_r( secDiag[jCh], sub( exp_max, secDiag_exp[jCh] ) ); /* exp(exp_max) */ - move32(); - } - *secDiag_e = exp_max; - move16(); -#endif - - -#ifndef FIX_1010_OPT_SINGLE_RESCALE - exp_max = *singularVectors_e; - move16(); - FOR( iCh = 0; iCh < nChannelsL; iCh++ ) - { - FOR( jCh = 0; jCh < nChannelsC; jCh++ ) - { - exp_max = s_max( exp_max, sing_exp2[iCh][jCh] ); - } - } - - FOR( iCh = 0; iCh < nChannelsL; iCh++ ) - { - FOR( jCh = 0; jCh < nChannelsC; jCh++ ) - { - singularVectors[iCh][jCh] = L_shr_r( singularVectors[iCh][jCh], sub( exp_max, sing_exp2[iCh][jCh] ) ); /* exp(exp_max) */ - move32(); - } - } - *singularVectors_e = exp_max; - move16(); -#endif } } @@ -1598,11 +1133,7 @@ static void biDiagonalReductionRight_fx( static void singularVectorsAccumulationLeft_fx( Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* input exp(singularVectors_Left_e), output Q31 */ Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 singularVectors_e, -#else Word16 singularVectors_Left_e[][MAX_OUTPUT_CHANNELS], -#endif Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ const Word16 nChannelsC /* Q0 */ @@ -1612,13 +1143,6 @@ static void singularVectorsAccumulationLeft_fx( Word16 nChannels; Word32 norm_y, t_jj, t_ii; Word16 norm_y_e, t_jj_e, t_ii_e, temp_exp; -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 sing_exp2[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 }; - FOR( nCh = 0; nCh < MAX_OUTPUT_CHANNELS; nCh++ ) - { - set16_fx( sing_exp2[nCh], singularVectors_e, MAX_OUTPUT_CHANNELS ); - } -#endif /* Processing */ nChannels = s_min( nChannelsL, nChannelsC ); /* min(nChannelsL,ChannelsC) Q0*/ @@ -1638,15 +1162,10 @@ static void singularVectorsAccumulationLeft_fx( IF( t_ii ) /*if (fabsf(t_ii) > EPSILON *fabsf(t_ii)) {*/ { -#ifdef FIX_1010_OPT_DIV - t_ii = BASOP_Util_Divide3232_Scale_cadence( MAXVAL_WORD32, maxWithSign_fx( t_ii ), &temp_exp ); + t_ii = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( t_ii ), &temp_exp ); t_ii_e = sub( temp_exp, t_ii_e ); -#else - t_ii = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, maxWithSign_fx( t_ii ), &temp_exp ); /* exp(1 + (temp_exp + tii_e)) */ - t_ii_e = add( 1, sub( temp_exp, t_ii_e ) ); -#endif Word16 tempe; - Word32 temp = BASOP_Util_Divide3232_Scale_cadence( t_ii, maxWithSign_fx( singularVectors_Left[nCh][nCh] ), &tempe ); + Word32 temp = BASOP_Util_Divide3232_Scale_newton( t_ii, maxWithSign_fx( singularVectors_Left[nCh][nCh] ), &tempe ); tempe = add( tempe, sub( t_ii_e, singularVectors_Left_e[nCh][nCh] ) ); // fprintf( fp, "%e\n", me2f( t_ii, t_ii_e ) ); FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ @@ -1659,13 +1178,9 @@ static void singularVectorsAccumulationLeft_fx( move16(); FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ), add( sing_exp2[k][nCh], sing_exp2[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ -#else prod[k] = W_mult0_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ); prod_e[k] = add( singularVectors_Left_e[k][nCh], singularVectors_Left_e[k][iCh] ); max_e = s_max( max_e, prod_e[k] ); -#endif } FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */ @@ -1678,18 +1193,10 @@ static void singularVectorsAccumulationLeft_fx( norm_y = W_extract_h( acc ); norm_y_e = add( sub( max_e, acc_e ), 1 ); t_jj = Mpy_32_32( temp, norm_y ); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - t_jj_e = add( temp_exp, sub( add( t_ii_e, norm_y_e ), sing_exp2[nCh][nCh] ) ); -#else t_jj_e = add( tempe, norm_y_e ); -#endif FOR( k = nCh; k < nChannelsL; k++ ) /* nChannelsL */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors_Left[k][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[k][iCh], sing_exp2[k][iCh], Mpy_32_32( t_jj, singularVectors_Left[k][nCh] ), add( t_jj_e, sing_exp2[k][nCh] ), &sing_exp2[k][iCh] ); /* exp(sing_exp2) */ -#else singularVectors_Left[k][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[k][iCh], singularVectors_Left_e[k][iCh], Mpy_32_32( t_jj, singularVectors_Left[k][nCh] ), add( t_jj_e, singularVectors_Left_e[k][nCh] ), &singularVectors_Left_e[k][iCh] ); /* exp(sing_exp2) */ -#endif move32(); } } @@ -1698,11 +1205,7 @@ static void singularVectorsAccumulationLeft_fx( { singularVectors_Left[iCh][nCh] = Mpy_32_32( singularVectors_Left[iCh][nCh], t_ii ); /* exp(sing_exp2 + t_ii_e) */ move32(); -#ifndef FIX_1010_OPT_SINGLE_RESCALE - sing_exp2[iCh][nCh] = add( sing_exp2[iCh][nCh], t_ii_e ); -#else singularVectors_Left_e[iCh][nCh] = add( singularVectors_Left_e[iCh][nCh], t_ii_e ); -#endif move16(); } } @@ -1714,11 +1217,7 @@ static void singularVectorsAccumulationLeft_fx( move32(); } } -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors_Left[nCh][nCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[nCh][nCh], sing_exp2[nCh][nCh], ONE_IN_Q30, 1, &sing_exp2[nCh][nCh] ); /* exp(sing_exp2) */ -#else singularVectors_Left[nCh][nCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[nCh][nCh], singularVectors_Left_e[nCh][nCh], ONE_IN_Q30, 1, &singularVectors_Left_e[nCh][nCh] ); /* exp(sing_exp2) */ -#endif move32(); } // fclose(fp); @@ -1726,11 +1225,7 @@ static void singularVectorsAccumulationLeft_fx( { FOR( iCh = 0; iCh < nChannelsC; iCh++ ) { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - singularVectors_Left[nCh][iCh] = L_shl_sat( singularVectors_Left[nCh][iCh], sing_exp2[nCh][iCh] ); /* Q31 */ -#else - singularVectors_Left[nCh][iCh] = L_shl_sat( singularVectors_Left[nCh][iCh], singularVectors_Left_e[nCh][iCh] ); /* Q31 */ -#endif + singularVectors_Left[nCh][iCh] = L_shl_sat( singularVectors_Left[nCh][iCh], singularVectors_Left_e[nCh][iCh] ); /* Q31 */ move32(); } } @@ -1748,16 +1243,8 @@ static void singularVectorsAccumulationRight_fx( Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_Left_e) */ Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* input exp(singularVectors_Left_e), output Q31 */ Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_e) */ -#ifndef FIX_1010_OPT_SINGLE_RESCALE - Word16 singularVectors_e, -#else Word16 singularVectors_Left_e[][MAX_OUTPUT_CHANNELS], -#endif -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - Word16 secDiag_e, -#else Word16 *secDiag_e, -#endif const Word16 nChannelsC /* Q0 */ ) { @@ -1783,22 +1270,11 @@ static void singularVectorsAccumulationRight_fx( FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC*/ { -#ifdef FIX_1010_OPT_DIV ratio_float = L_deposit_h( BASOP_Util_Divide3232_Scale( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 ) ); /* exp(temp_exp1) */ singularVectors_Right[iCh][nCh] = L_deposit_h( BASOP_Util_Divide3232_Scale( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] ) ); /* exp(sing_right_exp + (temp_exp1 - secDiag_e) */ -#else - ratio_float = BASOP_Util_Divide3232_Scale_cadence( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 ); /* exp(temp_exp1) */ - singularVectors_Right[iCh][nCh] = BASOP_Util_Divide3232_Scale_cadence( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] ); /* exp(sing_right_exp + (temp_exp1 - secDiag_e) */ -#endif -#ifdef FIX_1010_OPT_SINGLE_RESCALE temp_exp1 = add( temp_exp1, sub( singularVectors_Left_e[nCh][iCh], singularVectors_Left_e[nCh][nCh + 1] ) ); -#endif move32(); -#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE - sing_right_exp[iCh][nCh] = add( sing_right_exp[iCh][nCh], sub( temp_exp1, secDiag_e ) ); -#else sing_right_exp[iCh][nCh] = add( sing_right_exp[iCh][nCh], sub( temp_exp1, secDiag_e[nCh + 1] ) ); -#endif move16(); // singularVectors_Right[iCh][nCh] = L_shl_sat( singularVectors_Right[iCh][nCh], temp_exp2 ); } @@ -1812,11 +1288,7 @@ static void singularVectorsAccumulationRight_fx( FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ { -#ifndef FIX_1010_OPT_SINGLE_RESCALE - norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[nCh][k], singularVectors_Right[k][iCh] ), add( singularVectors_e, sing_right_exp[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ -#else norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[nCh][k], singularVectors_Right[k][iCh] ), add( singularVectors_Left_e[nCh][k], sing_right_exp[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ -#endif } FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ @@ -1853,7 +1325,6 @@ static void singularVectorsAccumulationRight_fx( *-------------------------------------------------------------------------*/ -#ifdef FIX_1010_OPT_GIVENS_INV static void GivensRotation2_fx( const Word32 x, /* exp(x_e) */ const Word16 x_e, @@ -1875,7 +1346,6 @@ static void GivensRotation2_fx( *resultInv = ISqrt32( r, outInv_e ); move32(); } -#endif static Word32 GivensRotation_fx( const Word32 x, /* exp(x_e) */ @@ -1884,62 +1354,10 @@ static Word32 GivensRotation_fx( const Word16 z_e, Word16 *out_e ) { -#ifdef FIX_1010_OPT_GIVENS Word32 r; -#else - Word32 x_abs, z_abs; - Word32 cotan, tan, r; - Word16 temp_exp; - Word32 L_temp; -#endif -#ifdef FIX_1010_OPT_GIVENS r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( z, z ), shl( z_e, 1 ), Mpy_32_32( x, x ), shl( x_e, 1 ), out_e ); r = Sqrt32( r, out_e ); -#else - x_abs = L_abs( x ); - z_abs = L_abs( z ); - test(); - IF( LE_32( x_abs, Mpy_32_32( CONVERGENCE_FACTOR_FX, x_abs ) ) && LE_32( z_abs, Mpy_32_32( CONVERGENCE_FACTOR_FX, z_abs ) ) ) - { - r = 0; - move32(); - } - ELSE IF( BASOP_Util_Cmp_Mant32Exp( x_abs, x_e, z_abs, z_e ) >= 0 ) - { - IF( LE_32( x_abs, SVD_MINIMUM_VALUE_FX ) ) - { - r = 0; - move32(); - } - ELSE - { - cotan = BASOP_Util_Divide3232_Scale_cadence( z_abs, x_abs, &temp_exp ); /* exp(temp_exp + (z_e - x_e) */ - temp_exp = add( temp_exp, sub( z_e, x_e ) ); - L_temp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, Mpy_32_32( cotan, cotan ), 2 * temp_exp, &temp_exp ); /* exp(temp_exp) */ - L_temp = Sqrt32( L_temp, &temp_exp ); - r = Mpy_32_32( x_abs, L_temp ); /* exp(x_e + temp_exp) */ - *out_e = add( x_e, temp_exp ); - } - } - ELSE - { - IF( LE_32( z_abs, SVD_MINIMUM_VALUE_FX ) ) - { - r = 0; - move32(); - } - ELSE - { - tan = BASOP_Util_Divide3232_Scale_cadence( x_abs, z_abs, &temp_exp ); /* exp(temp_exp + (x_e - z_e) */ - temp_exp = add( temp_exp, sub( x_e, z_e ) ); - L_temp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, Mpy_32_32( tan, tan ), shl( temp_exp, 1 ), &temp_exp ); /* exp(temp_exp) */ - L_temp = Sqrt32( L_temp, &temp_exp ); - r = Mpy_32_32( z_abs, L_temp ); /* exp(z_e + temp_exp) */ - *out_e = add( z_e, temp_exp ); - } - } -#endif return ( r ); } @@ -1953,20 +1371,6 @@ static Word32 maxWithSign_fx( const Word32 a /* Qx */ ) { -#ifndef FIX_MINOR_SVD_WMOPS_MR1010X - IF( GT_32( L_abs( a ), SVD_MINIMUM_VALUE_FX ) ) - { - return a; - } - ELSE IF( a < 0 ) - { - return -SVD_MINIMUM_VALUE_FX; - } - ELSE - { - return SVD_MINIMUM_VALUE_FX; - } -#else Word32 result; IF( a >= 0 ) { @@ -1977,7 +1381,6 @@ static Word32 maxWithSign_fx( result = L_min( a, -SVD_MINIMUM_VALUE_FX ); } return result; -#endif } /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index c187c351c462fe7ff3b8dcc5b1e91044a659c34d..aa5a379e87c316892f9f161dd48749c31e46ede7 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -644,21 +644,13 @@ void stereo_tcx_core_dec_fx( test(); test(); test(); -#ifdef NONBE_FIX_1402_WAVEADJUST IF( ( bfi || st->prev_bfi ) && st->hPlcInfo->Pitch_fx && EQ_16( st->hPlcInfo->concealment_method, TCX_NONTONAL ) ) -#else - IF( ( bfi || st->prev_bfi ) && st->hPlcInfo->Pitch && EQ_16( st->hPlcInfo->concealment_method, TCX_NONTONAL ) ) -#endif { lerp( synthFB_fx, synth_fx, st->L_frame, hTcxDec->L_frameTCX ); if ( !bfi && st->prev_bfi ) { -#ifdef NONBE_FIX_1402_WAVEADJUST st->hPlcInfo->Pitch_fx = 0; -#else - st->hPlcInfo->Pitch = 0; -#endif move16(); } } @@ -816,21 +808,11 @@ void stereo_tcx_core_dec_fx( move16(); /* Postfiltering */ -#ifndef MSAN_FIX - IF( st->p_bpf_noise_buf_32 ) - { - Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, negate( Q11 ) ); - } -#endif post_decoder( st, synth_buf_fx, pit_gain_fx, pitch, signal_out_fx, st->p_bpf_noise_buf ); test(); -#ifdef MSAN_FIX IF( st->p_bpf_noise_buf_32 && st->tcxonly == 0 ) -#else - IF( st->p_bpf_noise_buf_32 ) -#endif // MSAN_FIX { Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); /* q_p_bpf + Q11 */ } diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 98c1a6a79dd6fcd080752f1b40a09f483c7cf8da..3191a8b4abcdcd54fb80589a75dbfa64a9b3b950 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -137,7 +137,6 @@ void tdm_low_rate_dec_fx( edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); -#ifdef FIX_USAN_ISSUES IF( bwe_exc != NULL ) { Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx, @@ -148,10 +147,6 @@ void tdm_low_rate_dec_fx( Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); } -#else - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx, - L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); -#endif /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 002b4bc109985558a4bf8769317309d597cb8aca..d1f782b55c18b79990c3ea00b920f1cda41a6f13 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -911,7 +911,7 @@ static void JB4_adaptActivePlayout( ELSE { Word16 exp; - Word32 temp = BASOP_Util_Divide3232_Scale_cadence( W_extract_l( W_sub( dropRateMax, dropRateMin ) ), W_extract_l( dropGapMax ), &exp ); + Word32 temp = BASOP_Util_Divide3232_Scale_newton( W_extract_l( W_sub( dropRateMax, dropRateMin ) ), W_extract_l( dropGapMax ), &exp ); /* limit gap to [gapMin,gapMax] and calculate current drop rate from gap */ Word64 temp2 = W_mult0_32_32( W_extract_l( JB4_MIN( gap, dropGapMax ) ), temp ); Word64 temp3 = W_shr( temp2, sub( 31, exp ) ); diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index fc793dff01c72047684bc8a5db1fe53ab98f5644..e2528e619eb9ab631ad0ced53399220cba4a2702 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -270,9 +270,7 @@ UWord8 apa_reconfigure( free( ps->buf_out_fx ); ps->buf_out_fx = (Word16 *) malloc( sizeof( Word16 ) * ps->buf_out_capacity ); -#ifdef MSAN_FIX memset( ps->buf_out_fx, 0, ( sizeof( Word16 ) * ps->buf_out_capacity ) ); -#endif ps->Q_buf_out = Q15; move16(); IF( !ps->buf_out_fx ) diff --git a/lib_dec/lead_deindexing_fx.c b/lib_dec/lead_deindexing_fx.c index 786e0c276956fcb209bed3bc2c814b69c2b6f828..ecc5f6fe01a50d55b5156784ae951993658b3092 100644 --- a/lib_dec/lead_deindexing_fx.c +++ b/lib_dec/lead_deindexing_fx.c @@ -192,7 +192,6 @@ void re8_decode_base_index_fx( m1 = sub( k1, 1 ); m2 = 8; move16(); -#ifdef CR_2109_to_2112_cd0_ce0 l = 1; move16(); FOR( i = 0; i < 8; i++ ) @@ -206,9 +205,6 @@ void re8_decode_base_index_fx( test(); /* if the signs are constrained and all components are non-zero */ IF( EQ_16( k1, 7 ) && ( l > 0 ) ) -#else - IF( k1 == 7 ) -#endif { m2 = 7; move16(); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 6e906dd93cc6441f4fb83068eda3f42fe050c836..95d599d6dfc5bb5fd821abe181ad7ed106086eee 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -46,9 +46,6 @@ #include "jbm_pcmdsp_fifo.h" #include #include -#ifndef FIX_DISCLAIMER -#include -#endif #include "wmc_auto.h" #define INV_1000_Q31 2147484 /*1/1000 IN Q31*/ @@ -3531,85 +3528,6 @@ const char *IVAS_DEC_GetErrorMessage( return ivas_error_to_string( error ); } -#ifndef FIX_DISCLAIMER -/*---------------------------------------------------------------------* - * get_channel_config() - * - * Gets a str related to input config - *---------------------------------------------------------------------*/ - -static ivas_error get_channel_config( - AUDIO_CONFIG config, - Word8 *str ) -{ - IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_MONO ) ) - { - strcpy( (char *) str, "Mono" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_STEREO ) ) - { - strcpy( (char *) str, "Stereo" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - strcpy( (char *) str, "Multichannel 5.1 (CICP6)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - strcpy( (char *) str, "Multichannel 7.1 (CICP12)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - strcpy( (char *) str, "Multichannel 5.1+2 (CICP14)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - strcpy( (char *) str, "Multichannel 5.1+4 (CICP16)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_7_1_4 ) ) - { - strcpy( (char *) str, "Multichannel 7.1+4 (CICP19)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - strcpy( (char *) str, "Multichannel (custom loudspeaker layout)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_FOA ) ) - { - strcpy( (char *) str, "Ambisonics: First Order (FOA)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - strcpy( (char *) str, "Ambisonics: Second Order (HOA2)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - strcpy( (char *) str, "Ambisonics: Third Order (HOA3)" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL ) ) - { - strcpy( (char *) str, "Binaural: no room" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) - { - strcpy( (char *) str, "Binaural: room with impulse responses" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - strcpy( (char *) str, "Binaural: room with reverb" ); - } - ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - strcpy( (char *) str, "External renderer" ); - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" ); - } - - return IVAS_ERR_OK; -} -#endif /*---------------------------------------------------------------------* * printConfigInfo_dec( ) diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 712ead8f460687baf4d0335122614e075e08e681..fcd5142a4c11b824f0a9638e8ca0d1209ae58b37 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -161,13 +161,7 @@ typedef struct { Word16 L_frameTCX; -#ifndef NONBE_FIX_1402_WAVEADJUST - Word16 Pitch; -#endif Word16 Pitch_fx; -#ifndef NONBE_FIX_1402_WAVEADJUST - Word16 T_bfi; -#endif Word8 T_bfi_fx; Word16 Transient[MAX_POST_LEN]; @@ -187,9 +181,6 @@ typedef struct Word16 step_concealgain_fx; Word16 concealment_method; -#ifndef NONBE_FIX_1402_WAVEADJUST - Word16 subframe; -#endif Word16 subframe_fx; Word16 nbLostCmpt; Word16 seed; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 492c927b6e7fcf81fd3ce8eaedd017ab5b55660c..1b51a29fb642cfffd08c7a39517f1f2d7224b226 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -6070,12 +6070,6 @@ void ivas_swb_tbe_dec_fx( tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) ); /* convert LSPs to LP coefficients */ E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER ); -#ifndef FIX_1100_REMOVE_LPC_RESCALING - /* Bring the LPCs to Q12 */ - Copy_Scale_sig( lpc_shb_sf_fx + tmp, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_sf_fx[tmp] ), 2 ) ); - lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this - move16(); -#endif } } diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 650e8572bc7bbcaddb28a1a385df35933750cd1b..bc7e1d536257616343132f5dc3090351c994cc12 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -146,28 +146,20 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( hTonalMDCTConc->tcx_cfg = hTcxCfg; hTonalMDCTConc->lastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[0]; -#ifdef MSAN_FIX set16_fx( hTonalMDCTConc->lastBlockData.spectralData, 0, L_FRAME_MAX ); -#endif move16(); hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1]; -#ifdef MSAN_FIX set16_fx( hTonalMDCTConc->secondLastBlockData.spectralData, 0, L_FRAME_MAX ); -#endif move16(); hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; move16(); hTonalMDCTConc->secondLastPowerSpectrum_exp = hTonalMDCTConc->secondLastBlockData.spectralData_exp; move16(); hTonalMDCTConc->lastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[0]; -#ifdef MSAN_FIX set16_fx( hTonalMDCTConc->lastBlockData.scaleFactors, 0, FDNS_NPTS ); -#endif move16(); hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[1]; -#ifdef MSAN_FIX set16_fx( hTonalMDCTConc->secondLastBlockData.scaleFactors, 0, FDNS_NPTS ); -#endif move16(); hTonalMDCTConc->lastBlockData.scaleFactors_exp = hTonalMDCTConc->scaleFactorsBuffers_exp[0]; move16(); @@ -234,9 +226,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( move16(); /* just the second half of the second last pcm output is needed */ -#ifdef MSAN_FIX set16_fx( hTonalMDCTConc->timeDataBuffer, 0, ( 3 * L_FRAME_MAX ) / 2 ); -#endif hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) / 2 )]; hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ @@ -1226,9 +1216,7 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 element_mode ) { Word32 secondLastMDST[L_FRAME_MAX]; -#ifdef MSAN_FIX set32_fx( secondLastMDST, 0, L_FRAME_MAX ); -#endif Word32 secondLastMDCT[L_FRAME_MAX]; Word16 secondLastMDCT_exp; Word32 *powerSpectrum = secondLastMDST; @@ -1236,9 +1224,7 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 nSamples; // Word16 nBands; Word32 sns_int_scf_fx[FDNS_NPTS]; -#ifdef MSAN_FIX set32_fx( sns_int_scf_fx, 0, FDNS_NPTS ); -#endif nSamples = hTonalMDCTConc->nSamples; move16(); @@ -1302,11 +1288,7 @@ void TonalMDCTConceal_Detect_ivas_fx( { /* If the second last frame was also lost, it is expected that pastTimeSignal could hold a bit different signal (e.g. including fade-out) from the one stored in TonalMDCTConceal_SaveTimeSignal. */ /* That is why we reuse the already stored information about the concealed spectrum in the second last frame */ -#ifdef MSAN_FIX Word16 temp_power_spectrum_q = 0; -#else - Word16 power_spectrum_q; -#endif nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); Copy_Scale_sig_16_32_DEPREC( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples, Q15 ); @@ -1401,12 +1383,15 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word16 rnd; Word16 tmp, g, tilt, exp_last, exp_noise, tiltFactor, crossfadeGain, e_crossfadeGain; - Word32 L_tmp, L_tmp2, nrgNoiseInLastFrame, nrgWhiteNoise; + Word32 L_tmp, L_tmp1, L_tmp2, nrgNoiseInLastFrame, nrgWhiteNoise; Word16 inv_exp, inv_samples, exp; Word32 last_block_nrg_correct; Word16 last_block_nrg_correct_e; Word32 max_concealment_value; Word16 max_spectral_value; + Word64 sum1, sum2; + Word16 num16, den16, exp1, exp2; + Word16 shift1, shift2; crossfadeGain = crossfadeGain_const; move16(); @@ -1869,28 +1854,36 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( } } ELSE{ - IF( !tonalConcealmentActive ){ - ld = sub( 14, norm_s( hTonalMDCTConc->lastBlockData.nSamples ) ); - fac = shr( -32768, ld ); - + IF( tonalConcealmentActive == 0 ){ + sum1 = 0; + sum2 = 0; + move64(); + move64(); FOR( i = 0; i < crossOverFreq; i++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; - Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); /* Q0 */ - y = L_mult( tilt, rnd ); /* 15Q16 */ + Word16 x; + /*x = hTonalMDCTConc->lastBlockData.spectralData[i]; + nrgNoiseInLastFrame += x * x;*/ + sum1 = W_mac0_16_16( sum1, hTonalMDCTConc->lastBlockData.spectralData[i], hTonalMDCTConc->lastBlockData.spectralData[i] ); // Q: 2*(15-hTonalMDCTConc->lastBlockData.spectralData_exp) - nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - x_exp - ld) + Q(15 - x_exp) - 15 = Q(31 - x_exp * 2 - ld) - x = round_fx( y ); /* 15Q16 -> 15Q0 */ - nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - (15 - 0) - ld) + Q(0) - 15 = Q(1 - ld) + /* rnd = own_random(&rnd); */ + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); /* Q0 */ - mdctSpectrum[i] = y; /* 15Q16 */ + /* mdctSpectrum[i] = tilt * rnd; */ + mdctSpectrum[i] = L_mult( tilt, rnd ); // Q16 move32(); + /* tilt *= tiltFactor; */ tilt = mult_r( tilt, tiltFactor ); /* Q15 */ + + /* nrgWhiteNoise += mdctSpectrum[i] * mdctSpectrum[i]; */ + x = round_fx( mdctSpectrum[i] ); // Q0 + sum2 = W_mac0_16_16( sum2, x, x ); // Q0 } + *mdctSpectrum_exp = 15; + move16(); - IF( nrgNoiseInLastFrame == 0 ) + IF( sum1 /* nrgNoiseInLastFrame */ == 0 ) { set32_fx( mdctSpectrum, 0, crossOverFreq ); *mdctSpectrum_exp = SPEC_EXP_DEC; @@ -1898,85 +1891,70 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( } ELSE { - exp_last = add( ld, shl( hTonalMDCTConc->lastBlockData.spectralData_exp, 1 ) ); - exp_noise = add( ld, 30 ); - - IF( nrgWhiteNoise > 0 ) + IF( g == 0 ) { - ld = norm_l( nrgNoiseInLastFrame ); - nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); // Q31- exp_last + ld - exp_last = sub( exp_last, ld ); - ld = norm_l( nrgWhiteNoise ); - nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); // Q31 - exp_noise + ld - exp_noise = sub( exp_noise, ld ); - - exp = sub( exp_last, exp_noise ); - - IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) - { - nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); // Q31-exp -1 - exp = add( exp, 1 ); - } - tmp = div_l( nrgNoiseInLastFrame, round_fx( nrgWhiteNoise ) ); // Q15 - tmp = Sqrt16( tmp, &exp ); - g = mult_r( g, tmp ); // exponent of g = exp - - L_tmp = L_deposit_h( 0 ); - ld = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, 15 ); - exp = sub( ld, exp ); - - IF( exp > 0 ) - { - g = shr( g, exp ); // Q15 - exp - *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; - move16(); - } - ELSE - { - crossfadeGain = shl( crossfadeGain, exp ); // Q15-e_crossfadeGain+ exp - e_crossfadeGain = sub( e_crossfadeGain, exp ); - *mdctSpectrum_exp = add( e_crossfadeGain, hTonalMDCTConc->lastBlockData.spectralData_exp ); - move16(); - } - /*make a headroom for mdct_shaping*/ - exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); - /* assert(exp < 0);*/ - IF( exp < 0 ) - { - *mdctSpectrum_exp = SPEC_EXP_DEC; - move16(); - } - ELSE + *mdctSpectrum_exp = add( add( hTonalMDCTConc->lastBlockData.spectralData_exp, e_crossfadeGain ), 31 - SPEC_EXP_DEC ); + move16(); + FOR( i = 0; i < crossOverFreq; i++ ) { - exp = 0; - move16(); + /* mdctSpectrum[i] = g * mdctSpectrum[i] + crossfadeGain * hTonalMDCTConc->lastBlockData.spectralData[i]; */ + L_tmp = L_mult( crossfadeGain, hTonalMDCTConc->lastBlockData.spectralData[i] ); // exp: hTonalMDCTConc->lastBlockData.spectralData_exp+e_crossfadeGain + if ( mdctSpectrum[i] <= 0 ) + { + /* mdctSpectrum[i] = g * mdctSpectrum[i] - crossfadeGain * hTonalMDCTConc->lastBlockData.spectralData[i]; */ + L_tmp = L_negate( L_tmp ); // exp: hTonalMDCTConc->lastBlockData.spectralData_exp+e_crossfadeGain + } + /* headroom for mdct_shaping */ + mdctSpectrum[i] = L_shr( L_tmp, 31 - SPEC_EXP_DEC ); // *mdctSpectrum_exp + move32(); } } - FOR( i = 0; i < crossOverFreq; i++ ) + ELSE { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[i]; // Q15 - spectralData_exp - move16(); - Word32 const y = mdctSpectrum[i]; // Q31-mdctSpectrum_exp - move32(); - - IF( g > 0 ) + IF( sum2 /* nrgWhiteNoise */ > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp + exp1 = sub( W_norm( sum1 ), 1 ); + num16 = extract_h( W_extract_h( W_shl( sum1, exp1 ) ) ); // nrgNoiseInLastFrame -> Q: 2*(15-hTonalMDCTConc->lastBlockData.spectralData_exp)+exp1-48 + exp2 = W_norm( sum2 ); + den16 = extract_h( W_extract_h( W_shl( sum2, exp2 ) ) ); // nrgWhiteNoise -> Q: exp2-48 + + /* sqrt( nrgNoiseInLastFrame / nrgWhiteNoise ) */ + tmp = div_s( num16, den16 ); // Q: 15+(2*(15-hTonalMDCTConc->lastBlockData.spectralData_exp)+exp1-48)-(exp2-48) + exp = sub( sub( shl( hTonalMDCTConc->lastBlockData.spectralData_exp, 1 ), 30 ), sub( exp1, exp2 ) ); // exp of tmp + tmp = Sqrt16( tmp, &exp ); + g = mult_r( g, tmp ); // exponent of g = exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp - IF( GT_32( y, 0 ) ) + exp1 = add( *mdctSpectrum_exp, exp ); + exp2 = add( hTonalMDCTConc->lastBlockData.spectralData_exp, e_crossfadeGain ); + exp = add( s_max( exp1, exp2 ), 1 ); + shift1 = sub( exp1, exp ); + shift2 = sub( exp2, exp ); + + FOR( i = 0; i < crossOverFreq; i++ ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + L_tmp1 = L_shl( Mpy_32_16_1( mdctSpectrum[i], g ), shift1 ); // g * mdctSpectrum[i] + L_tmp2 = L_shl( L_mult( crossfadeGain, hTonalMDCTConc->lastBlockData.spectralData[i] ), shift2 ); // exp + + /* mdctSpectrum[i] = g * mdctSpectrum[i] - crossfadeGain * hTonalMDCTConc->lastBlockData.spectralData[i]; */ + L_tmp = L_sub( L_tmp1, L_tmp2 ); // exp + if ( mdctSpectrum[i] > 0 ) + { + /* mdctSpectrum[i] = g * mdctSpectrum[i] + crossfadeGain * hTonalMDCTConc->lastBlockData.spectralData[i]; */ + L_tmp = L_add( L_tmp1, L_tmp2 ); // exp + } + mdctSpectrum[i] = L_shr( L_tmp, 31 - SPEC_EXP_DEC ); // exp+31-SPEC_EXP_DEC + move32(); } - mdctSpectrum[i] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp - move32(); + /* headroom for mdct_shaping */ + *mdctSpectrum_exp = add( exp, 31 - SPEC_EXP_DEC ); + move16(); } } - exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, sub( *mdctSpectrum_exp, 16 ) ); + exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, *mdctSpectrum_exp ); FOR( i = crossOverFreq; i < hTonalMDCTConc->lastBlockData.nSamples; i++ ) { - mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), exp ); // Q15 - spectralData_exp + exp + mdctSpectrum[i] = L_shl( L_deposit_h( hTonalMDCTConc->lastBlockData.spectralData[i] ), exp ); // mdctSpectrum_exp move32(); } } @@ -3511,9 +3489,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( psychParams = st->hTonalMDCTConc->psychParams; hFdCngCom = st->hFdCngDec->hFdCngCom; -#ifdef MSAN_FIX set32_fx( whitenend_noise_shape, 0, L_FRAME16k ); -#endif IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) { diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index b82378198604518d2b6ea4a15a4417d0a306a15e..b9ad17fcfedb094ff24ca64463b55580d1315305 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -56,9 +56,7 @@ void transition_dec_fx( Word16 i, offset, temp, tmp; Word16 limit_flag; Word16 i_subfridx; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( Opt_AMR_WB ); -#endif i_subfridx = i_subfr / L_SUBFR; /*i_subfr / L_SUBFR*/ /* Set limit_flag to 0 for restrained limits, and 1 for extended limits */ @@ -830,9 +828,7 @@ Word16 tc_classif_fx( /*o: Q0*/ ) { Word16 tc_subfr, indice; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( L_frame ); -#endif IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { IF( get_next_indice_fx( st_fx, 1 ) ) diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index f993caa8d1650555dc32b1c8ff9c2dc53f5e3df0..75a514cc21c2fb99f546ae3ff75358544c97b3bc 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -848,16 +848,8 @@ void concealment_init_ivas_fx( hPlcInfo->L_frameTCX = L_frameTCX; move16(); -#ifndef NONBE_FIX_1402_WAVEADJUST - hPlcInfo->Pitch = 0; - move16(); -#endif hPlcInfo->Pitch_fx = 0; move16(); -#ifndef NONBE_FIX_1402_WAVEADJUST - hPlcInfo->T_bfi = 0; - move16(); -#endif hPlcInfo->T_bfi_fx = 0; move16(); hPlcInfo->outx_new_n1_fx = 0; @@ -876,10 +868,6 @@ void concealment_init_ivas_fx( move16(); hPlcInfo->concealment_method = TCX_NONTONAL; move16(); -#ifndef NONBE_FIX_1402_WAVEADJUST - hPlcInfo->subframe = 0; - move16(); -#endif hPlcInfo->subframe_fx = 0; move16(); hPlcInfo->nbLostCmpt = (Word16) L_deposit_l( 0 ); @@ -1326,11 +1314,7 @@ static Word16 waveform_adj_fix( test(); test(); test(); -#ifdef NONBE_FIX_1402_WAVEADJUST IF( hPlcInfo->T_bfi_fx && ( LE_16( pitch, Framesizediv2 ) ) && ( GT_16( Framesize, 256 ) ) && ( EQ_16( core, 1 ) ) ) -#else - IF( hPlcInfo->T_bfi && ( LE_16( pitch, Framesizediv2 ) ) && ( GT_16( Framesize, 256 ) ) && ( EQ_16( core, 1 ) ) ) -#endif { Word16 i1 = 0, i2 = 0; Word16 pos1, pos2, pos3; diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index c52fddf97ee55b28084b7e44ba010a1edf76d3d4..43bd30fd4a5a3d9514160fc45397991ee27fbfb9 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -343,13 +343,13 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx( /* Push number of encoded tuples */ value = sub( shr( lastnz, 1 ), 1 ); /* Q0 */ - push_next_indice_fx( hBstr, value, nbbits_ntuples ); + push_next_indice( hBstr, value, nbbits_ntuples ); /* Push arithmetic coded bits */ - push_next_bits_fx( hBstr, &ptr[nbbits_ntuples], sub( bp, nbbits_ntuples ) ); + push_next_bits( hBstr, (UWord16 *) &ptr[nbbits_ntuples], sub( bp, nbbits_ntuples ) ); /* Push sign bits */ - push_next_bits_fx( hBstr, signs, nbbits_signs ); + push_next_bits( hBstr, (UWord16 *) signs, nbbits_signs ); bp = add( bp, nbbits_signs ); /* Q0 */ /*write residual Quantization bits*/ @@ -372,7 +372,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx( assert( bp + k <= nbbits ); /* Push the rest of the buffer */ - push_next_bits_fx( hBstr, &ptr[bp], sub( nbbits, bp ) ); + push_next_bits( hBstr, (UWord16 *) &ptr[bp], sub( nbbits, bp ) ); return /*(bp+nbbits_lsbs)*/; /*return only for debug plot*/ } diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 87243e8d2fa5268c37ab5a6cb7513969450575d9..69b14eb9b65dcbc5422bd658464249a3967b882b 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -94,7 +94,7 @@ void FEC_encode_fx( index = 3; move16(); } - push_indice_fx( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS ); + push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS ); } /*-----------------------------------------------------------------* @@ -117,7 +117,7 @@ void FEC_encode_fx( tmpS = s_min( tmpS, 31 ); tmpS = s_max( tmpS, 0 ); - push_indice_fx( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR ); + push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR ); } /*-----------------------------------------------------------------* * Encode last glottal pulse position (8 bits) @@ -157,7 +157,7 @@ void FEC_encode_fx( maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ } - push_indice_fx( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS ); + push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS ); } maxi = 0; move16(); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index d2d5ac4e6583ab86396685bb38c2ae67610dc01e..795f03403e1355a49da0ffba61995e412aa6ad98 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -395,11 +395,7 @@ ivas_error acelp_core_enc_fx( IF( !nelp_mode && !ppp_mode ) { config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#ifdef NONBE_FIX_GSC_BSTR st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, -#else - st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, -#endif tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } @@ -465,11 +461,7 @@ ivas_error acelp_core_enc_fx( tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx ); config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -#ifdef NONBE_FIX_GSC_BSTR -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, -#else - -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, -#endif tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } @@ -480,7 +472,7 @@ ivas_error acelp_core_enc_fx( IF( nb_bits > 0 ) { Es_pred_enc_fx( &Es_pred_fx, &indice, st_fx->L_frame, res_fx, st_fx->voicing_fx, nb_bits, 0, Q_new ); - push_indice_fx( st_fx->hBstr, IND_ES_PRED, indice, nb_bits ); + push_indice( st_fx->hBstr, IND_ES_PRED, indice, nb_bits ); } @@ -522,11 +514,7 @@ ivas_error acelp_core_enc_fx( /* Configure ACELP bit allocation */ config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -#ifdef NONBE_FIX_GSC_BSTR -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, -#else - -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, -#endif st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ @@ -631,7 +619,7 @@ ivas_error acelp_core_enc_fx( WHILE( nBits > 0 ) { i = s_min( nBits, 16 ); // Q0 - push_indice_fx( st_fx->hBstr, IND_UNUSED, 0, i ); + push_indice( st_fx->hBstr, IND_UNUSED, 0, i ); nBits = sub( nBits, i ); // Q0 } } @@ -772,21 +760,17 @@ ivas_error acelp_core_enc_ivas_fx( Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2]; Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx; -#ifdef MSAN_FIX set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); set16_fx( old_exc_fx, 0, L_EXC ); set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) ); set16_fx( syn_fx, 0, L_FRAME16k ); -#endif Word16 tilt_code_bck_fx; Word32 gc_threshold_bck_fx; Word16 clip_var_bck_fx[6]; Word32 q_env_fx[NUM_ENV_CNG]; -#ifdef MSAN_FIX set32_fx( q_env_fx, 0, NUM_ENV_CNG ); set16_fx( exc2_fx, 0, L_FRAME16k ); -#endif Word16 exc3_fx[L_FRAME16k]; Word16 syn1_fx[L_FRAME16k]; Word16 *tdm_Pri_pitch_buf_fx; @@ -1189,11 +1173,7 @@ ivas_error acelp_core_enc_ivas_fx( test(); IF( !nelp_mode && !ppp_mode ) { -#ifdef NONBE_FIX_GSC_BSTR config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &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( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &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 } /*-----------------------------------------------------------------* @@ -1330,11 +1310,7 @@ ivas_error acelp_core_enc_ivas_fx( { tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx ); -#ifdef NONBE_FIX_GSC_BSTR config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, 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( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 1, NULL, 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 } /*---------------------------------------------------------------* @@ -1393,11 +1369,7 @@ ivas_error acelp_core_enc_ivas_fx( lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen ); /* Configure ACELP bit allocation */ -#ifdef NONBE_FIX_GSC_BSTR config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); -#else - config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); -#endif /* redo LSF quantization */ lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new ); @@ -1458,12 +1430,8 @@ ivas_error acelp_core_enc_ivas_fx( test(); IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) { - Copy( syn1_fx + shr( st->L_frame, 1 ), st->hTcxEnc->Txnq, shr( st->L_frame, 1 ) ); // st->Q_syn -#ifdef MSAN_FIX + Copy( syn1_fx + shr( st->L_frame, 1 ), st->hTcxEnc->Txnq, shr( st->L_frame, 1 ) ); // st->Q_syn Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 1 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) ); // st->Q_syn -#else - Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 2 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) ); -#endif st->hTcxEnc->q_Txnq = st->Q_syn; move16(); } @@ -1488,11 +1456,7 @@ ivas_error acelp_core_enc_ivas_fx( *-----------------------------------------------------------------*/ Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new ) -#ifdef MSAN_FIX Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new ) -#else - Scale_sig( res_fx, L_FRAME16k, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); -#endif FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) ); IF( st->hBWE_TD != NULL ) { @@ -1557,11 +1521,7 @@ ivas_error acelp_core_enc_ivas_fx( IF( !st->Opt_SC_VBR && ( 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 ) ) ) { /* Apply a non linearity to the SHB excitation */ -#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( Q_new, 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( Q_new, 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, Q_new, 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( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc } diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index d88e1523ed825acceb35a351a58e66b63f4906ce..8226748f745c1e5aa4ad7ce41b2a5e027a55b106 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -62,7 +62,10 @@ void acelp_core_switch_enc_fx( Word16 Aq[2 * ( M + 1 )]; LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - +#ifdef HARM_PUSH_BIT + UWord16 value; + Word16 nb_bits; +#endif hLPDmem = st_fx->hLPDmem; /* initializations */ @@ -149,14 +152,22 @@ void acelp_core_switch_enc_fx( *----------------------------------------------------------------*/ config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, -#ifdef NONBE_FIX_GSC_BSTR GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); -#else - GENERIC, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); -#endif encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); +#ifdef HARM_PUSH_BIT + i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); +#ifdef DEBUGGING + assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); +#endif + while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START ) + { + push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits ); + i++; + } + delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); +#else /*----------------------------------------------------------------* * bit-stream: modify the layer of sub frame CELP *----------------------------------------------------------------*/ @@ -169,6 +180,7 @@ void acelp_core_switch_enc_fx( hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */ move16(); } +#endif /*----------------------------------------------------------------* * BWE encoding *----------------------------------------------------------------*/ @@ -264,11 +276,7 @@ void acelp_core_switch_enc_ivas_fx( *----------------------------------------------------------------*/ config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, -#ifdef NONBE_FIX_GSC_BSTR GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); -#else - GENERIC, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); -#endif encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); @@ -449,7 +457,7 @@ static void encod_gen_voic_core_switch_fx( IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { - push_indice_fx( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); + push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } /*-----------------------------------------------------------------* @@ -497,7 +505,7 @@ static void encod_gen_voic_core_switch_fx( /* write reserved bits */ IF( unbits ) { - push_indice_fx( hBstr, IND_UNUSED, 0, unbits ); + push_indice( hBstr, IND_UNUSED, 0, unbits ); } /*-----------------------------------------------------------------* @@ -846,7 +854,7 @@ static void bwe_switch_enc_fx( } } - push_indice_fx( hBstr, IND_CORE_SWITCHING_AUDIO_DELAY, d1m_fx, AUDIODELAYBITS ); + push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_DELAY, d1m_fx, AUDIODELAYBITS ); tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx ); /* Q0 */ ptmp = &hb_synth_tmp_fx[tmp]; /* Q0 */ @@ -875,7 +883,7 @@ static void bwe_switch_enc_fx( L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); /* Q0 */ - push_indice_fx( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); + push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); return; } diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index b1b2257e2b8f422ccc17444d939f4350c0bb305d..1580a78186f071f46a99e4bdb4e5154f1d1f9fa3 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -372,7 +372,7 @@ void amr_wb_enc_fx( * WB, SWB and FB bandwidth detector *----------------------------------------------------------------*/ - bw_detect_fx( st, st->input_fx, NULL, NULL, NULL, MONO_FORMAT, 0 ); + bw_detect_fx( st, st->input_fx, NULL, NULL, NULL, MONO_FORMAT, 0, 0 ); /* in AMR_WB IO, limit the maximum band-width to WB */ if ( GT_16( st->bwidth, WB ) ) @@ -548,7 +548,7 @@ void amr_wb_enc_fx( * Write VAD information into the bitstream in AMR-WB IO mode *--------------------------------------------------------------------------------------*/ - push_indice_fx( st->hBstr, IND_VAD_FLAG, st->vad_flag, 1 ); + push_indice( st->hBstr, IND_VAD_FLAG, st->vad_flag, 1 ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 185bac26bc7847ecd023228e95a204404ee2b044..4f96ea2d4872231719e0fdf89912fbdbfec04b0c 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -399,6 +399,10 @@ static void find_enr_dft_ivas_fx( BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 2]; // // *q_Bin_E move32(); + Word16 norm = getScaleFactor32( BinE_fx, L_FFT ); + scale_sig32( BinE_fx, L_FFT, norm ); + *q_Bin_E = add( *q_Bin_E, norm ); + move16(); L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, q_Bin_E ); MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E @@ -490,9 +494,9 @@ void ivas_analy_sp_fx( } ELSE { - Word16 scale = 0; + Word16 scale = 0, shift; move16(); - + shift = s_min( norm_arr( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT ), norm_arr( speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT ) ); FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ ) { /* set pointer to the beginning of the signal for spectral analysis */ @@ -503,27 +507,26 @@ void ivas_analy_sp_fx( /* set the pointer for second analysis window */ pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2; } - /* Clear 1st value of 1st part, copy 1st value of 2nd part */ pt_fft[0] = 0; move16(); - pt_fft[L_FFT / 2] = pt[L_FFT / 2]; // Q_new - preemph_bits + pt_fft[L_FFT / 2] = shl( pt[L_FFT / 2], shift ); // (Q_new + shift) - preemph_bits move16(); FOR( i = 1; i < L_FFT / 2; i++ ) { /* 1st windowed part */ - pt_fft[i] = mult_r( pt[i], sqrt_han_window_fx[i] ); // Q_new - preemph_bits + pt_fft[i] = mult_r( shl( pt[i], shift ), sqrt_han_window_fx[i] ); // (Q_new + shift) - preemph_bits move16(); /* 2nd windowed part */ - pt_fft[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] ); // Q_new - preemph_bits + pt_fft[L_FFT - i] = mult_r( shl( pt[L_FFT - i], shift ), sqrt_han_window_fx[i] ); // (Q_new + shift) - preemph_bits move16(); } /* compute the spectrum */ fft_rel_16_32fx( pt_fft, &scale, i_subfr, L_FFT, LOG2_L_FFT ); - *q_fft_buff = add( Q_new, scale ); // resultant q for fft_buff + *q_fft_buff = add( add( Q_new, shift ), scale ); // resultant q for fft_buff move16(); IF( EQ_16( i_subfr, 1 ) ) { diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 76d48ccf4318fd1aa0931b8b8358876751c1d6e1..343f1890fd01b79e821a02184d77e8383bc8d3fd 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -42,12 +42,12 @@ Word16 EncodeIndex_fx( NumRatioBitsBwLtpIndx = NumRatioBits[Bandwidth][LtpPitchIndex]; move16(); - push_next_indice_fx( hBst, s_and( PeriodicityIndex, 0xff ), NumRatioBitsBwLtpIndx ); + push_next_indice( hBst, s_and( PeriodicityIndex, 0xff ), NumRatioBitsBwLtpIndx ); return NumRatioBitsBwLtpIndx; } ELSE { - push_next_indice_fx( hBst, PeriodicityIndex, 8 ); + push_next_indice( hBst, PeriodicityIndex, 8 ); return 8; } } diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 962b715cd7a1068638db2451a6547556ac1c0eb8..b3a49c59ef44f47907cd76b13c71eb34b8156521 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -384,20 +384,20 @@ void AVQ_encmux_fx( /* write the unary code */ FOR( ; j > 16; j -= 16 ) { - push_indice_fx( hBstr, nq_ind, 65535, 16 ); + push_indice( hBstr, nq_ind, 65535, 16 ); bits = sub( bits, 16 ); } IF( j > 0 ) { - push_indice_fx( hBstr, nq_ind, extract_l( L_sub( L_shl( 1L, j ), 1L ) ), j ); + push_indice( hBstr, nq_ind, extract_l( L_sub( L_shl( 1L, j ), 1L ) ), j ); bits = sub( bits, j ); } } IF( !overflow ) { /* write the stop bit */ - push_indice_fx( hBstr, nq_ind, 0, 1 ); + push_indice( hBstr, nq_ind, 0, 1 ); bits = sub( bits, 1 ); } @@ -506,13 +506,13 @@ void AVQ_encmux_fx( IF( j > 0 ) { /* write the unary code */ - push_indice_fx( hBstr, nq_ind, sub( shl( 1, j ), 1 ), j ); + push_indice( hBstr, nq_ind, sub( shl( 1, j ), 1 ), j ); } IF( nq[i] != 0 ) { /* write the stop bit */ - push_indice_fx( hBstr, nq_ind, 0, 1 ); + push_indice( hBstr, nq_ind, 0, 1 ); } /*Compute AVQ code book number from unused Bits */ @@ -1099,32 +1099,32 @@ static void wrte_cv( ELSE IF( LT_16( nq, 5 ) ) /* Q2, Q3, Q4 */ { nq4 = shl( nq, 2 ); - push_indice_fx( hBstr, i_ind, I, nq4 ); + push_indice( hBstr, i_ind, I, nq4 ); bits = sub( bits, nq4 ); } ELSE IF( EQ_16( s_and( nq, 1 ), 0 ) ) /* Q4 + Voronoi extensions r=1,2,3,... */ { - push_indice_fx( hBstr, i_ind, I, 4 * 4 ); + push_indice( hBstr, i_ind, I, 4 * 4 ); bits = sub( bits, 4 * 4 ); /*pos = (int16_t)(nq / 2 - 2);*/ /* Voronoi order determination */ pos = sub( shr( nq, 1 ), 2 ); FOR( j = 0; j < 8; j++ ) { - push_indice_fx( hBstr, kv_ind, kv[j], pos ); + push_indice( hBstr, kv_ind, kv[j], pos ); } bits = sub( bits, shl( pos, 3 ) ); } ELSE /* Q3 + Voronoi extensions r=1,2,3,... */ { - push_indice_fx( hBstr, i_ind, I, 4 * 3 ); + push_indice( hBstr, i_ind, I, 4 * 3 ); bits = sub( bits, 4 * 3 ); /*pos = (int16_t)(nq / 2 - 1);*/ /* Voronoi order determination */ pos = sub( shr( nq, 1 ), 1 ); FOR( j = 0; j < 8; j++ ) { - push_indice_fx( hBstr, kv_ind, kv[j], pos ); + push_indice( hBstr, kv_ind, kv[j], pos ); } bits = sub( bits, shl( pos, 3 ) ); diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index a1d672fe0059f3a6971fa0fb7f6bb6800745d88a..a241101ba1f9b869a6b22df58d3b7aea1461e7c5 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -269,11 +269,7 @@ Word16 bass_pf_enc_fx( st = sub( s2, s2_old ); FOR( i = 0; i < tmp16; i++ ) { -#ifdef FIX_ISSUE_1187 noise_buf[i] = shl_sat( mem_bpf->noise_buf[i], st ); -#else - noise_buf[i] = shl( mem_bpf->noise_buf[i], st ); -#endif move16(); } Copy( noise_buf + l_subfr, mem_bpf->noise_buf, tmp16 ); diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 2e9b2c5db1fa63e6e80f58b43617227bab6bd2cb..8a150d514caea3fc700b04b8921fc25dd0ddef92 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -41,12 +41,12 @@ void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ const Word16 signal_in[], /* i : input signal */ - Word16 *spectrum, /* i : MDCT spectrum */ + Word16 *spectrum, /* i : MDCT spectrum Q_spec */ const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 mct_on /* i : flag MCT mode */ -) + const Word16 mct_on, /* i : flag MCT mode */ + const Word16 Q_spec ) { Word16 Q_dct; Word16 i, j, k, bw_max, bin_width, n_bins; @@ -312,6 +312,11 @@ void bw_detect_fx( bin_width = i_mult( bin_width, l_frame / BWD_TOTAL_WIDTH ); Copy( spectrum, spect, l_frame ); + if ( st->element_mode != EVS_MONO ) + { + Q_dct = Q_spec; + move16(); + } } /*---------------------------------------------------------------------* * compute energy per spectral bins @@ -903,6 +908,7 @@ void bw_detect_fx( return; } + /*-------------------------------------------------------------------* * set_bw_fx() * diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index b65d414033bfd12e84d19875aa07fbf21b3bfd08..b031ca5286e5688abb3280298481d225d47d5300 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -975,7 +975,7 @@ void CNG_enc_fx( hTdCngEnc->old_enr_index = enr_index; move16(); - push_indice_fx( hBstr, IND_ENERGY, enr_index, num_bits ); + push_indice( hBstr, IND_ENERGY, enr_index, num_bits ); if ( enr_index == 0 ) { enr_index = -5; @@ -1063,7 +1063,7 @@ void CNG_enc_fx( move16(); } } - push_indice_fx( hBstr, IND_CNG_ENV1, min1_idx, 6 ); + push_indice( hBstr, IND_CNG_ENV1, min1_idx, 6 ); /* get quantized res_env_details */ FOR( i = 0; i < NUM_ENV_CNG; i++ ) { @@ -1122,28 +1122,28 @@ void CNG_enc_fx( /* dithering bit for AMR-WB IO mode is always set to 0 */ IF( EQ_32( st_fx->core_brate, SID_1k75 ) ) { - push_indice_fx( hBstr, IND_DITHERING, 0, 1 ); + push_indice( hBstr, IND_DITHERING, 0, 1 ); } IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - push_indice_fx( hBstr, IND_ACELP_16KHZ, 1, 1 ); + push_indice( hBstr, IND_ACELP_16KHZ, 1, 1 ); } ELSE { - push_indice_fx( hBstr, IND_ACELP_16KHZ, 0, 1 ); + push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 ); } - push_indice_fx( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, 7 ), 3 ); + push_indice( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, 7 ), 3 ); hTdCngEnc->num_ho = m; move16(); - push_indice_fx( hBstr, IND_SID_TYPE, 0, 1 ); + push_indice( hBstr, IND_SID_TYPE, 0, 1 ); test(); IF( LT_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { - push_indice_fx( hBstr, IND_SID_BW, 0, 1 ); + push_indice( hBstr, IND_SID_BW, 0, 1 ); *sid_bw = 0; move16(); } @@ -1305,19 +1305,19 @@ void CNG_enc_ivas_fx( move16(); BREAK; case L_FRAME32k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME32k_Q31; move16(); BREAK; case L_FRAME16k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME16k_Q31; move16(); BREAK; case L_FRAME8k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME8k_Q31; move16(); BREAK; case L_FRAME4k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME4k_Q31; move16(); BREAK; default: @@ -1876,7 +1876,7 @@ void CNG_enc_ivas_fx( { E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); exp = sub( Q14, norm_s( Aq[0] ) ); - Scale_sig( Aq, M, sub( Q12, exp ) ); // Q12 + Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12 } tmp_loop = shr( st_fx->L_frame, 6 ); @@ -1986,19 +1986,19 @@ void CNG_enc_ivas_fx( move16(); BREAK; case L_FRAME32k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME32k_Q31; move16(); BREAK; case L_FRAME16k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME16k_Q31; move16(); BREAK; case L_FRAME8k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME8k_Q31; move16(); BREAK; case L_FRAME4k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; + inv_frame_len = ONE_BY_L_FRAME4k_Q31; move16(); BREAK; default: @@ -2011,14 +2011,12 @@ void CNG_enc_ivas_fx( /* convert log2 of residual signal energy */ /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ -#ifdef FIX_ISSUE_1245 IF( L_ener == 0 ) { enr = -850; /*log(0.1) base 2 in Q8*/ move16(); } ELSE -#endif { hi = norm_l( L_ener ); lo = Log2_norm_lc( L_shl( L_ener, hi ) ); @@ -2460,10 +2458,14 @@ static void shb_CNG_encod_fx( idx_ener_fx = s_max( idx_ener_fx, 0 ); } - push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); - push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); + push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); + push_indice( hBstr, IND_SID_BW, 1, 1 ); +#ifdef HARM_PUSH_BIT + delete_indice( hBstr, IND_CNG_ENV1 ); +#else hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; +#endif move16(); move16(); @@ -2472,7 +2474,7 @@ static void shb_CNG_encod_fx( } else { - push_indice_fx( hBstr, IND_UNUSED, 0, 2 ); + push_indice( hBstr, IND_UNUSED, 0, 2 ); } hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); hTdCngEnc->ho_sid_bw = L_or( hTdCngEnc->ho_sid_bw, 0x1L ); @@ -2484,7 +2486,7 @@ static void shb_CNG_encod_fx( IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - push_indice_fx( hBstr, IND_SID_BW, 0, 1 ); + push_indice( hBstr, IND_SID_BW, 0, 1 ); } } diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index a948a4656c7154b56e7af98b6e3fae967d5e5ec2..dc967e656015c19b31d029321709cc01eef3608d 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -292,7 +292,7 @@ void acelp_2t32_fx( } { /* write index to array of indices */ - push_indice_fx( hBstr, IND_ALG_CDBK_2T32, index, 12 ); + push_indice( hBstr, IND_ALG_CDBK_2T32, index, 12 ); } return; } @@ -636,11 +636,11 @@ void acelp_1t64_fx( } IF( EQ_16( L_subfr, L_SUBFR ) ) { - push_indice_fx( hBstr, IND_ALG_CDBK_1T64, index, 7 ); + push_indice( hBstr, IND_ALG_CDBK_1T64, index, 7 ); } ELSE /* L_subfr == 2*L_SUBFR */ { - push_indice_fx( hBstr, IND_ALG_CDBK_1T64, index, 8 ); + push_indice( hBstr, IND_ALG_CDBK_1T64, index, 8 ); } return; diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index 0e4c02744823c9718cfae159a01f6aaf362ff25a..e24f3b678add290844dd03df2a523248c5a3d169 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -123,10 +123,11 @@ void acelp_fast_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 cdk_index, /* i : codebook index */ const Word16 dn_orig[L_SUBFR], - /* i : corr. between target and h[]. */ // Q_new + 1 + /* i : corr. between target and h[]. */ // Q_dn Word16 Q_dn, const Word16 cn[L_SUBFR], - /* i : residual after long term prediction */ // Q_new + 1 + /* i : residual after long term prediction */ // q_cn + const Word16 q_cn, const Word16 H[L_SUBFR], /* i : impulse response of weighted synthesis filter */ // e(norm_s(H[0])+1) Word16 code[L_SUBFR], @@ -161,7 +162,9 @@ void acelp_fast_fx( Word64 s64; Word16 flag = 0; move16(); - + Word32 temp1, temp2, temp3, temp4, temp5, temp6; + Word16 q_temp1, q_temp2; + Word16 scale_temp1, scale_temp2; /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -294,16 +297,23 @@ void acelp_fast_fx( exp = sub( Q31, shl( Q_dn, 1 ) ); + s64 = 0; + move64(); + FOR( i = 0; i < L_subfr; i++ ) + { + s64 = W_mac_16_16( s64, dn_orig[i], dn_orig[i] ); // 2 * Q_dn + 1 + } dndn_fx = 21474836 /*0.01f in Q31 */; move32(); dndn_e = 0; move16(); - FOR( i = 0; i < L_subfr; i++ ) + IF( s64 ) { - dndn_fx = BASOP_Util_Add_Mant32Exp( dndn_fx, dndn_e, L_mult0( dn_orig[i], dn_orig[i] ), exp, &dndn_e ); // Q(dndn_e) + Word16 new_exp1 = W_norm( s64 ); + dndn_fx = W_extract_h( W_shl( s64, new_exp1 ) ); // 2 * Q_dyn + exp1 - 31 + dndn_e = sub( 31, sub( add( add( shl( Q_dn, 1 ), 1 ), new_exp1 ), 32 ) ); } - exp1 = sub( Q31, shl( sub( Q_dn, 1 ), 1 ) ); cncn_fx = 214748365 /* 0.1f in Q31 */; move32(); @@ -312,31 +322,42 @@ void acelp_fast_fx( FOR( q = 0; q < nb_tracks; q++ ) { + s64 = 0; + move64(); + FOR( i = 0; i < L_subfr; i += nb_tracks ) + { + s64 = W_mac_16_16( s64, cn[i + q], cn[i + q] ); // 2 * q_cn + 1 + } + cncn_track[q] = 214748365 /* 0.1f in Q31 */; move32(); cncn_track_e[q] = 0; move16(); - - FOR( i = 0; i < L_subfr; i += nb_tracks ) + IF( s64 ) { - Word32 L_tmp = L_mult0( cn[i + q], cn[i + q] ); - shift = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, shift ); - cncn_track[q] = BASOP_Util_Add_Mant32Exp( cncn_track[q], cncn_track_e[q], L_tmp, sub( exp1, shift ), &cncn_track_e[q] ); // Q(cncn_track_e[q]) - move32(); + Word16 new_exp1 = W_norm( s64 ); + cncn_track[q] = W_extract_h( W_shl( s64, new_exp1 ) ); // 2 * Q_dyn + exp1 - 31 + cncn_track_e[q] = sub( 31, sub( add( add( shl( q_cn, 1 ), 1 ), new_exp1 ), 32 ) ); } cncn_fx = BASOP_Util_Add_Mant32Exp( cncn_fx, cncn_e, cncn_track[q], cncn_track_e[q], &cncn_e ); // Q(cncn_e) } - Word16 tmp; + Word16 tmp = 0; + move16(); s_coef_fx = BASOP_Util_Divide3232_Scale( dndn_fx, cncn_fx, &tmp ); tmp = add( tmp, sub( dndn_e, cncn_e ) ); s_coef_fx = Sqrt16( s_coef_fx, &tmp ); // Q(15 - tmp) - + q_temp1 = add( add( sub( Q15, tmp ), q_cn ), Q1 ); + scale_temp1 = sub( q_temp1, Q_dn ); FOR( i = 0; i < L_subfr; i++ ) { - bn_orig_fx[i] = L_mac0( L_shr( L_mult( s_coef_fx, cn[i] ), sub( 15, tmp ) ), beta1_fx, dn_orig[i] ); // Q_dn + temp1 = L_mult( s_coef_fx, cn[i] ); // Q(15 - tmp)+q_cn+1 + temp2 = L_mult( beta1_fx, dn_orig[i] ); // 1+Q_dn+1 + /* bn_orig_fx[i] is being used in Q_dn */ + temp2 = L_shr( temp2, 1 ); + temp1 = L_shr( temp1, scale_temp1 ); + bn_orig_fx[i] = L_add( temp1, temp2 ); // Q_dn move32(); IF( bn_orig_fx[i] >= 0 ) @@ -576,12 +597,12 @@ void acelp_fast_fx( } ELSE { - Gn = i_mult( s[0], shr( dn_orig[m[0]], 1 ) ); // Q_dn - 1 - Gd = alp[0]; // Q6 + Gn = i_mult( s[0], dn_orig[m[0]] ); // Q_dn + Gd = alp[0]; // Q6 move16(); - G = Gn; // Q_dn - 1 + G = Gn; // Q_dn move16(); - G = i_mult( G, s[0] ); // Q_dn - 1 + G = i_mult( G, s[0] ); // Q_dn track = track_order[q * nb_tracks + 1]; // Q0 move16(); @@ -596,14 +617,17 @@ void acelp_fast_fx( move64(); FOR( i = track; i < L_subfr; i += nb_tracks ) { - dn[i] = L_shr( L_msu( L_mult0( Gd, dn_orig[i] ), G, *alp_pos0 ), 6 ); // Q_dn + temp1 = L_mult0( Gd, dn_orig[i] ); + temp2 = L_mult0( G, *alp_pos0 ); + temp3 = L_sub( temp1, temp2 ); + dn[i] = L_shr( temp3, 6 ); move32(); alp_pos0 += nb_tracks; s64 = W_mac_32_32( s64, dn[i], dn[i] ); // 2 * Q_dn + 1 } exp1 = W_norm( s64 ); dndn_fx = W_extract_h( W_shl( s64, exp1 ) ); // 2 * Q_dyn + exp1 - 31 - dndn_e = sub( 31, sub( add( shl( Q_dn, 1 ), exp ), 31 ) ); + dndn_e = sub( 31, sub( add( add( shl( Q_dn, 1 ), 1 ), exp1 ), 32 ) ); IF( dndn_fx == 0 ) { @@ -612,17 +636,28 @@ void acelp_fast_fx( dndn_e = 0; move16(); } + exp1 = 0; + move16(); s_coef_fx = BASOP_Util_Divide3232_Scale( dndn_fx, cncn_track[track], &exp1 ); exp1 = add( exp1, sub( dndn_e, cncn_track_e[track] ) ); s_coef_fx = Sqrt16( s_coef_fx, &exp1 ); - exp1 = sub( exp1, shift ); max_val_fx = EPSILLON_FX; move16(); m[1] = track; // Q0 move16(); + q_temp1 = add( add( sub( Q15, exp1 ), q_cn ), 1 ); + q_temp2 = add( Q_dn, Q2 ); + scale_temp1 = sub( q_temp1, Q_dn ); + scale_temp2 = sub( q_temp2, Q_dn ); FOR( i = track; i < L_subfr; i += nb_tracks ) { - dn[i] = L_add( L_shr( L_mult( s_coef_fx, cn[i] ), sub( 15, exp1 ) ), L_shr( imult3216( dn[i], beta2_fx ), 2 ) ); // Q_dn + temp1 = L_mult( s_coef_fx, cn[i] ); // Q(15 - tmp)+q_cn+1 + temp2 = imult3216( dn[i], beta2_fx ); // Q_dn + 2 + + /* bn_orig_fx[i] is being used in Q_dn */ + temp2 = L_shr( temp2, scale_temp2 ); + temp1 = L_shr( temp1, scale_temp1 ); + dn[i] = L_add( temp1, temp2 ); // Q_dn move32(); temp_fx = imult3216( dn[i], sign_fx[i] ); // Q_dn @@ -645,14 +680,14 @@ void acelp_fast_fx( IF( GE_16( nb_pulse, 3 ) ) { - Gn = add( Gn, i_mult( s[1], shr( dn_orig[m[1]], 1 ) ) ); // Q_dn -1 + Gn = add( Gn, i_mult( s[1], dn_orig[m[1]] ) ); // Q_dn Gd32 = Gd; move16(); Gd32 = L_add( Gd32, L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[1] ), alp[m[0] - m[1]] ) ) ); // Q6 - G = Gn; // Q_dn - 1 + G = Gn; // Q_dn move16(); - G1 = i_mult( G, s[1] ); // Q_dn-1 - G = i_mult( G, s[0] ); // Q_dn-1 + G1 = i_mult( G, s[1] ); // Q_dn + G = i_mult( G, s[0] ); // Q_dn track = track_order[q * nb_tracks + 2]; // Q0 move16(); @@ -661,7 +696,12 @@ void acelp_fast_fx( FOR( i = track; i < L_subfr; i += nb_tracks ) { - dn[i] = L_shr( L_msu( L_msu0( imult3216( Gd32, dn_orig[i] ), G, *alp_pos0 ), G1, *alp_pos1 ), 6 ); // Q_dn + temp1 = imult3216( Gd32, dn_orig[i] ); + temp2 = L_mult0( G, *alp_pos0 ); + temp3 = L_mult0( G1, *alp_pos1 ); + temp4 = L_sub( temp1, temp2 ); + temp4 = L_sub( temp4, temp3 ); + dn[i] = L_shr( temp4, 6 ); move32(); alp_pos0 += nb_tracks; alp_pos1 += nb_tracks; @@ -677,15 +717,19 @@ void acelp_fast_fx( IF( GE_16( nb_pulse, 4 ) ) { - Gn = add( Gn, i_mult( s[2], shr( dn_orig[m[2]], 1 ) ) ); // Q_dn-1 + Gn = add( Gn, i_mult( s[2], dn_orig[m[2]] ) ); // Q_dn Gd32 = Gd; move16(); - Gd32 = L_add( Gd32, L_add( L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[2] ), alp[m[0] - m[2]] ) ), L_mult0( i_mult( shl( s[1], 1 ), s[2] ), alp[m[1] - m[2]] ) ) ); // Q6 - G = Gn; // Q_dn-1 + temp1 = alp[0]; + move32(); + temp2 = L_mult0( i_mult( shl( s[0], 1 ), s[2] ), alp[m[0] - m[2]] ); + temp3 = L_mult0( i_mult( shl( s[1], 1 ), s[2] ), alp[m[1] - m[2]] ); + Gd32 = L_add( Gd32, L_add( L_add( temp1, temp2 ), temp3 ) ); // Q6 + G = Gn; // Q_dn move16(); - G1 = i_mult( G, s[1] ); // Q_dn-1 - G2 = i_mult( G, s[2] ); // Q_dn-1 - G = i_mult( G, s[0] ); // Q_dn-1 + G1 = i_mult( G, s[1] ); // Q_dn + G2 = i_mult( G, s[2] ); // Q_dn + G = i_mult( G, s[0] ); // Q_dn track = track_order[q * nb_tracks + 3]; move16(); @@ -695,7 +739,15 @@ void acelp_fast_fx( FOR( i = track; i < L_subfr; i += nb_tracks ) { - dn[i] = L_shr( L_msu( L_msu( L_msu( imult3216( Gd32, dn_orig[i] ), G, *alp_pos0 ), G1, *alp_pos1 ), G2, *alp_pos2 ), 6 ); // Q_dn + + temp1 = imult3216( Gd32, dn_orig[i] ); + temp2 = L_mult0( G, *alp_pos0 ); + temp3 = L_mult0( G1, *alp_pos1 ); + temp4 = L_mult0( G2, *alp_pos2 ); + temp5 = L_sub( temp1, temp2 ); + temp5 = L_sub( temp5, temp3 ); + temp5 = L_sub( temp5, temp4 ); + dn[i] = L_shr( temp5, 6 ); move32(); alp_pos0 += nb_tracks; alp_pos1 += nb_tracks; @@ -717,16 +769,22 @@ void acelp_fast_fx( IF( GE_16( nb_pulse, 5 ) ) { - Gn = add( Gn, i_mult( s[3], shr( dn_orig[m[3]], 1 ) ) ); // Q_dn-1 + Gn = add( Gn, i_mult( s[3], dn_orig[m[3]] ) ); // Q_dn Gd32 = Gd; move16(); - Gd32 = L_add( Gd32, L_add( L_add( L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[3] ), alp[m[0] - m[3]] ) ), L_mult0( i_mult( shl( s[1], 1 ), s[3] ), alp[m[1] - m[3]] ) ), L_mult0( i_mult( shl( s[2], 1 ), s[3] ), alp[m[2] - m[3]] ) ) ); // Q6 + temp1 = alp[0]; + move32(); + temp2 = L_mult0( i_mult( shl( s[0], 1 ), s[3] ), alp[m[0] - m[3]] ); + temp3 = L_mult0( i_mult( shl( s[1], 1 ), s[3] ), alp[m[1] - m[3]] ); + temp4 = L_mult0( i_mult( shl( s[2], 1 ), s[3] ), alp[m[2] - m[3]] ); + + Gd32 = L_add( Gd32, L_add( L_add( L_add( temp1, temp2 ), temp3 ), temp4 ) ); // Q6 G = Gn; - move16(); // Q_dn-1 - G1 = i_mult( G, s[1] ); // Q_dn-1 - G2 = i_mult( G, s[2] ); // Q_dn-1 - G3 = i_mult( G, s[3] ); // Q_dn-1 - G = i_mult( G, s[0] ); // Q_dn-1 + move16(); // Q_dn + G1 = i_mult( G, s[1] ); // Q_dn + G2 = i_mult( G, s[2] ); // Q_dn + G3 = i_mult( G, s[3] ); // Q_dn + G = i_mult( G, s[0] ); // Q_dn IF( EQ_16( cdk_index, 6 ) ) { @@ -740,7 +798,16 @@ void acelp_fast_fx( FOR( i = track; i < L_subfr; i += nb_tracks ) { - dn[i] = L_shr( L_msu( L_msu( L_msu( L_msu( imult3216( Gd32, dn_orig[i] ), G, *alp_pos0 ), G1, *alp_pos1 ), G2, *alp_pos2 ), G3, *alp_pos3 ), 6 ); // Q_dn + temp1 = imult3216( Gd32, dn_orig[i] ); + temp2 = L_mult0( G, *alp_pos0 ); + temp3 = L_mult0( G1, *alp_pos1 ); + temp4 = L_mult0( G2, *alp_pos2 ); + temp5 = L_mult0( G3, *alp_pos3 ); + temp6 = L_sub( temp1, temp2 ); + temp6 = L_sub( temp6, temp3 ); + temp6 = L_sub( temp6, temp4 ); + temp6 = L_sub( temp6, temp5 ); + dn[i] = L_shr( temp6, 6 ); move32(); alp_pos0 += nb_tracks; alp_pos1 += nb_tracks; @@ -760,7 +827,16 @@ void acelp_fast_fx( FOR( i = 0; i < L_subfr; i++ ) { - dn[i] = L_shr( L_msu( L_msu( L_msu( L_msu( imult3216( Gd32, dn_orig[i] ), G, *alp_pos0 ), G1, *alp_pos1 ), G2, *alp_pos2 ), G3, *alp_pos3 ), 6 ); /*Q_dn*/ + temp1 = imult3216( Gd32, dn_orig[i] ); + temp2 = L_mult0( G, *alp_pos0 ); + temp3 = L_mult0( G1, *alp_pos1 ); + temp4 = L_mult0( G2, *alp_pos2 ); + temp5 = L_mult0( G3, *alp_pos3 ); + temp6 = L_sub( temp1, temp2 ); + temp6 = L_sub( temp6, temp3 ); + temp6 = L_sub( temp6, temp4 ); + temp6 = L_sub( temp6, temp5 ); + dn[i] = L_shr( temp6, 6 ); move16(); alp_pos0++; alp_pos1++; diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 99b794b42325932654eef0f13ab6f90b733671d2..457a129b839cc96400674fb882c3fd05b6e07616 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -330,11 +330,11 @@ Word16 acelp_4t64_fx( bitcnt = s_and( nbbits, 15 ); FOR( i = 0; i < wordcnt; i++ ) { - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, indexing_indices[i], 16 ); + push_indice( hBstr, IND_ALG_CDBK_4T64, indexing_indices[i], 16 ); } IF( bitcnt ) { - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, indexing_indices[i], bitcnt ); + push_indice( hBstr, IND_ALG_CDBK_4T64, indexing_indices[i], bitcnt ); } } ELSE @@ -347,7 +347,7 @@ Word16 acelp_4t64_fx( { k = i_mult2( track, NPMAXPT ); index = quant_1p_N1_fx( ind[k], 4 ); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, index, 5 ); + push_indice( hBstr, IND_ALG_CDBK_4T64, index, 5 ); } } ELSE IF( EQ_16( nbbits, 36 ) ) @@ -357,7 +357,7 @@ Word16 acelp_4t64_fx( k = i_mult2( track, NPMAXPT ); /* k = track * NPMAXPT;*/ index = quant_2p_2N1_fx( ind[k], ind[k + 1], 4 ); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, index, 9 ); + push_indice( hBstr, IND_ALG_CDBK_4T64, index, 9 ); } } ELSE IF( EQ_16( nbbits, 44 ) ) /* AMR-WB pulse indexing */ @@ -366,14 +366,14 @@ Word16 acelp_4t64_fx( { k = i_mult2( track, NPMAXPT ); index = quant_3p_3N1_fx( ind[k], ind[k + 1], ind[k + 2], 4 ); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, index, 13 ); + push_indice( hBstr, IND_ALG_CDBK_4T64, index, 13 ); } FOR( track = 2; track < NB_TRACK_FCB_4T; track++ ) { k = i_mult2( track, NPMAXPT ); index = quant_2p_2N1_fx( ind[k], ind[k + 1], 4 ); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, index, 9 ); + push_indice( hBstr, IND_ALG_CDBK_4T64, index, 9 ); } } ELSE IF( EQ_16( nbbits, 52 ) ) /* AMR-WB pulse indexing */ @@ -382,7 +382,7 @@ Word16 acelp_4t64_fx( { k = i_mult2( track, NPMAXPT ); index = quant_3p_3N1_fx( ind[k], ind[k + 1], ind[k + 2], 4 ); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64, index, 13 ); + push_indice( hBstr, IND_ALG_CDBK_4T64, index, 13 ); } } ELSE IF( EQ_16( nbbits, 64 ) ) /* AMR-WB pulse indexing */ @@ -393,7 +393,7 @@ Word16 acelp_4t64_fx( L_index = quant_4p_4N_fx( &ind[k], 4 ); index = extract_l( L_shr( L_index, 14 ) & 3 ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_1, index, 2 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_1, index, 2 ); } FOR( track = 0; track < NB_TRACK_FCB_4T; track++ ) @@ -402,7 +402,7 @@ Word16 acelp_4t64_fx( L_index = quant_4p_4N_fx( &ind[k], 4 ); index = extract_l( L_index & 0x3FFF ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_2, index, 14 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_2, index, 14 ); } } ELSE IF( EQ_16( nbbits, 72 ) ) @@ -413,7 +413,7 @@ Word16 acelp_4t64_fx( L_index = quant_5p_5N_fx( &ind[k], 4 ); index = extract_l( L_shr( L_index, 10 ) & 0x03FF ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_1, index, 10 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_1, index, 10 ); } FOR( track = 2; track < NB_TRACK_FCB_4T; track++ ) @@ -422,7 +422,7 @@ Word16 acelp_4t64_fx( L_index = quant_4p_4N_fx( &ind[k], 4 ); index = extract_l( L_shr( L_index, 14 ) & 3 ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_1, index, 2 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_1, index, 2 ); } FOR( track = 0; track < ( NB_TRACK_FCB_4T - 2 ); track++ ) @@ -431,7 +431,7 @@ Word16 acelp_4t64_fx( L_index = quant_5p_5N_fx( &ind[k], 4 ); index = extract_l( L_index & 0x03FF ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_2, index, 10 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_2, index, 10 ); } FOR( track = 2; track < NB_TRACK_FCB_4T; track++ ) @@ -440,7 +440,7 @@ Word16 acelp_4t64_fx( L_index = quant_4p_4N_fx( &ind[k], 4 ); index = extract_l( L_index & 0x3FFF ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_2, index, 14 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_2, index, 14 ); } } ELSE IF( EQ_16( nbbits, 88 ) ) @@ -451,7 +451,7 @@ Word16 acelp_4t64_fx( L_index = quant_6p_6N_2_fx( &ind[k], 4 ); index = extract_l( L_shr( L_index, 11 ) & 0x07FF ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_1, index, 11 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_1, index, 11 ); } FOR( track = 0; track < NB_TRACK_FCB_4T; track++ ) @@ -460,7 +460,7 @@ Word16 acelp_4t64_fx( L_index = quant_6p_6N_2_fx( &ind[k], 4 ); index = extract_l( L_index & 0x07FF ); logic16(); - push_indice_fx( hBstr, IND_ALG_CDBK_4T64_2, index, 11 ); + push_indice( hBstr, IND_ALG_CDBK_4T64_2, index, 11 ); } } } diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index e701b8e466b946d9c4c6cbc739f4a77476e558ca..d3725dcba73c1b1a10380ea33ca42f9abc403a74 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -37,14 +37,8 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Word16 *bwe_exc /* o : excitation for SWB TBE Qx */ ) { -#ifndef SIMPLIFY_CODE_BE - Word16 i, j, i_subfr, j_subfr; - Word16 tmp, tmp2, Es_pred; - Word32 gain_code_vect[2]; -#else Word16 i, i_subfr, j_subfr; Word16 tmp, Es_pred; -#endif Word16 T0, T0_min, T0_min_frac, T0_max, T0_max_frac, T0_res; Word16 T0_frac; Word16 gain_pit, voice_fac; @@ -103,11 +97,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * /* Configure ACELP */ -#ifndef MSAN_FIX - hLPDmem->nbits = BITS_ALLOC_config_acelp( target_bits, st->coder_type, acelp_cfg, st->narrowBand, st->nb_subfr ); -#else BITS_ALLOC_config_acelp( target_bits, st->coder_type, acelp_cfg, st->narrowBand, st->nb_subfr ); -#endif /* Init Framing parameters */ move16(); @@ -324,12 +314,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); -#ifndef SIMPLIFY_CODE_BE - gain_code_vect[0] = gain_code; - move32(); - gain_code_vect[1] = gain_code; - move32(); -#endif /*----------------------------------------------------------* * - voice factor (for pitch enhancement) * *----------------------------------------------------------*/ @@ -361,32 +345,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * /*-------------------------------------------------------* * - Find the total excitation. * *-------------------------------------------------------*/ -#ifndef SIMPLIFY_CODE_BE - tmp2 = shr( L_SUBFR, 1 ); - FOR( j = 0; j < 2; j++ ) - { - FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ ) - { - /* code in Q9, gain_pit in Q14; exc Q_new */ - Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); - Ltmp = L_shl( Ltmp, Q_new_p5 ); - Ltmp = L_mac( Ltmp, gain_pit, exc[i + i_subfr] ); - BASOP_SATURATE_WARNING_OFF_EVS - exc2[i] = round_fx( L_shl( Ltmp, 1 ) ); - BASOP_SATURATE_WARNING_ON_EVS - - Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); - Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); - Ltmp = L_add( Ltmp, Ltmp2 ); - BASOP_SATURATE_WARNING_OFF_EVS - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - BASOP_SATURATE_WARNING_ON_EVS - exc[i + i_subfr] = round_fx( Ltmp ); - } - tmp2 = L_SUBFR; - move16(); - } -#else FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14; exc Q_new */ @@ -402,7 +360,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); move16(); } -#endif /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index e6fc25e367957fef69abbe7dc45e9035bd516f31..4bb44eae27961630ea3f98bab5030ebce5fce018 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -14,11 +14,9 @@ #include "stl.h" // #include "basop_mpy.h" #include "prot_fx_enc.h" -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS #include #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" -#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -1717,9 +1715,7 @@ void EstimateStereoTCXNoiseLevel_fx( Word16 *fac_ns_q; Word32 total_brate; -#ifdef MSAN_FIX set32_fx( combined_q_spectrum, 0, N_MAX ); -#endif FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -3747,7 +3743,7 @@ void QuantizeTCXSpectrum_fx( } /* Quantize original spectrum */ - sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e ); + sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, ( mult( hTcxEnc->tcx_target_bits_fac, shl( sqTargetBits, 1 ) ) ), L_spec, &sqGain_e ); tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); @@ -4365,9 +4361,6 @@ void coder_tcx_fx( Word16 winMDST[N_MAX + L_MDCT_OVLP_MAX]; Word16 *pWinMDST; Word16 left_overlap_mode, right_overlap_mode; -#ifndef MSAN_FIX - LPD_state_HANDLE hLPDmem = st->hLPDmem; -#endif TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; left_overlap = right_overlap = -1; @@ -4532,11 +4525,6 @@ void coder_tcx_fx( n, st, hm_cfg ); - -#ifndef MSAN_FIX - hLPDmem->nbits = add( hLPDmem->nbits, add( tnsBits, ltpBits ) ); - move16(); -#endif } @@ -4742,7 +4730,7 @@ void InternalTCXDecoder_fx( } ELSE { - mdct_shaping( spectrum_fx, L_frame, gainlpc_fx, gainlpc_e ); + mdct_noiseShaping_ivas_fx( spectrum_fx, spectrum_e, L_frame, gainlpc_fx, gainlpc_e ); } /*-----------------------------------------------------------* * Apply gain * diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c index 8eccddc0b822eb5eaba77b68f5eba4f6f1cc3411..8b1e8a1446925ded36467c3c76af609ce3066edf 100644 --- a/lib_enc/cod_uv_fx.c +++ b/lib_enc/cod_uv_fx.c @@ -135,7 +135,6 @@ void gauss_L2_ivas_fx( *gain = L_deposit_l( 0 ); move32(); /*Update correlations for gains coding */ -#ifdef FIX_ISSUE_1167 tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 16 ); /* Q16 */ tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 16 ); /* Q16 */ FOR( i = 0; i < L_SUBFR; i++ ) @@ -144,34 +143,17 @@ void gauss_L2_ivas_fx( tmp32 = L_mac0( tmp32, tmp16, tmp16 ); /* Q16 */ tmp32_2 = L_mac0( tmp32_2, tmp16, shr( y2[i], 1 ) ); /* Q16 */ } -#else - tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */ - tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */ - FOR( i = 0; i < L_SUBFR; i++ ) - { - tmp32 = L_mac0( tmp32, y11[i], y11[i] ); /* Q18 */ - tmp32_2 = L_mac0( tmp32_2, y11[i], y2[i] ); /* Q18 */ - } -#endif tmp16 = norm_l( tmp32 ); // To be checked g_corr->y1y1 = round_fx_sat( L_shl( tmp32, tmp16 ) ); -#ifdef FIX_ISSUE_1167 g_corr->y1y1_e = sub( 31 - 16, tmp16 ); -#else - g_corr->y1y1_e = sub( 31 - 18, tmp16 ); -#endif move16(); move16(); tmp16 = norm_l( tmp32_2 ); g_corr->y1y2 = round_fx_sat( L_shl( tmp32_2, tmp16 ) ); -#ifdef FIX_ISSUE_1167 g_corr->y1y2_e = sub( 31 - 16, tmp16 ); -#else - g_corr->y1y2_e = sub( 31 - 18, tmp16 ); -#endif move16(); move16(); } diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 4ed9b6bc43b2a551a978860e112e26a1df9a202d..05f838a3a9011ad9f854add5bc806c8f02fb962a 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -299,11 +299,9 @@ static void init_tcx_fx( Word16 i; Word16 fscaleFB; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) MCT_flag; (void) total_brate; (void) last_total_brate; -#endif // PMT("init_tcx_fx needs an entire review to adapt to IVAS") fscaleFB = div_l( L_shl( st->input_Fs, LD_FSCALE_DENOM + 1 ), 12800 ); @@ -1563,6 +1561,10 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh { set16_fx( hLPDmem->syn, 0, 1 + M ); set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); + hLPDmem->q_lpd_syn = Q15; + hLPDmem->q_mem_syn = Q15; + move16(); + move16(); } IF( st->hTcxEnc != NULL ) @@ -1593,6 +1595,8 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); set16_fx( hLPDmem->syn, 0, M ); hLPDmem->q_lpd_syn = Q15; + hLPDmem->q_mem_syn = Q15; + move16(); move16(); } IF( st->hTcxEnc != NULL ) diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 04857c334d7130aa8b298baaa0bdb78f8cd5e82e..18f48e904671c41127b9f6d0c7d3bf801dcd555e 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -80,10 +80,8 @@ void core_encode_openloop_fx( Word16 w_rf[M + 1], lsf_uq_rf[M + 1]; Word16 lsf_q_1st_rf[M + 1], lsf_q_d_rf[M + 1], lsf_q_rf[M + 1]; Word16 lsp_old_q_rf[M + 1], lsf_old_q_rf[M + 1]; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) vad_hover_flag; (void) vad_flag_dtx; -#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c index 1ba496b0e4f3eca516d5a3b7d53b44b9a84b1500..9e7380aaa8329662fb6ef5546e90a51b6a0f2c7b 100644 --- a/lib_enc/core_enc_reconf_fx.c +++ b/lib_enc/core_enc_reconf_fx.c @@ -24,9 +24,7 @@ void core_coder_reconfig_fx( { Word16 i, bwidth, index; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) last_total_brate; -#endif /*Configuration of ACELP*/ BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index 305c2a92fe5f74d7c02317667cb6aa3c234f1401..ce2681e75e3efa460b226285a570115043c4752a 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -171,8 +171,8 @@ void core_encode_update_cng_fx( tmp = sub( st->wspeech_enc[-1], shl( hLPDmem->mem_w0, shift ) ); E_UTIL_deemph2( negate( shift ), wsyn, st->preemph_fac, st->L_frame, &tmp ); - hLPDmem->mem_w0 = sub( st->wspeech_enc[st->L_frame - 1], tmp ); - hLPDmem->mem_w0 = shr( hLPDmem->mem_w0, shift ); + hLPDmem->mem_w0 = sub_sat( st->wspeech_enc[st->L_frame - 1], tmp ); + hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); move16(); move16(); /* Update LPC-related memories */ diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index dc306229884ed4b3834ea6e0b6da1fcc2ba324a1..5290509cd32d8a7909d6c9af75ee51fabda55fdd 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -997,10 +997,8 @@ void core_switching_pre_enc_ivas_fx( tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); -#ifdef FIX_ISSUE_1230 hBWE_FD->Q_new_input_hp = 0; move16(); -#endif IF( NE_16( st_fx->last_extl, WB_BWE ) ) { diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index 3624cf37463b4f56b24b40fb5660b567a406ced2..bc5feeb6be1d1e6855a7758070709130ae0d6f7b 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -386,7 +386,6 @@ void decision_matrix_enc_fx( move16(); } -#ifdef NONBE_FIX_GSC_BSTR /*-----------------------------------------------------------------* * set inactive coder_type flag in ACELP core *-----------------------------------------------------------------*/ @@ -400,7 +399,6 @@ void decision_matrix_enc_fx( move16(); } -#endif return; } @@ -451,14 +449,14 @@ Word16 signalling_mode1_tcx20_enc_fx( num_bits = add( num_bits, nBits ); IF( push != 0 ) { - push_indice_fx( hBstr, IND_ACELP_SIGNALLING, sub( idx, start_idx ), nBits ); + push_indice( hBstr, IND_ACELP_SIGNALLING, sub( idx, start_idx ), nBits ); } /* HQ/TCX core switching flag */ num_bits = add( num_bits, 1 ); IF( push != 0 ) { - push_indice_fx( hBstr, IND_MDCT_CORE, 1, 1 ); + push_indice( hBstr, IND_MDCT_CORE, 1, 1 ); } } ELSE @@ -469,7 +467,7 @@ Word16 signalling_mode1_tcx20_enc_fx( num_bits = add( num_bits, 1 ); IF( push != 0 ) { - push_indice_fx( hBstr, IND_CORE, 1, 1 ); + push_indice( hBstr, IND_CORE, 1, 1 ); } } @@ -477,7 +475,7 @@ Word16 signalling_mode1_tcx20_enc_fx( num_bits = add( num_bits, 1 ); IF( push != 0 ) { - push_indice_fx( hBstr, IND_MDCT_CORE, 1, 1 ); + push_indice( hBstr, IND_MDCT_CORE, 1, 1 ); } num_bits = add( num_bits, 2 ); @@ -486,19 +484,19 @@ Word16 signalling_mode1_tcx20_enc_fx( /* write band-width (needed for different I/O sampling rate support) */ IF( EQ_16( st->bwidth, NB ) ) { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 0, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 0, 2 ); } ELSE IF( EQ_16( st->bwidth, WB ) ) { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 1, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 1, 2 ); } ELSE IF( EQ_16( st->bwidth, SWB ) ) { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 2, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 2, 2 ); } ELSE /* st->bwidth == FB */ { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 3, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 3, 2 ); } } } @@ -529,28 +527,28 @@ void signalling_enc_fx( assert( !st_fx->tcxonly ); assert( st_fx->core == HQ_CORE ); - push_next_indice_fx( hBstr, 1, 1 ); /* TCX */ - push_next_indice_fx( hBstr, 1, 1 ); /* HQ_CORE */ + push_next_indice( hBstr, 1, 1 ); /* TCX */ + push_next_indice( hBstr, 1, 1 ); /* HQ_CORE */ /* write ACELP->HQ core switching flag */ test(); IF( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) { - push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 ); + push_indice( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 ); /* write ACELP L_frame info */ IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) { - push_indice_fx( hBstr, IND_LAST_L_FRAME, 0, 1 ); + push_indice( hBstr, IND_LAST_L_FRAME, 0, 1 ); } ELSE { - push_indice_fx( hBstr, IND_LAST_L_FRAME, 1, 1 ); + push_indice( hBstr, IND_LAST_L_FRAME, 1, 1 ); } } ELSE { - push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 0, 1 ); + push_indice( hBstr, IND_HQ_SWITCHING_FLG, 0, 1 ); } return; @@ -576,7 +574,7 @@ void signalling_enc_fx( IF( EQ_16( ppp_mode, 1 ) || EQ_16( nelp_mode, 1 ) ) { /* 1 bit to distinguish between 2.8kbps PPP/NELP frame and SID frame */ - push_indice_fx( hBstr, IND_CORE, 0, 1 ); + push_indice( hBstr, IND_CORE, 0, 1 ); /* SC-VBR: 0 - PPP_NB, 1 - PPP_WB, 2 - NELP_NB, 3 - NELP_WB */ test(); test(); @@ -588,19 +586,19 @@ void signalling_enc_fx( test(); IF( EQ_16( st_fx->coder_type, VOICED ) && EQ_16( st_fx->bwidth, NB ) && EQ_16( ppp_mode, 1 ) ) { - push_indice_fx( hBstr, IND_PPP_NELP_MODE, 0, 2 ); + push_indice( hBstr, IND_PPP_NELP_MODE, 0, 2 ); } ELSE IF( EQ_16( st_fx->coder_type, VOICED ) && NE_16( st_fx->bwidth, NB ) && EQ_16( ppp_mode, 1 ) ) { - push_indice_fx( hBstr, IND_PPP_NELP_MODE, 1, 2 ); + push_indice( hBstr, IND_PPP_NELP_MODE, 1, 2 ); } ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) && EQ_16( st_fx->bwidth, NB ) && EQ_16( nelp_mode, 1 ) ) { - push_indice_fx( hBstr, IND_PPP_NELP_MODE, 2, 2 ); + push_indice( hBstr, IND_PPP_NELP_MODE, 2, 2 ); } ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) && NE_16( st_fx->bwidth, NB ) && EQ_16( nelp_mode, 1 ) ) { - push_indice_fx( hBstr, IND_PPP_NELP_MODE, 3, 2 ); + push_indice( hBstr, IND_PPP_NELP_MODE, 3, 2 ); } } ELSE IF( NE_32( st_fx->core_brate, SID_2k40 ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) @@ -608,7 +606,7 @@ void signalling_enc_fx( /* write the ACELP/HQ core selection bit */ IF( GE_32( st_fx->total_brate, ACELP_24k40 ) ) { - push_indice_fx( hBstr, IND_CORE, 0, 1 ); + push_indice( hBstr, IND_CORE, 0, 1 ); } /* find the section in the ACELP signalling table corresponding to bitrate */ @@ -654,7 +652,7 @@ void signalling_enc_fx( idx++; } - push_indice_fx( hBstr, IND_ACELP_SIGNALLING, idx - start_idx, nBits ); + push_indice( hBstr, IND_ACELP_SIGNALLING, idx - start_idx, nBits ); } /* write extension layer flag to distinguish between TBE (0) and BWE (1) */ @@ -666,11 +664,11 @@ void signalling_enc_fx( test(); IF( EQ_16( st_fx->extl, WB_TBE ) || EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) { - push_indice_fx( hBstr, IND_BWE_FLAG, 0, 1 ); + push_indice( hBstr, IND_BWE_FLAG, 0, 1 ); } ELSE IF( EQ_16( st_fx->extl, WB_BWE ) || EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) { - push_indice_fx( hBstr, IND_BWE_FLAG, 1, 1 ); + push_indice( hBstr, IND_BWE_FLAG, 1, 1 ); } } } @@ -680,24 +678,24 @@ void signalling_enc_fx( test(); IF( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) { - push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 ); + push_indice( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 ); /* write ACELP L_frame info */ IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) { - push_indice_fx( hBstr, IND_LAST_L_FRAME, 0, 1 ); + push_indice( hBstr, IND_LAST_L_FRAME, 0, 1 ); } ELSE { - push_indice_fx( hBstr, IND_LAST_L_FRAME, 1, 1 ); + push_indice( hBstr, IND_LAST_L_FRAME, 1, 1 ); } } ELSE { - push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 0, 1 ); + push_indice( hBstr, IND_HQ_SWITCHING_FLG, 0, 1 ); } /* HQ/TCX core switching flag */ - push_indice_fx( hBstr, IND_MDCT_CORE, 0, 1 ); + push_indice( hBstr, IND_MDCT_CORE, 0, 1 ); /* Use ACELP signaling for LR MDCT */ IF( LE_32( st_fx->total_brate, ACELP_16k40 ) ) @@ -721,7 +719,7 @@ void signalling_enc_fx( idx++; } - push_indice_fx( hBstr, IND_ACELP_SIGNALLING, idx - start_idx, nBits ); + push_indice( hBstr, IND_ACELP_SIGNALLING, idx - start_idx, nBits ); } ELSE { @@ -729,25 +727,25 @@ void signalling_enc_fx( IF( LE_32( st_fx->core_brate, ACELP_64k ) ) { /* write ACELP/HQ core indication flag */ - push_indice_fx( hBstr, IND_CORE, 1, 1 ); + push_indice( hBstr, IND_CORE, 1, 1 ); } /* write band-width (needed for different I/O sampling rate support) */ IF( EQ_16( st_fx->bwidth, NB ) ) { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 0, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 0, 2 ); } ELSE IF( EQ_16( st_fx->bwidth, WB ) ) { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 1, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 1, 2 ); } ELSE IF( EQ_16( st_fx->bwidth, SWB ) ) { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 2, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 2, 2 ); } ELSE /* st_fx->bwidth == FB */ { - push_indice_fx( hBstr, IND_HQ_BWIDTH, 3, 2 ); + push_indice( hBstr, IND_HQ_BWIDTH, 3, 2 ); } } } diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 154b43c124b83fe0394d7662fdad731a8d288d5c..6d8a297958fd614b8e44672ef8f64317dfb8ee45 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -29,9 +29,6 @@ #define CNG_TYPE_HO 20 /* hangover for switching between CNG types */ -#ifndef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD -#define DTX_THR 5 /* LP_NOISE level */ -#endif #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ #define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ @@ -63,14 +60,12 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ None */ /*==================================================================================*/ void dtx_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ -#ifdef NONBE_1211_DTX_BR_SWITCHING + Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ -#endif - const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ - const Word16 vad, /* i : vad flag for DTX Q0*/ - const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word16 vad, /* i : vad flag for DTX Q0*/ + const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ + Word16 Q_speech /* i : Q factor for speech */ ) { Word16 alpha, i, j, Q_speech2; @@ -83,21 +78,15 @@ void dtx_ivas_fx( Flag Overflow = 0; move32(); #endif -#ifdef NONBE_1211_DTX_BR_SWITCHING Word32 total_brate_ref; total_brate_ref = st_fx->total_brate; move32(); -#endif IF( st_fx->dtx_sce_sba != 0 ) { last_br_cng_flag = 1; last_br_flag = 1; -#ifndef NONBE_1211_DTX_BR_SWITCHING - br_dtx_flag = 1; - move16(); -#endif move16(); move16(); } @@ -112,15 +101,9 @@ void dtx_ivas_fx( test(); test(); -#ifdef NONBE_1211_DTX_BR_SWITCHING last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); -#else - last_br_flag = LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_IVAS ) ); - br_dtx_flag = 0; - move16(); -#endif } /* Initialization */ @@ -217,10 +200,8 @@ void dtx_ivas_fx( * Select SID or FRAME_NO_DATA frame if DTX is enabled *------------------------------------------------------------------------*/ -#ifdef NONBE_1211_DTX_BR_SWITCHING br_dtx_flag = 1; move16(); -#endif IF( st_fx->dtx_sce_sba == 0 ) { @@ -230,11 +211,7 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || -#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); -#else - LT_16( st_fx->lp_noise_fx, 3840 /*15 in Q8*/ ); -#endif } test(); test(); @@ -352,13 +329,11 @@ void dtx_ivas_fx( reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); } } -#ifdef NONBE_1211_DTX_BR_SWITCHING ELSE IF( st_fx->element_mode != EVS_MONO ) { st_fx->total_brate = total_brate_ref; move32(); } -#endif /*------------------------------------------------------------------------* * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame) @@ -863,7 +838,11 @@ void dtx_fx( /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { +#ifdef HARM_PUSH_BIT + reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); +#else reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); +#endif } } diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index a509a7cd74346749a88061b9a841e5bbad9ac4cc..4317bdbb339419e21de8d9d597255c2083a32b4c 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1387,7 +1387,6 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const return; } -#ifdef FIX_ISSUE_1165 void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ) { Word16 sign[L_SUBFR], vec[L_SUBFR]; @@ -1712,7 +1711,6 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, } return; } -#endif /* * E_ACELP_4t_fx @@ -1869,11 +1867,7 @@ void E_ACELP_4t_ivas_fx( } ELSE { -#ifdef FIX_ISSUE_1165 E_ACELP_4tsearch_ivas_fx( dn, cn, H, code, &config, ind, y ); -#else - E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); -#endif } E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index f18da2ef27024789870875f55f2b3f04c1b01b1c..240f9859c84f2748e544432bf47a9ff619bfae59 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -781,11 +781,7 @@ void E_ACELP_4tsearchx_ivas_fx( alp = shr( alp, 1 ); Scale_sig( cor, L_SUBFR, -1 ); /*Q8*/ Scale_sig( R_buf, 2 * L_SUBFR - 1, -1 ); /*Q8+scale*/ -#ifndef MSAN_FIX - Scale_sig( dn, 2 * L_SUBFR, -1 ); -#else - Scale_sig( dn, L_SUBFR, -1 ); /*Qdn-1*/ -#endif + Scale_sig( dn, L_SUBFR, -1 ); /*Qdn-1*/ } diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 08a20bbb9b8effbccc2227ae263e1c7a0d32ba4d..4c5268017f3c99d751c86272f368064d3209adc2 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -170,7 +170,7 @@ void encod_amr_wb_fx( IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { - push_indice_fx( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); + push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } /*-----------------------------------------------------------------* @@ -243,7 +243,7 @@ void encod_amr_wb_fx( hVAD->hangover_cnt, &hAmrwb_IO->gain_alpha_fx, &hf_gain_fx[i_subfr / L_SUBFR], add( Q_new, 1 ), st->Q_syn ); } - push_indice_fx( hBstr, IND_HF_GAIN_MODIFICATION, hf_gain_fx[i_subfr / L_SUBFR], 4 ); + push_indice( hBstr, IND_HF_GAIN_MODIFICATION, hf_gain_fx[i_subfr / L_SUBFR], 4 ); } p_Aw += ( M + 1 ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 06c49a8d3a3d9b7ed08f81da11f2030ac5da0127..22af9097ddb2a538140f180f0c87660a2b0d6971 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -179,7 +179,7 @@ void encod_gen_voic_fx( move16(); } - push_indice_fx( hBstr, IND_HARM_FLAG_ACELP, harm_flag_acelp, 1 ); + push_indice( hBstr, IND_HARM_FLAG_ACELP, harm_flag_acelp, 1 ); } /*------------------------------------------------------------------* @@ -239,7 +239,7 @@ void encod_gen_voic_fx( IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { - push_indice_fx( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); + push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ @@ -387,7 +387,7 @@ void encod_gen_voic_fx( WHILE( unbits_PI_fx > 0 ) { i = s_min( unbits_PI_fx, 16 ); - push_indice_fx( hBstr, IND_UNUSED, 0, i ); + push_indice( hBstr, IND_UNUSED, 0, i ); unbits_PI_fx -= i; } IF( st_fx->Opt_SC_VBR ) @@ -403,14 +403,14 @@ void encod_gen_voic_fx( void encod_gen_voic_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q0*/ + const Word16 speech_fx[], /* i : input speech Qnew -1 */ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/ + Word16 *syn_fx, /* i/o: core synthesis Q_new - 1*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ @@ -550,12 +550,12 @@ void encod_gen_voic_ivas_fx( Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); @@ -587,7 +587,7 @@ void encod_gen_voic_ivas_fx( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ - Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); @@ -646,7 +646,7 @@ void encod_gen_voic_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_o( Lgcode, &Overflow ); /* Q0 */ + gcode16 = round_fx_o( Lgcode, &Overflow ); hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ move16(); @@ -656,11 +656,7 @@ void encod_gen_voic_ivas_fx( *-----------------------------------------------------------------*/ test(); -#ifdef NONBE_FIX_GSC_BSTR IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) ) -#else - IF( GE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) -#endif { transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); @@ -670,14 +666,30 @@ void encod_gen_voic_ivas_fx( * Update memory of the weighting filter *-----------------------------------------------------------------*/ + + /*At this point + xn has to be in Qnew + yn has to be in Qnew + y2_fx has to be in Q9 + gcode16 in Q_new + gain_pit_fx in Q14 + */ + Scale_sig( xn_fx, L_SUBFR, 1 ); + Scale_sig( y1_fx, L_SUBFR, 1 ); /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); /* Q9 */ - Ltmp = L_shl( Ltmp, add( 5, shift ) ); // Q_new+14+shift + Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); + Ltmp = L_shl( Ltmp, add( 5, shift ) ); Ltmp = L_negate( Ltmp ); - Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); // Q_new-1+15+shift - Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); // Q_new-1+15+shift - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 ); + Ltmp = L_add( Ltmp, Ltmp2 ); + Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx ); + Ltmp = L_sub( Ltmp, Ltmp3 ); + + /*Ltmp is in Q14 + Qnew here + We need memWo in Qnew -1 */ + + Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1 + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ move16(); IF( gain_preQ_fx != 0 ) { @@ -686,20 +698,20 @@ void encod_gen_voic_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* Contribution from AVQ layer */ - Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ + Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); + Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Compute exc2 */ - Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q0 */ - exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ + Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); + exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); move16(); /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ - Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ - Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ + Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ + Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ + Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); move16(); } } @@ -712,11 +724,12 @@ void encod_gen_voic_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ - Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */ - Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */ - Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */ + /*gcode16 in Qnew*/ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ + Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /*Qnew + 9+ 1+5 */ + Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/ + Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ + exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); } } /*-----------------------------------------------------------------* @@ -733,7 +746,7 @@ void encod_gen_voic_ivas_fx( * Update A(z) filters *-----------------------------------------------------------------*/ - Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); p_Aw_fx += ( M + 1 ); p_Aq_fx += ( M + 1 ); diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 40fb9f4f69b5d25e85b877e1256d1b6d1839758c..6b2457d95f0f7fdedd53f9d89d11b0060ebfe3a5 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -242,7 +242,7 @@ void transf_cdbk_enc_fx( Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/ *gain_preQ = round_fx( Ltmp ); /* Q2*/ } - push_indice_fx( st_fx->hBstr, IND_AVQ_GAIN, index, G_AVQ_BITS ); + push_indice( st_fx->hBstr, IND_AVQ_GAIN, index, G_AVQ_BITS ); /*--------------------------------------------------------------* * Encode and multiplex subvectors into bit-stream @@ -276,7 +276,7 @@ void transf_cdbk_enc_fx( WHILE( *unbits > 0 ) { i = s_min( *unbits, 16 ); - push_indice_fx( st_fx->hBstr, IND_UNUSED, 0, i ); + push_indice( st_fx->hBstr, IND_UNUSED, 0, i ); *unbits -= i; } } diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 7e5734e70bdead3ae0e6a5569eac06ca3458b5f3..9180d73b823d3c0096b9548874617676c56baace 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -291,7 +291,7 @@ void enc_pit_exc_fx( IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { - push_indice_fx( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); + push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ @@ -312,12 +312,12 @@ void enc_pit_exc_fx( IF( GE_32( st_fx->core_brate, MIN_RATE_FCB ) ) { pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 32 ); /* Q0 */ - push_indice_fx( hBstr, IND_PIT_IDX, pit_idx, 5 ); + push_indice( hBstr, IND_PIT_IDX, pit_idx, 5 ); } ELSE { pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 16 ); /* Q0 */ - push_indice_fx( hBstr, IND_PIT_IDX, pit_idx, 4 ); + push_indice( hBstr, IND_PIT_IDX, pit_idx, 4 ); } } else if ( use_fcb == 2 ) @@ -549,20 +549,20 @@ void enc_pit_exc_ivas_fx( Word16 xn[PIT_EXC_L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[PIT_EXC_L_SUBFR]; /* Target vector for codebook search */ Word16 h1[PIT_EXC_L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - Word16 y1[PIT_EXC_L_SUBFR]; /* Filtered adaptive excitation */ - Word16 code[2 * L_SUBFR]; /* Fixed codebook excitation */ - Word16 y2[2 * L_SUBFR]; /* Filtered algebraic excitation */ - Word16 voice_fac; /* Voicing factor */ - Word32 gain_code; /* Gain of code */ - Word16 gain_inov; /* inovation gain */ - Word16 gain_pit; /* Pitch gain */ - Word16 pit_idx, i_subfr; /* tmp variables */ - Word16 T0_min, T0_max; /* pitch variables */ - Word16 g_corr[10]; /* ACELP correlation values + gain pitch */ - Word16 clip_gain, i; /* LSF clip gain and LP flag */ - const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */ - Word16 cn1[PIT_EXC_L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ - Word16 *pt_pitch; /* pointer to floating pitch */ + Word16 cn[PIT_EXC_L_SUBFR]; + Word16 y1[PIT_EXC_L_SUBFR]; /* Filtered adaptive excitation */ + Word16 code[2 * L_SUBFR]; /* Fixed codebook excitation */ + Word16 y2[2 * L_SUBFR]; /* Filtered algebraic excitation */ + Word16 voice_fac; /* Voicing factor */ + Word32 gain_code; /* Gain of code */ + Word16 gain_inov; /* inovation gain */ + Word16 gain_pit; /* Pitch gain */ + Word16 pit_idx, i_subfr; /* tmp variables */ + Word16 T0_min, T0_max; /* pitch variables */ + Word16 g_corr[10]; /* ACELP correlation values + gain pitch */ + Word16 clip_gain, i; /* LSF clip gain and LP flag */ + const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */ + Word16 *pt_pitch; /* pointer to floating pitch */ Word16 L_subfr; Word16 cum_gpit, gpit_tmp; Word32 Local_BR, Pitch_BR; @@ -578,9 +578,6 @@ void enc_pit_exc_ivas_fx( Word16 use_fcb; Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/ -#ifndef FIX_ISSUE_1376 - Word16 h1_q15[PIT_EXC_L_SUBFR + ( M + 1 )]; -#endif Word16 q_h1; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; @@ -602,9 +599,7 @@ void enc_pit_exc_ivas_fx( move16(); Pitch_CT = GENERIC; move16(); -#ifdef MSAN_FIX - set16_fx( cn1, 0, PIT_EXC_L_SUBFR ); -#endif + set16_fx( cn, 0, PIT_EXC_L_SUBFR ); test(); test(); IF( st_fx->GSC_IVAS_mode > 0 && ( st_fx->GSC_noisy_speech || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) ) @@ -714,13 +709,6 @@ void enc_pit_exc_ivas_fx( /*------------------------------------------------------------------* * ACELP subframe loop *------------------------------------------------------------------*/ - cn = NULL; - test(); - if ( EQ_16( L_subfr, L_SUBFR ) || EQ_16( L_subfr, L_SUBFR * 2 ) ) - { - cn = cn1; - move16(); - } p_Aw = Aw; p_Aq = Aq; @@ -738,8 +726,8 @@ void enc_pit_exc_ivas_fx( Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ /* condition on target (compared to float) has been put outside the loop */ - find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, - res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + find_targets_ivas_new_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, + res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/ @@ -773,20 +761,15 @@ void enc_pit_exc_ivas_fx( * Codebook target computation * (No LP filtering of the adaptive excitation) *-----------------------------------------------------------------*/ -#ifndef FIX_ISSUE_1376 - Copy_Scale_sig( h1, h1_q15, L_subfr, 1 ); // Q14 -> Q15 - - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1_q15, - xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ -#else lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1, xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ -#endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } + st_fx->hSpMusClas->lowrate_pitchGain = mac_r( L_mult( 29491 /* 0.9 in Q15 */, st_fx->hSpMusClas->lowrate_pitchGain ), 3277 /* 0.1 in Q15 */, gain_pit ); /* Q14 */ + gpit_tmp = gain_pit; move16(); /*Q14*/ test(); diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index c2aeaa7ca3d4ec2d9aad3c65eb64e7cac8177e6c..9d1ffad606de1ad414a8a6249fef35c5763a38b1 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -189,8 +189,11 @@ ivas_error encod_ppp_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ +#ifdef HARM_PUSH_BIT + reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); +#else reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); - +#endif /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); } @@ -373,8 +376,11 @@ ivas_error encod_ppp_ivas_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ +#ifdef HARM_PUSH_BIT + reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); +#else reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); - +#endif /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); } diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index ecd4e2f013b4bb937d8fa8cb5d8f88a19b1482b6..6d6a2d575ac9f262d0817f60ef4cfa4232a5b9d4 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -33,7 +33,7 @@ static void enc_prm_hm( } /* Flag */ - push_next_indice_fx( hBstr, prm_hm[0], 1 ); + push_next_indice( hBstr, prm_hm[0], 1 ); IF( prm_hm[0] ) { @@ -50,7 +50,7 @@ static void enc_prm_hm( IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) ) { /* Gain index */ - push_next_indice_fx( hBstr, prm_hm[2], kTcxHmNumGainBits ); + push_next_indice( hBstr, prm_hm[2], kTcxHmNumGainBits ); } } } @@ -152,7 +152,7 @@ void enc_prm_rf_ivas_fx( index = 3; move16(); } - push_next_indice_fx( hBstr, index, 2 ); + push_next_indice( hBstr, index, 2 ); IF( EQ_16( rf_frame_type, RF_TCXFD ) ) { @@ -296,9 +296,9 @@ void enc_prm_rf_fx( /* LSF indices */ IF( EQ_16( rf_frame_type, RF_TCXFD ) ) { - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][0], lsf_numbits[0] ); /* VQ 1 */ - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][1], lsf_numbits[1] ); /* VQ 2 */ - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][2], lsf_numbits[2] ); /* VQ 3 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], lsf_numbits[0] ); /* VQ 1 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], lsf_numbits[1] ); /* VQ 2 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][2], lsf_numbits[2] ); /* VQ 3 */ } /* classification */ @@ -324,12 +324,12 @@ void enc_prm_rf_fx( index = 3; move16(); } - push_next_indice_fx( hBstr, index, 2 ); + push_next_indice( hBstr, index, 2 ); IF( EQ_16( rf_frame_type, RF_TCXFD ) ) { /* TCX global gain = 7 bits */ - push_next_indice_fx( hBstr, hRF->rf_gain_tcx[fec_offset], 7 ); + push_next_indice( hBstr, hRF->rf_gain_tcx[fec_offset], 7 ); /*window info 1 bit for long overlap 2 if minimum or half overlap*/ @@ -345,35 +345,35 @@ void enc_prm_rf_fx( test(); IF( ( EQ_16( rf_frame_type, RF_TCXTD1 ) || EQ_16( rf_frame_type, RF_TCXTD2 ) ) && hTcxEnc->tcxltp != 0 ) { - push_next_indice_fx( hBstr, hRF->rf_tcxltp_param[fec_offset], 9 ); + push_next_indice( hBstr, hRF->rf_tcxltp_param[fec_offset], 9 ); } } } ELSE IF( EQ_16( rf_frame_type, 7 ) ) /* NELP bitstream writing */ { /* LSF indices */ - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ /* NELP gain indices */ - push_next_indice_fx( hBstr, hRF->rf_indx_nelp_iG1[fec_offset], 5 ); - push_next_indice_fx( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][0], 6 ); - push_next_indice_fx( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][1], 6 ); + push_next_indice( hBstr, hRF->rf_indx_nelp_iG1[fec_offset], 5 ); + push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][0], 6 ); + push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][1], 6 ); /* NELP filter selection index */ - push_next_indice_fx( hBstr, hRF->rf_indx_nelp_fid[fec_offset], 2 ); + push_next_indice( hBstr, hRF->rf_indx_nelp_fid[fec_offset], 2 ); /* tbe gainFr */ - push_next_indice_fx( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 5 ); + push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 5 ); } ELSE IF( GE_16( rf_frame_type, 4 ) ) /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6 */ { /* LSF indices */ - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ - push_next_indice_fx( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ + push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ /* ES pred */ - push_next_indice_fx( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 ); + push_next_indice( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 ); ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type]; /* Q0 */ ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type]; /* Q0 */ @@ -386,13 +386,13 @@ void enc_prm_rf_fx( n = ACELP_LTP_BITS_SFR[ltp_mode][sfr]; IF( n != 0 ) { - push_next_indice_fx( hBstr, hRF->rf_indx_pitch[fec_offset][sfr], n ); + push_next_indice( hBstr, hRF->rf_indx_pitch[fec_offset][sfr], n ); } /* Adaptive codebook filtering (1 bit) */ IF( EQ_16( ltf_mode, 2 ) ) { - push_next_indice_fx( hBstr, hRF->rf_indx_ltfMode[fec_offset][sfr], 1 ); + push_next_indice( hBstr, hRF->rf_indx_ltfMode[fec_offset][sfr], 1 ); } /*Innovative codebook*/ @@ -403,7 +403,7 @@ void enc_prm_rf_fx( ( EQ_16( rf_frame_type, RF_GENPRED ) && ( sfr == 0 || EQ_16( sfr, 2 ) ) ) ) { - push_next_indice_fx( hBstr, hRF->rf_indx_fcb[fec_offset][sfr], 7 ); + push_next_indice( hBstr, hRF->rf_indx_fcb[fec_offset][sfr], 7 ); } /* Gains (5b, 6b or 7b / subfr) */ @@ -411,11 +411,11 @@ void enc_prm_rf_fx( IF( sfr == 0 || EQ_16( sfr, 2 ) ) { n = ACELP_GAINS_BITS[gains_mode]; - push_next_indice_fx( hBstr, hRF->rf_indx_gain[fec_offset][sfr], n ); + push_next_indice( hBstr, hRF->rf_indx_gain[fec_offset][sfr], n ); } } /* tbe gainFr */ - push_next_indice_fx( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 2 ); + push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 2 ); } /***************/ @@ -429,15 +429,15 @@ void enc_prm_rf_fx( test(); IF( EQ_16( fec_offset, 2 ) ) { - push_next_indice_fx( hBstr, 0, 2 ); + push_next_indice( hBstr, 0, 2 ); } ELSE IF( EQ_16( fec_offset, 3 ) || EQ_16( fec_offset, 5 ) || EQ_16( fec_offset, 7 ) ) { - push_next_indice_fx( hBstr, ( fec_offset - 1 ) / 2, 2 ); + push_next_indice( hBstr, ( fec_offset - 1 ) / 2, 2 ); } /* write RF frame type last in the bitstream */ - push_next_indice_fx( hBstr, rf_frame_type, 3 ); + push_next_indice( hBstr, rf_frame_type, 3 ); } @@ -533,7 +533,7 @@ void enc_prm_fx( IF( st->tcxonly ) { - push_next_indice_fx( hBstr, core == TCX_10_CORE, 1 ); + push_next_indice( hBstr, core == TCX_10_CORE, 1 ); { index = 3; move16(); @@ -553,7 +553,7 @@ void enc_prm_fx( index = 2; move16(); } - push_next_indice_fx( hBstr, index, 2 ); + push_next_indice( hBstr, index, 2 ); } } ELSE @@ -581,13 +581,13 @@ void enc_prm_fx( { idx = add( idx, 1 ); /* Q0 */ } - push_next_indice_fx( hBstr, idx - start_idx, nBits ); - push_next_indice_fx( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/ - nbits_start = 3; /* Q0 */ + push_next_indice( hBstr, idx - start_idx, nBits ); + push_next_indice( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/ + nbits_start = 3; /* Q0 */ } ELSE { - push_next_indice_fx( hBstr, coder_type, 3 ); + push_next_indice( hBstr, coder_type, 3 ); } } ELSE @@ -595,15 +595,15 @@ void enc_prm_fx( IF( EQ_16( st->mdct_sw, MODE1 ) ) { /* 2 bits instead of 3 as TCX is already signaled */ - push_next_indice_fx( hBstr, st->hTcxCfg->coder_type, 2 ); + push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); } ELSE { IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) { - push_next_indice_fx( hBstr, 1, 1 ); /* TCX */ - push_next_indice_fx( hBstr, 0, 1 ); /* not HQ_CORE */ - push_next_indice_fx( hBstr, st->hTcxCfg->coder_type, 2 ); + push_next_indice( hBstr, 1, 1 ); /* TCX */ + push_next_indice( hBstr, 0, 1 ); /* not HQ_CORE */ + push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); } ELSE { @@ -641,13 +641,13 @@ void enc_prm_fx( { idx = add( idx, 1 ); } - push_next_indice_fx( hBstr, idx - start_idx, nBits ); - push_next_indice_fx( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/ + push_next_indice( hBstr, idx - start_idx, nBits ); + push_next_indice( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/ nbits_start = 3; } ELSE { - push_next_indice_fx( hBstr, 4 + st->hTcxCfg->coder_type, 3 ); + push_next_indice( hBstr, 4 + st->hTcxCfg->coder_type, 3 ); } } } @@ -667,7 +667,7 @@ void enc_prm_fx( tmp = TCX_20_CORE; move16(); } - push_next_indice_fx( hBstr, tmp, 1 ); + push_next_indice( hBstr, tmp, 1 ); } /* write TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */ @@ -696,7 +696,7 @@ void enc_prm_fx( overlap_code = 0; move16(); } - push_next_indice_fx( hBstr, overlap_code, nbits_tcx ); + push_next_indice( hBstr, overlap_code, nbits_tcx ); } IF( st->hPlcExt->enableGplc ) @@ -719,7 +719,7 @@ void enc_prm_fx( IF( EQ_16( core, ACELP_CORE ) ) { - push_next_indice_fx( hBstr, st->glr_idx[0], G_LPC_RECOVERY_BITS ); + push_next_indice( hBstr, st->glr_idx[0], G_LPC_RECOVERY_BITS ); } } @@ -789,7 +789,7 @@ void enc_prm_fx( IF( n != 0 ) { - push_next_indice_fx( hBstr, st->bpf_gain_param, n ); + push_next_indice( hBstr, st->bpf_gain_param, n ); } /* Mean energy (2 or 3 bits) */ @@ -797,7 +797,7 @@ void enc_prm_fx( IF( n != 0 ) { - push_next_indice_fx( hBstr, prm[j++], n ); + push_next_indice( hBstr, prm[j++], n ); } /* Subframe parameters */ @@ -810,14 +810,14 @@ void enc_prm_fx( IF( n != 0 ) { - push_next_indice_fx( hBstr, prm[j++], n ); + push_next_indice( hBstr, prm[j++], n ); } /* Adaptive codebook filtering (1 bit) */ IF( EQ_16( st->acelp_cfg.ltf_mode, 2 ) ) { - push_next_indice_fx( hBstr, prm[j++], 1 ); + push_next_indice( hBstr, prm[j++], 1 ); } /*Innovative codebook*/ @@ -839,12 +839,12 @@ void enc_prm_fx( FOR( ix = 0; ix < wordcnt; ix++ ) { - push_next_indice_fx( hBstr, prm[j++], 16 ); + push_next_indice( hBstr, prm[j++], 16 ); } IF( bitcnt ) { - push_next_indice_fx( hBstr, prm[j++], bitcnt ); + push_next_indice( hBstr, prm[j++], bitcnt ); } j = add( j_old, 8 ); /* Q0 */ @@ -852,7 +852,7 @@ void enc_prm_fx( /* Gains (5b, 6b or 7b / subfr) */ n = ACELP_GAINS_BITS[st->acelp_cfg.gains_mode[sfr]]; - push_next_indice_fx( hBstr, prm[j++], n ); + push_next_indice( hBstr, prm[j++], n ); } /*end of for(sfr)*/ } /*end of mode[0]==0*/ @@ -866,14 +866,14 @@ void enc_prm_fx( move16(); IF( st->enablePlcWaveadjust ) { - push_next_indice_fx( hBstr, st->Tonal_SideInfo, 1 ); + push_next_indice( hBstr, st->Tonal_SideInfo, 1 ); } /* TCX Gain = 7 bits */ - push_next_indice_fx( hBstr, prm[j++], 7 ); + push_next_indice( hBstr, prm[j++], 7 ); /* TCX Noise Filling = NBITS_NOISE_FILL_LEVEL bits */ - push_next_indice_fx( hBstr, prm[j++], NBITS_NOISE_FILL_LEVEL ); + push_next_indice( hBstr, prm[j++], NBITS_NOISE_FILL_LEVEL ); /* LTP data */ test(); @@ -881,13 +881,13 @@ void enc_prm_fx( { IF( prm[j] ) { - push_next_indice_fx( hBstr, 1, 1 ); - push_next_indice_fx( hBstr, prm[j + 1], 9 ); - push_next_indice_fx( hBstr, prm[j + 2], 2 ); + push_next_indice( hBstr, 1, 1 ); + push_next_indice( hBstr, prm[j + 1], 9 ); + push_next_indice( hBstr, prm[j + 2], 2 ); } ELSE { - push_next_indice_fx( hBstr, 0, 1 ); + push_next_indice( hBstr, 0, 1 ); } } j = add( j, 3 ); @@ -932,7 +932,7 @@ void enc_prm_fx( test(); IF( st->hTcxCfg->ctx_hm && NE_16( last_core, ACELP_CORE ) ) { - push_next_indice_fx( hBstr, prm[j], 1 ); + push_next_indice( hBstr, prm[j], 1 ); IF( prm[j] ) { @@ -965,7 +965,7 @@ void enc_prm_fx( IF( hTcxEnc->tcx_lpc_shaped_ari != 0 ) { - push_next_bits_fx( hBstr, &prm[++j], nbits_tcx ); + push_next_bits( hBstr, (UWord16 *) &prm[++j], nbits_tcx ); j = add( j, nbits_tcx ); /* Q0 */ } ELSE @@ -1015,14 +1015,14 @@ void enc_prm_fx( test(); IF( st->enablePlcWaveadjust && k ) { - push_next_indice_fx( hBstr, st->Tonal_SideInfo, 1 ); + push_next_indice( hBstr, st->Tonal_SideInfo, 1 ); } /* TCX Gain = 7 bits */ - push_next_indice_fx( hBstr, prm[j++], 7 ); + push_next_indice( hBstr, prm[j++], 7 ); /* TCX Noise Filling = NBITS_NOISE_FILL_LEVEL bits */ - push_next_indice_fx( hBstr, prm[j++], NBITS_NOISE_FILL_LEVEL ); + push_next_indice( hBstr, prm[j++], NBITS_NOISE_FILL_LEVEL ); /* LTP data */ test(); @@ -1031,13 +1031,13 @@ void enc_prm_fx( { IF( prm[j] ) { - push_next_indice_fx( hBstr, 1, 1 ); - push_next_indice_fx( hBstr, prm[j + 1], 9 ); - push_next_indice_fx( hBstr, prm[j + 2], 2 ); + push_next_indice( hBstr, 1, 1 ); + push_next_indice( hBstr, prm[j + 1], 9 ); + push_next_indice( hBstr, prm[j + 2], 2 ); } ELSE { - push_next_indice_fx( hBstr, 0, 1 ); + push_next_indice( hBstr, 0, 1 ); } } j = add( j, 3 ); @@ -1079,7 +1079,7 @@ void enc_prm_fx( test(); IF( st->hTcxCfg->ctx_hm && !( last_core == ACELP_CORE && k == 0 ) ) { - push_next_indice_fx( hBstr, prm[j], 1 ); + push_next_indice( hBstr, prm[j], 1 ); IF( prm[j] ) { diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 5b9f6750302d8933f8718fd68ec923edc7b20863..d6935dd0ce0cbbf841fc6f7917dba300dfd34f33 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -327,7 +327,7 @@ Word16 encod_tran_fx( WHILE( unbits_PI > 0 ) { i = s_min( unbits_PI, 16 ); - push_indice_fx( hBstr, IND_UNUSED, 0, i ); + push_indice( hBstr, IND_UNUSED, 0, i ); unbits_PI -= i; } @@ -336,72 +336,72 @@ Word16 encod_tran_fx( { IF( EQ_16( tc_subfr, TC_0_0 ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); } ELSE IF( EQ_16( tc_subfr, TC_0_64 ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); } ELSE IF( EQ_16( tc_subfr, TC_0_128 ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); } ELSE IF( EQ_16( tc_subfr, TC_0_192 ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); } ELSE IF( EQ_16( tc_subfr, L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); } ELSE IF( EQ_16( tc_subfr, 2 * L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); } ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); } } ELSE /* L_frame == L_FRAME16k */ { IF( tc_subfr == 0 ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 2 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 2 ); } ELSE IF( EQ_16( tc_subfr, L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 2 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 2 ); } ELSE IF( EQ_16( tc_subfr, 2 * L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 2, 2 ); + push_indice( hBstr, IND_TC_SUBFR, 2, 2 ); } ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 3, 2 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 0, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 3, 2 ); + push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); } ELSE IF( EQ_16( tc_subfr, 4 * L_SUBFR ) ) { - push_indice_fx( hBstr, IND_TC_SUBFR, 3, 2 ); - push_indice_fx( hBstr, IND_TC_SUBFR, 1, 1 ); + push_indice( hBstr, IND_TC_SUBFR, 3, 2 ); + push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); } } @@ -478,9 +478,7 @@ Word16 encod_tran_ivas_fx( L_frame_fx = st_fx->L_frame; move16(); -#ifdef MSAN_FIX set16_fx( h1, 0, L_SUBFR + ( M + 1 ) ); -#endif /*------------------------------------------------------------------* * Initializations diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index b0c67abf528e2aef3bf40e609cfaba8e803b5f70..a8612725b3a71575342f9197aeda467f235b75ad 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -153,7 +153,7 @@ void encod_unvoiced_fx( #ifdef DEBUGGING assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" ); #endif - push_indice_fx( st_fx->hBstr, IND_GAIN, index, st_fx->acelp_cfg.gains_mode[i_subfr_idx] ); + push_indice( st_fx->hBstr, IND_GAIN, index, st_fx->acelp_cfg.gains_mode[i_subfr_idx] ); gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); @@ -453,14 +453,10 @@ void encod_unvoiced_ivas_fx( voice_factors_fx[i_subfr / L_SUBFR] = 0; move16(); -#ifdef FIX_ISSUE_1148 if ( st_fx->hBWE_TD != NULL ) { interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR ); } -#else - interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR ); -#endif /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index 7dc96a4e31a73fa401bb5170f05035510b58de02..0168e52b11bbbd0c077eeb15366ba2ea3059130b 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -451,11 +451,7 @@ void background_update_fx( tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) ); /* scale_sb_energy */ FOR( i = 0; i < SNR_sb_num; i++ ) { -#ifdef FIX_ISSUE_1209 sb_bg_energy[i] = L_add_sat( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp ); /* scale_sb_energy */ -#else - sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp ); /* scale_sb_energy */ -#endif move32(); } } diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index aef5fd637644d28922b643193804a24b9b93be31..5e1c8dfe32dffa97ff711e152ddc3b37b3c89478 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -378,6 +378,16 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit move16(); set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR16k ); + +#ifdef HARM_PUSH_BIT + /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ + for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) + { + delete_indice( hBstr, i ); + } + + delete_indice( hBstr, IND_ES_PRED ); +#else /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) { @@ -396,6 +406,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit hBstr->ind_list[IND_ES_PRED].nb_bits = -1; move16(); } +#endif } IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { @@ -409,17 +420,17 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { - push_indice_fx( hBstr, IND_PIT_CONTR_IDX, pit_contr_idx, 1 ); + push_indice( hBstr, IND_PIT_CONTR_IDX, pit_contr_idx, 1 ); } } ELSE { - push_indice_fx( hBstr, IND_PIT_CONTR_IDX, pit_contr_idx, 3 ); + push_indice( hBstr, IND_PIT_CONTR_IDX, pit_contr_idx, 3 ); } } ELSE { - push_indice_fx( hBstr, IND_PIT_CONTR_IDX, pit_contr_idx, 4 ); + push_indice( hBstr, IND_PIT_CONTR_IDX, pit_contr_idx, 4 ); } return last_pit_bin; diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index c86b7e0613bcc737810d7a33d01b17b2d021a76e..396e97c6fa5adf5d01e3b2bd3b6ebcd39dd0fbfc 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -419,7 +419,7 @@ ivas_error evs_enc_fx( FOR( i = 0; i < padBits; i++ ) { - push_next_indice_fx( hBstr, 0, 1 ); + push_next_indice( hBstr, 0, 1 ); } } @@ -678,19 +678,19 @@ static void writeFrameHeader_loc( Encoder_State *st ) IF( EQ_16( st->cng_type, FD_CNG ) ) { /* write SID/CNG type flag */ - push_next_indice_fx( hBstr, 1, 1 ); + push_next_indice( hBstr, 1, 1 ); /* write bandwidth mode */ - push_next_indice_fx( hBstr, st->bwidth, 2 ); + push_next_indice( hBstr, st->bwidth, 2 ); /* write L_frame */ IF( EQ_16( st->L_frame, L_FRAME ) ) { - push_next_indice_fx( hBstr, 0, 1 ); + push_next_indice( hBstr, 0, 1 ); } ELSE { - push_next_indice_fx( hBstr, 1, 1 ); + push_next_indice( hBstr, 1, 1 ); } } } @@ -698,7 +698,7 @@ static void writeFrameHeader_loc( Encoder_State *st ) { IF( st->rf_mode == 0 ) { - push_next_indice_fx( hBstr, sub( st->bwidth, FrameSizeConfig[st->frame_size_index].bandwidth_min ), FrameSizeConfig[st->frame_size_index].bandwidth_bits ); + push_next_indice( hBstr, sub( st->bwidth, FrameSizeConfig[st->frame_size_index].bandwidth_min ), FrameSizeConfig[st->frame_size_index].bandwidth_bits ); } } @@ -706,7 +706,7 @@ static void writeFrameHeader_loc( Encoder_State *st ) test(); IF( FrameSizeConfig[st->frame_size_index].reserved_bits && st->rf_mode == 0 ) { - push_next_indice_fx( hBstr, 0, FrameSizeConfig[st->frame_size_index].reserved_bits ); + push_next_indice( hBstr, 0, FrameSizeConfig[st->frame_size_index].reserved_bits ); } } diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index f546c3ef8f6c2edb7eddad5358700447e8efc613..200e7e8edc410168b73ffd26a52f84ac35c5bfe4 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -675,6 +675,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( Word16 alw_voicing[2], alw_voicing_wc = -1; Word16 disable_ltp = 0; Word16 tmp, *tmpP16; + Word16 q_mdstWin = st->q_inp, q_tcx20Win = st->q_inp; Word32 *tmpP32; Word16 Q_exp; Word32 L_tmpbuf[N_MAX + L_MDCT_OVLP_MAX]; @@ -684,15 +685,18 @@ void core_signal_analysis_high_bitrate_ivas_fx( move16(); move16(); move16(); + move16(); + move16(); (void) vad_hover_flag; Word16 Q_win_temp[2]; Word16 *speech_ltp_fx = NULL; Word16 *wspeech_fx = NULL; Word16 *speech_fx = NULL; - Word16 q_out_wtda = 0; + Word16 q_out_wtda = st->q_inp; move16(); Word16 win_len[2]; move16(); + Word16 shift; set32_fx( buf_powerSPec, 0, N_MAX + L_MDCT_OVLP_MAX ); set16_fx( buf_powerSPec_exp, 0, N_MAX + L_MDCT_OVLP_MAX ); @@ -961,16 +965,14 @@ void core_signal_analysis_high_bitrate_ivas_fx( move32(); windowed_samples[frameno * L_FRAME_MAX + 1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0 move32(); - Copy_Scale_sig_16_32_DEPREC( tcx20Win, windowed_samples + add( imult1616( frameno, L_FRAME_MAX ), 2 ), add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), 0 ); + Copy_Scale_sig_16_32_DEPREC( tcx20Win, windowed_samples + add( imult1616( frameno, L_FRAME_MAX ), 2 ), add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), negate( q_tcx20Win ) ); *q_win = s_min( *q_win, sub( L_norm_arr( windowed_samples + add( imult1616( frameno, L_FRAME_MAX ), 2 ), add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ) ), 1 ) ); move16(); Q_win_temp[frameno] = *q_win; move16(); -#ifdef MSAN_FIX Scale_sig32( windowed_samples + frameno * L_FRAME_MAX + 2, win_len[frameno], *q_win ); // q_win -#endif IF( EQ_16( frameno, 1 ) ) { Scale_sig32( windowed_samples + 2, win_len[0], sub( *q_win, Q_win_temp[0] ) ); // q_win @@ -985,7 +987,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outter left folding */ FOR( i = 0; i < folding_offset; i++ ) { - tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0 + tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // q_tcx20Win move16(); } @@ -998,18 +1000,16 @@ void core_signal_analysis_high_bitrate_ivas_fx( Word32 L_tmp; FOR( i = minWindowLen; i >= tmp; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_tcx20Win, Q15) -> Q16 + q_tcx20Win + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_tcx20Win, Q15) -> Q16 + q_tcx20Win + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_h( L_tmp ) ); // q_tcx20Win move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_tcx20Win, Q15) -> Q16 + q_tcx20Win + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_tcx20Win, Q15) -> Q16 + q_tcx20Win + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_h( L_tmp ) ); // q_tcx20Win move32(); } } @@ -1018,7 +1018,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = shr( right_overlap, 1 ); FOR( i = 0; i < tmp; i++ ) { - tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0 + tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // q_tcx20Win move16(); } @@ -1029,6 +1029,12 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmpP16 = tcx20Win; tmpP32 = hTcxEnc->spectrum_fx[frameno]; assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE ); + Word16 len[2], exp[2]; + hTcxEnc->spectrum_e[frameno] = sub( 16, q_tcx20Win ); + exp[0] = exp[1] = hTcxEnc->spectrum_e[frameno]; + move16(); + move16(); + move16(); FOR( i = 0; i < 2; i++ ) { test(); @@ -1039,17 +1045,17 @@ void core_signal_analysis_high_bitrate_ivas_fx( mac_r( 2 << 16, -( 3 << 8 ), shl( i, 7 ) ), /* equivalent to: sub(i, 1) == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP */ &left_overlap, &right_overlap, tmpP16, &L_subframe, tcx5Win, st->element_mode != IVAS_CPE_MDCT, 1 ); - hTcxEnc->spectrum_e[frameno] = 16; - move16(); TCX_MDCT( tcx5Win, tmpP32, - &hTcxEnc->spectrum_e[frameno], + &exp[i], left_overlap, sub( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); tmpP16 += tcx5SizeFB; tmpP32 += tcx5SizeFB; + len[i] = L_subframe; + move16(); /* high-band gain control in case of BWS */ IF( st->bwidth_sw_cnt > 0 ) @@ -1066,6 +1072,13 @@ void core_signal_analysis_high_bitrate_ivas_fx( L_subframe - L_FRAME16k / ( 2 * nSubframes ) ); } } + hTcxEnc->spectrum_e[frameno] = s_max( exp[0], exp[1] ); + move16(); + + FOR( i = 0; i < 2; i++ ) + { + scale_sig32( hTcxEnc->spectrum_fx[frameno] + i * L_subframe, len[i], sub( exp[i], hTcxEnc->spectrum_e[frameno] ) ); + } } ELSE /* transform_type[frameno] != TCX_5 */ { @@ -1107,23 +1120,23 @@ void core_signal_analysis_high_bitrate_ivas_fx( Word32 L_tmp; FOR( i = minWindowLen; i >= tmp; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_tcx20Win, Q15) -> Q16 + q_tcx20Win + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 + q_tcx20Win + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_h( L_tmp ) ); // q_tcx20Win move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_tcx20Win, Q15) -> Q16 + q_tcx20Win + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_tcx20Win, Q15) -> Q16 + q_tcx20Win + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_h( L_tmp ) ); // q_tcx20Win move32(); } } TCX_MDCT( tcx20Win, hTcxEnc->spectrum_fx[frameno], &hTcxEnc->spectrum_e[frameno], left_overlap, sub( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); + hTcxEnc->spectrum_e[frameno] = sub( hTcxEnc->spectrum_e[frameno], q_tcx20Win ); + move16(); } /* high-band gain control in case of BWS */ @@ -1149,23 +1162,27 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) && ( ( LT_32( st->total_brate, HQ_96k ) ) || st->igf ) ) { pMdstWin = tcx20Win; + Word16 q_pmdstWin = q_tcx20Win; + move16(); test(); if ( ( ( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) && ( NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) ) ) { pMdstWin = mdstWin; + q_pmdstWin = q_mdstWin; + move16(); } /* Compute noise-measure flags for spectrum filling and quantization */ AnalyzePowerSpectrum_ivas_fx( st, div_l( L_mult( L_subframe, st->L_frame ), hTcxEnc->L_frameTCX ), L_subframe, left_overlap, right_overlap, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_e[frameno], - pMdstWin, powerSpec, powerSpec_e ); + pMdstWin, q_pmdstWin, powerSpec, powerSpec_e ); } } } IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Word16 q_mdstWin, scale; + Word16 scale; L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */ test(); @@ -1175,8 +1192,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( scale = sub( norm_arr( mdstWin, L_frameTCX ), 1 ); scale = s_min( 1, scale ); // restricting the Q to zero or less scale_sig( mdstWin, L_frameTCX, scale ); - q_mdstWin = add( -1, scale ); - move16(); + q_mdstWin = add( add( st->q_inp, -1 ), scale ); } ELSE { @@ -1187,8 +1203,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( scale = sub( norm_arr( mdstWin, sig_len ), 1 ); scale = s_min( 0, scale ); // restricting the Q to zero or less scale_sig( mdstWin, sig_len, scale ); - q_mdstWin = scale; - move16(); + q_mdstWin = add( scale, st->q_inp ); } IF( EQ_16( transform_type[frameno], TCX_5 ) ) @@ -1204,20 +1219,21 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( frameno == 0 && overlap_mode[0] == FULL_OVERLAP && GT_16( sub( L_subframe, left_overlap ), minWindowLen ) ) { tmp = shr( st->hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ); + shift = sub( q_mdstWin, add( Q16, st->q_inp ) ); Word32 L_tmp; FOR( i = minWindowLen; i >= tmp; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_inp, Q15) -> Q16 + q_inp + L_tmp = L_shl( L_tmp, shift ); // q_mdstWin mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_inp, Q15) -> Q16 + q_inp + L_tmp = L_shl( L_tmp, shift ); // q_mdstWin mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } @@ -1292,19 +1308,20 @@ void core_signal_analysis_high_bitrate_ivas_fx( { tmp = shr( st->hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ); Word32 L_tmp; + shift = sub( q_mdstWin, add( Q16, st->q_inp ) ); FOR( i = minWindowLen; i >= tmp; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_inp, Q15) -> Q16 + q_inp + L_tmp = L_shl( L_tmp, shift ); // q_mdstWin mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp + L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_inp, Q15) -> Q16 + q_inp + L_tmp = L_shl( L_tmp, shift ); // q_mdstWin mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } @@ -1384,27 +1401,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( st->igf ) { Word16 q_spectrum = sub( Q31, hTcxEnc->spectrum_e[frameno] ); -#ifndef MSAN_FIX - ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); -#else ProcessIGF_ivas_fx( st, N_MAX + L_MDCT_OVLP_MAX, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); -#endif } } } -#ifndef MSAN_FIX - IF( windowed_samples != NULL ) - { - FOR( frameno = 0; frameno < nSubframes; frameno++ ) - { - IF( !( ( EQ_16( transform_type[frameno], TCX_20 ) ) && ( NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) ) ) - { - Scale_sig32( windowed_samples + frameno * L_FRAME_MAX + 2, win_len, *q_win ); - } - } - } -#endif IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 9c3a236d75d8ec84214f7397eeeb1526df695a3a..a7339e65334a0964eaeecdfd2a4fa1c3c9a35a9a 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1211,27 +1211,27 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru { FOR( i = 0; i < stages_37bits; i++ ) { - push_next_indice_fx( hBstr, indices[i], bits_37bits[i] ); + push_next_indice( hBstr, indices[i], bits_37bits[i] ); } - push_next_indice_fx( hBstr, index, 7 ); + push_next_indice( hBstr, index, 7 ); } ELSE { - push_indice_fx( hBstr, IND_SID_TYPE, 1, 1 ); - push_indice_fx( hBstr, IND_ACELP_16KHZ, corest->bwidth, 2 ); + push_indice( hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( hBstr, IND_ACELP_16KHZ, corest->bwidth, 2 ); IF( EQ_16( corest->L_frame, L_FRAME16k ) ) { - push_indice_fx( hBstr, IND_ACELP_16KHZ, 1, 1 ); + push_indice( hBstr, IND_ACELP_16KHZ, 1, 1 ); } ELSE { - push_indice_fx( hBstr, IND_ACELP_16KHZ, 0, 1 ); + push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 ); } FOR( i = 0; i < stages_37bits; i++ ) { - push_indice_fx( hBstr, IND_LSF, indices[i], bits_37bits[i] ); + push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); } - push_indice_fx( hBstr, IND_ENERGY, index, 7 ); + push_indice( hBstr, IND_ENERGY, index, 7 ); } /* Interpolate the bin/band-wise levels from the partition levels */ @@ -2066,7 +2066,7 @@ Word16 cng_energy_fx( L_tmp = L_mult0( tmp16, tmp16 ); pt_res++; tmp16 = shl( *pt_res, scale ); - L_tmp = L_mac0( L_tmp, tmp16, tmp16 ); /* 2*(Q_new+scale) */ + L_tmp = L_mac0_sat( L_tmp, tmp16, tmp16 ); /* 2*(Q_new+scale) */ pt_res++; L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ } @@ -2317,8 +2317,10 @@ void perform_noise_estimation_enc_ivas_fx( move32(); periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) ); move16(); - max_exp = s_max( max_exp, periodog_exp[i] ); - + if ( *ptr_per_fx ) + { + max_exp = s_max( max_exp, periodog_exp[i] ); + } ptr_per_fx++; i++; } @@ -2350,8 +2352,8 @@ void perform_noise_estimation_enc_ivas_fx( &hFdCngEnc->msPeriodog_fx_exp_cldfb ); ///* find common exponent for fft part and cldfb part of msperiodog */ - s1 = getScaleFactor32( msPeriodog_fx, nFFTpart ); - s2 = getScaleFactor32( &msPeriodog_fx[nFFTpart], nCLDFBpart ); + s1 = L_norm_arr( msPeriodog_fx, nFFTpart ); + s2 = L_norm_arr( &msPeriodog_fx[nFFTpart], nCLDFBpart ); s = s_max( sub( hFdCngEnc->msPeriodog_fx_exp_fft, s1 ), sub( hFdCngEnc->msPeriodog_fx_exp_cldfb, s2 ) ); s1 = sub( s, hFdCngEnc->msPeriodog_fx_exp_fft ); @@ -2370,7 +2372,7 @@ void perform_noise_estimation_enc_ivas_fx( FOR( i = 0; i < nCLDFBpart; i++ ) { - msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ + msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s2 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ move32(); } } @@ -2839,16 +2841,19 @@ void FdCngEncodeMDCTStereoSID_fx( { IF( lr_in_ptr_fx[ch][p] ) { - t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] ); // Q25 - t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 + t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] ); // Q25 + t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 + ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 + move32(); } ELSE { - t2 = 0; + // 10.f * log10f( EPSILON ) --> -150.0f + // Subsequent additions / subtractions happen on these numbers, so to avoid saturations + // this value is set to -128.0f in Q23 + ms_ptr_fx[ch][p] = -ONE_IN_Q30; // Q23 move32(); } - ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 - move32(); E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 4 ) ); // Q19 move32(); } diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 4e15bc82820dbe3f6de8055ff78d911f814b63e9..4f24ec39f89d0468e5fead4014926f6e8497bf5f 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -3,7 +3,7 @@ ====================================================================================*/ #include #include "options.h" /* Compilation switches */ -//#include "prot_fx.h" /* Function prototypes */ +// #include "prot_fx.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "cnst.h" /* Common constants */ @@ -203,6 +203,7 @@ void find_targets_ivas_fx( temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */ move16(); } + Scale_sig( temp, M, 1 ); // scaling to make belong function output alligned //Qnew syn_filt_fx( 0, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); @@ -292,3 +293,136 @@ void find_targets_ivas_fx( return; } + +void find_targets_ivas_new_fx( + const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/ + const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/ + const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/ + const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/ + Word16 tilt_fac, /* i : tilt factor Q15*/ + Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/ + Word16 *cn, /* o : target vector in residual domain Q_new*/ + Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/ +) +{ + Word16 i; + Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */ + Word16 scale, scaleq, j, d, s, s2, tmp; + Word16 Aqs[M + 1]; + Word32 h1_32[6 * L_SUBFR]; + Word16 sf; + Word64 Ltmp64; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move16(); +#endif + /*------------------------------------------------------------------------* + * Find the target vector for excitation search: + * + * |------| res[n] + * speech[n]---| A(z) |-------- + * |------| | |--------| error[n] |------| + * zero -- (-)--| 1/A(z) |-----------| W(z) |-- target + * exc |--------| |------| + * + * Instead of subtracting the zero-input response of filters from + * the weighted input speech, the above configuration is used to + * compute the target vector. + *-----------------------------------------------------------------------*/ + FOR( i = 0; i < M; i++ ) + { + temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */ + move16(); + } + + syn_filt_fx( 1, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); + + Residu3_fx( Ap, temp + M, xn, L_subfr, 0 ); /* xn in Q_new - 1 */ + + deemph_fx( xn, tilt_fac, L_subfr, mem_w0 ); /* xn in Q_new - 1 */ + + + /*-----------------------------------------------------------------* + * Find target in residual domain (cn[]) for innovation search + *--------------------------------------------------------------*/ + IF( cn != NULL ) + { + /* first half: xn[] --> cn[] */ + temp[0] = 0; + move16(); + preemph_copy_fx( xn, cn, tilt_fac, L_SUBFR / 2, temp ); + syn_filt_s_lc_fx( 1, Ap, cn, temp, L_SUBFR / 2 ); /* Q-1 -> Q-2 */ + Residu3_lc_fx( p_Aq, M, temp, cn, L_SUBFR / 2, 1 ); /* Q-2 -> Q-1 */ + Scale_sig( cn, L_SUBFR / 2, 1 ); + + /* second half: res[] --> cn[] (approximated and faster) */ + Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 ); + } + + /*---------------------------------------------------------------* + * Compute impulse response, h1[], of weighted synthesis filter * + *---------------------------------------------------------------*/ + + scale = norm_s( Ap[0] ); + scaleq = norm_s( p_Aq[0] ); + d = sub( scaleq, scale ); + IF( d >= 0 ) + { + Copy( p_Aq, Aqs, M + 1 ); /* Q12 */ + s = add( scaleq, 1 ); + s2 = shr( 16384, d ); + } + ELSE + { + Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */ + s = add( scale, 1 ); + s2 = 16384; + move16(); + } + + set32_fx( h1_32, 0, L_subfr ); + Overflow = 0; + move16(); + FOR( i = 0; i < M; i++ ) + { + Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ + FOR( j = 1; j <= i; j++ ) + { + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ + } + h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ + move32(); + } + + Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ + FOR( j = 1; j <= M; j++ ) + { + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ + } + h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */ + move32(); + + FOR( i = M + 1; i < L_subfr; i++ ) + { + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ + FOR( j = 2; j <= M; j++ ) + { + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ + } + h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ + move32(); + } + + sf = sub( L_norm_arr( h1_32, L_subfr ), 1 ); + Copy_Scale_sig32_16( h1_32, h1, L_subfr, sf ); // Q11 + sf + + tmp = 0; + move16(); + Deemph2( h1, tilt_fac, L_subfr, &tmp ); // Q11 + sf - 1 + + return; +} diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index ea71b09bc9f73f71ada928bed3bd19be2ef090dd..ed8ff425efa6840f334b4f8ad70a35ac646f95a9 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -93,11 +93,7 @@ void find_tilt_fx( } tmp = BASOP_Util_Divide3232_Scale( lp_bckr, hp_bckr, &e_tmp ); -#ifdef FIX_ISSUE_1152 Ltmp = L_shr_r_sat( L_deposit_h( tmp ), sub( 15, e_tmp ) ); -#else - Ltmp = L_shr_r( L_deposit_h( tmp ), sub( 15, e_tmp ) ); -#endif *bckr_tilt_lt = L_add( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) ); /* Q16 */ diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 0321cd763496bed2b50533c25200944947315a6d..0ccb31ccfcf7e1eeb00cecab9149fa111b45bc8b 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -428,7 +428,7 @@ void gain_enc_mless_fx( tmp1 = mult_r( G_PITCH_MAX_MINUS_MIN_TC192_Q13, div_s( 1, sub( shl( 1, nBits ), 1 ) ) ); /*Q13*/ /* set quantization step */ index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_TC192_Q14, tmp1, shl( 1, nBits ) ); move16(); - push_indice_fx( hBstr, IND_GAIN_PIT, index, nBits ); + push_indice( hBstr, IND_GAIN_PIT, index, nBits ); /* gain_code Q */ /**gain_code /= gcode0;*/ @@ -441,7 +441,7 @@ void gain_enc_mless_fx( } index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); - push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits2 ); + push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ } @@ -508,7 +508,7 @@ void gain_enc_mless_fx( * search for the best quantizer *-----------------------------------------------------------------*/ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size ); // Q0 - push_indice_fx( hBstr, IND_GAIN, index, nBits ); + push_indice( hBstr, IND_GAIN, index, nBits ); } /* *norm_gain_code = *gain_code / *gain_inov; */ @@ -1108,7 +1108,7 @@ void gain_enc_SQ_fx( tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */ index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) ); // Q0 - push_indice_fx( hBstr, IND_GAIN_PIT, index, nBits_pitch ); + push_indice( hBstr, IND_GAIN_PIT, index, nBits_pitch ); /* gain_code Q */ /* *gain_code /= gcode0; */ @@ -1121,7 +1121,7 @@ void gain_enc_SQ_fx( } index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_Q14, LG10_G_CODE_MAX_Q13, nBits_code, &expg ); - push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits_code ); + push_indice( hBstr, IND_GAIN_CODE, index, nBits_code ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); move32(); /*Q16*/ @@ -1601,7 +1601,7 @@ void gain_enc_tc_fx( *gain_code_fx = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ move32(); - push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits ); + push_indice( hBstr, IND_GAIN_CODE, index, nBits ); } ELSE { @@ -1632,7 +1632,7 @@ void gain_enc_tc_fx( L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 2 ) ); move32(); /* Q14 -> Q16 */ - push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits ); + push_indice( hBstr, IND_GAIN_CODE, index, nBits ); } ELSE /* nBits == 3 */ { @@ -1642,7 +1642,7 @@ void gain_enc_tc_fx( L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); move32(); /* Q14 -> Q16 */ - push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits ); + push_indice( hBstr, IND_GAIN_CODE, index, nBits ); } } @@ -2438,7 +2438,7 @@ void gain_enc_lbr_fx( *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); { - push_indice_fx( hBstr, IND_GAIN, index, nBits ); + push_indice( hBstr, IND_GAIN, index, nBits ); } return; } @@ -3223,7 +3223,7 @@ void gain_enc_amr_wb_fx( *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); - push_indice_fx( hBstr, IND_GAIN, index, nBits ); + push_indice( hBstr, IND_GAIN, index, nBits ); return; } diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index f943b104d5ba4e27f3e0b7bbac7061463fd111f4..2aa9a5dfff887f9e1fd502971505046bb588201e 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -90,13 +90,13 @@ Word16 gaus_encode_fx( exp_code = sub( exp_code, 18 + 6 ); /* exp: -18 (code in Q9), -6 (L_subfr = 64) */ Ltmp = Isqrt_lc( Ltmp, &exp_code ); - *gain_inov = extract_h( L_shl( Ltmp, sub( exp_code, 3 ) ) ); /* g_code_inov in Q12 */ + *gain_inov = extract_h( L_shl_sat( Ltmp, sub( exp_code, 3 ) ) ); /* g_code_inov in Q12 */ nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx]; /* Q0 */ move16(); /* low bound = -30; stepSize = 1.71875; inv_stepSize = 0.5818181 */ idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 ); /* Q0 */ - push_indice_fx( st_fx->hBstr, IND_GAIN, idx, nb_bits ); + push_indice( st_fx->hBstr, IND_GAIN, idx, nb_bits ); /*----------------------------------------------------------------* * Total excitation for Unvoiced coders @@ -638,8 +638,8 @@ void gauss2v_fx( idx = cod_2pos_fx( i, j, sign1, sign2, nvec ); /* Q0 */ move16(); - push_indice_fx( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 ); - push_indice_fx( hBstr, IND_TILT_FACTOR, index_delta, 3 ); + push_indice( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 ); + push_indice( hBstr, IND_TILT_FACTOR, index_delta, 3 ); /*----------------------------------------------------------------* * Find quantized gain @@ -979,13 +979,8 @@ void gauss2v_ivas_fx( /* eneri = round_fx(ener[i]) + round_fx(ener[j]) + 2*round_fx(dotprod) */ /* Use ScalingShift to stay aligned with ener[] */ eneri = L_shl( dotprod, 1 ); /* One left shift added for factor of 2 */ -#ifndef FIX_1298 - eneri = L_add( ener[i], eneri ); - eneri = L_add( ener[j], eneri ); /* Q31 */ -#else eneri = L_add_sat( ener[i], eneri ); eneri = L_add_sat( ener[j], eneri ); /* Q31 */ -#endif lo1 = L_Extract_lc( cor32, &hi1 ); cor2 = Sad_32( 0, hi1, lo1 ); /* Square + Add */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 1642d1253ca44a9da38178f806a166ebfd151297..77470c25546c948f20e5b3acb3de766be38742b8 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -82,16 +82,16 @@ void encod_audio_fx( test(); IF( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 ) { - push_indice_fx( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 ); + push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 ); } #endif IF( attack_flag > 0 ) { - push_indice_fx( hBstr, IND_GSC_ATTACK, 1, 1 ); + push_indice( hBstr, IND_GSC_ATTACK, 1, 1 ); } ELSE { - push_indice_fx( hBstr, IND_GSC_ATTACK, 0, 1 ); + push_indice( hBstr, IND_GSC_ATTACK, 0, 1 ); } @@ -105,7 +105,7 @@ void encod_audio_fx( IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( NE_16( st_fx->coder_type, INACTIVE ) && ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && GE_32( st_fx->total_brate, ACELP_13k20 ) ) || ( GT_16( st_fx->element_mode, EVS_MONO ) && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) ) { - push_indice_fx( hBstr, IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech, 1 ); + push_indice( hBstr, IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech, 1 ); } /*---------------------------------------------------------------* * Find and encode the number of subframes @@ -185,12 +185,12 @@ void encod_audio_fx( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) ) { - push_indice_fx( hBstr, IND_HF_NOISE, nb_subfr_flag, 2 ); + push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 2 ); } ELSE IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) { /* nb_subfr_flag can only have the value 0 or 1 */ - push_indice_fx( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 ); + push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 ); } } test(); @@ -227,7 +227,7 @@ void encod_audio_fx( move16(); } Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new ); - push_indice_fx( hBstr, IND_ES_PRED, indice, nb_bits ); + push_indice( hBstr, IND_ES_PRED, indice, nb_bits ); } enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp, @@ -290,7 +290,7 @@ void encod_audio_fx( { hGSCEnc->noise_lev = s_max( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 ); move16(); - push_indice_fx( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 ), 2 ); + push_indice( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 ), 2 ); } ELSE IF( st_fx->GSC_noisy_speech ) { @@ -300,7 +300,7 @@ void encod_audio_fx( } ELSE { - push_indice_fx( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP0 ), 3 ); + push_indice( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP0 ), 3 ); } /*---------------------------------------------------------------* @@ -439,8 +439,8 @@ void encod_audio_ivas_fx( move16(); T0_frac_tmp = 0; move16(); - Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); - hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0; + Copy_Scale_sig( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); + Copy_Scale_sig( &hLPDmem->mem_w0, &hGSCEnc->mem_w0_tmp_fx, 1, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); move16(); Es_pred = 0; move16(); @@ -763,8 +763,8 @@ void encod_audio_ivas_fx( /*--------------------------------------------------------------------------------------* * Updates *--------------------------------------------------------------------------------------*/ - - hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; /*_DIFF_FLOAT_FIX_ The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */ + Copy_Scale_sig( &hGSCEnc->mem_w0_tmp_fx, &hLPDmem->mem_w0, 1, sub( hLPDmem->q_mem_syn, sub( Q_new, 1 ) ) ); + /*_DIFF_FLOAT_FIX_ The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */ move16(); Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_new */ @@ -931,7 +931,7 @@ void gsc_enc_fx( WHILE( bit > 0 ) { i = s_min( bit, 16 ); - push_indice_fx( hBstr, IND_UNUSED, 0, i ); + push_indice( hBstr, IND_UNUSED, 0, i ); bit = sub( bit, i ); } /* Reorder Q bands */ diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index 60a3f8f50773d8e32359d71cc2ed14587e4d5a03..81e50d099bc1149557b3ae1395749726e41d0ea5 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -215,7 +215,7 @@ void enc_prm_side_Info_fx( IF( GT_16( hPlc_Ext->nBits, 1 ) ) { - push_next_indice_fx( st->hBstr, 1, 1 ); + push_next_indice( st->hBstr, 1, 1 ); diff_pitch = sub( hPlc_Ext->T0, hPlc_Ext->T0_4th ); test(); @@ -225,11 +225,11 @@ void enc_prm_side_Info_fx( move16(); } - push_next_indice_fx( st->hBstr, add( diff_pitch, search_range ), bits_per_subfr ); + push_next_indice( st->hBstr, add( diff_pitch, search_range ), bits_per_subfr ); } ELSE { - push_next_indice_fx( st->hBstr, 0, 1 ); + push_next_indice( st->hBstr, 0, 1 ); } return; diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 944cb26491e4e19ddd932fa474b2991618e7878e..300e31e8e10c5c4c8183e5a0a31dabc01275a88f 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -83,7 +83,6 @@ static Word16 hf_spectrum_sparseness_fx( crest_mod_fx = 0; move32(); maximum_l( A_fx, L_SPEC_HB, &Amax_fx ); -#ifdef NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO IF( Amax_fx == 0 ) { /* For all-zero input the crest is 1.0 */ @@ -94,7 +93,6 @@ static Word16 hf_spectrum_sparseness_fx( } ELSE { -#endif thr_fx = Mpy_32_32( Amax_fx, PEAK_THRESHOLD_FX ); /* Q12 */ movmean_fx = 0; /* avoid uninitialized warning */ move32(); @@ -160,9 +158,7 @@ static Word16 hf_spectrum_sparseness_fx( move32(); st->hHQ_core->crest_mod_lp_q = sub( Q12, inv_rms32_e ); move16(); -#ifdef NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO } -#endif *crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, ( *crest_lp_fx ) ), Mpy_32_32( ONE_IN_Q31 - HQ_CREST_FAC_SM_FX, crest_fx ) ); /* Q(st->hHQ_core->crest_lp_q) */ move32(); *crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, ( *crest_mod_lp_fx ) ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), crest_mod_fx ) ); /* Q(st->hHQ_core->crest_mod_lp_q) */ @@ -262,16 +258,16 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits { IF( GE_16( *hqswb_clas, HQ_GEN_SWB ) ) { - push_indice_fx( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas - 5, bits ); + push_indice( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas - 5, bits ); } ELSE { - push_indice_fx( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits ); + push_indice( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits ); } } ELSE { - push_indice_fx( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits ); + push_indice( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits ); } test(); @@ -347,7 +343,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits move16(); } /* write signalling info to the bitstream */ - push_indice_fx( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits ); + push_indice( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits ); IF( LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( *hqswb_clas, HQ_NORMAL ) ) { diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index f22218d13675013ebf72419bf23980144ac8e4fb..66430cb8e9d0c29403f7711e854942050f46b78a 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -229,12 +229,12 @@ void hq_core_enc_fx( { IF( Voicing_flag > 0 ) { - push_indice_fx( hBstr, IND_HQ_VOICING_FLAG, 1, 1 ); + push_indice( hBstr, IND_HQ_VOICING_FLAG, 1, 1 ); num_bits = sub( num_bits, 1 ); } ELSE { - push_indice_fx( hBstr, IND_HQ_VOICING_FLAG, 0, 1 ); + push_indice( hBstr, IND_HQ_VOICING_FLAG, 0, 1 ); num_bits = sub( num_bits, 1 ); } } @@ -278,13 +278,13 @@ void hq_core_enc_fx( WHILE( num_bits >= 16 ) { - push_indice_fx( hBstr, IND_UNUSED, 0, 16 ); + push_indice( hBstr, IND_UNUSED, 0, 16 ); num_bits = sub( num_bits, 16 ); } IF( num_bits != 0 ) { - push_indice_fx( hBstr, IND_UNUSED, 0, num_bits ); + push_indice( hBstr, IND_UNUSED, 0, num_bits ); } #ifdef ADD_IVAS_HQ_CODE if ( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) ) @@ -374,7 +374,6 @@ void HQ_core_enc_init_fx( hHQ_core->last_max_pos_pulse = 0; move16(); -#ifdef MSAN_FIX hHQ_core->crest_lp_fx = HQ_CREST_THRESHOLD_FX; /* Q28 */ move32(); hHQ_core->crest_lp_q = Q28; @@ -383,7 +382,6 @@ void HQ_core_enc_init_fx( move32(); hHQ_core->crest_mod_lp_q = Q29; move16(); -#endif return; } @@ -482,13 +480,9 @@ void hq_core_enc_ivas_fx( Q_audio = sub( Q16, q ); TCX_MDCT( wtda_audio_fx16, t_audio_fx, &Q_audio, left_overlap, sub( L_spec, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); Q_audio = sub( Q31, Q_audio ); -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ -#else - Copy_Scale_sig_16_32_DEPREC( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ -#endif - inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ - L_spec = l_spec_ext_tbl[st->bwidth]; /* Q0 */ + inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ + L_spec = l_spec_ext_tbl[st->bwidth]; /* Q0 */ is_transient = 0; move16(); move16(); diff --git a/lib_enc/hq_env_enc_fx.c b/lib_enc/hq_env_enc_fx.c index 5d47710ed9fe68624d4a61c83d4b9ed99b03a942..f033bd685b8e5c1c48bd3485a23bf2b82b560411 100644 --- a/lib_enc/hq_env_enc_fx.c +++ b/lib_enc/hq_env_enc_fx.c @@ -295,13 +295,13 @@ Word16 encode_envelope_indices_fx( /* o : Number of b test(); IF( EQ_16( flag_HQ2, LOW_RATE_HQ_CORE_TRAN ) || EQ_16( flag_HQ2, LOW_RATE_HQ_CORE ) ) { - push_indice_fx( hBstr, IND_HQ2_DENG_HMODE, *LCmode, BITS_DE_HMODE ); - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, difidx[0], BITS_DE_FCOMP ); + push_indice( hBstr, IND_HQ2_DENG_HMODE, *LCmode, BITS_DE_HMODE ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, difidx[0], BITS_DE_FCOMP ); } ELSE { - push_indice_fx( hBstr, IND_LC_MODE, *LCmode, 2 ); - push_indice_fx( hBstr, IND_YNRM, difidx[0], NORM0_BITS ); + push_indice( hBstr, IND_LC_MODE, *LCmode, 2 ); + push_indice( hBstr, IND_YNRM, difidx[0], NORM0_BITS ); } test(); @@ -331,7 +331,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b m = lshr( m, 1 ); /* Q0 */ } - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, v, r ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, v, r ); } } ELSE @@ -370,7 +370,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b move16(); } } - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, m, r ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, m, r ); prevj = j; move16(); } @@ -419,11 +419,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of b IF( EQ_16( flag_HQ2, LOW_RATE_HQ_CORE ) ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, m, r ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, m, r ); } ELSE { - push_indice_fx( hBstr, IND_YNRM, m, r ); + push_indice( hBstr, IND_YNRM, m, r ); } prevj = j; @@ -515,11 +515,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of b IF( flag_HQ2 == 0 ) { - push_indice_fx( hBstr, IND_YNRM, v, r ); + push_indice( hBstr, IND_YNRM, v, r ); } ELSE { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, v, r ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, v, r ); } } } @@ -536,14 +536,14 @@ Word16 encode_envelope_indices_fx( /* o : Number of b r = huffsizn[j]; /* Q0 */ move16(); - push_indice_fx( hBstr, IND_YNRM, m, r ); + push_indice( hBstr, IND_YNRM, m, r ); } } ELSE { FOR( i = 1; i < num_sfm; i++ ) { - push_indice_fx( hBstr, IND_YNRM, difidx[i], NORMI_BITS ); + push_indice( hBstr, IND_YNRM, difidx[i], NORMI_BITS ); } } } diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 1cd516b43ede33b5bb2659fe020e73be8976338e..705db9ecdf46b08c5bf6ce41e323890bffd7d01d 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -236,12 +236,12 @@ void hq_hr_enc_fx( IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) { nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */ - push_indice_fx( st_fx->hBstr, IND_NF_IDX, nf_idx, 2 ); + push_indice( st_fx->hBstr, IND_NF_IDX, nf_idx, 2 ); } ELSE { nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */ - push_indice_fx( st_fx->hBstr, IND_NF_IDX, nf_idx, 2 ); + push_indice( st_fx->hBstr, IND_NF_IDX, nf_idx, 2 ); } } /* updates */ diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 9aca0f6465fd0e06e899334619e5504490d4a930..af27806820f6ba1cf295ffb130523b8cbaa3a377 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -115,7 +115,7 @@ static void spt_shorten_domain_set_fx( move16(); } } - push_indice_fx( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 ); + push_indice( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 ); *bit_budget = sub( *bit_budget, 1 ); /* Q0 */ move16(); } @@ -313,7 +313,7 @@ void hq_lr_enc_fx( } /* write the classification information into the bitstream */ - push_indice_fx( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas_fx, 2 ); + push_indice( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas_fx, 2 ); ( *num_bits_fx ) = sub( *num_bits_fx, 2 ); move16(); IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) ) @@ -325,7 +325,7 @@ void hq_lr_enc_fx( ELSE { /* write the transient bit into the bitstream */ - push_indice_fx( st_fx->hBstr, IND_HQ2_SWB_CLAS, is_transient_fx, 1 ); + push_indice( st_fx->hBstr, IND_HQ2_SWB_CLAS, is_transient_fx, 1 ); /* subtract one bit for the transient flag */ ( *num_bits_fx ) = sub( ( *num_bits_fx ), 1 ); @@ -741,7 +741,7 @@ void hq_lr_enc_fx( /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ FOR( i = 0; i < 2; i++ ) { - push_indice_fx( st_fx->hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); + push_indice( st_fx->hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); } } ELSE IF( is_transient_fx == 0 && EQ_16( inner_frame_fx, L_FRAME16k ) ) @@ -970,7 +970,7 @@ void hq_lr_enc_fx( /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ FOR( i = 0; i < 2; i++ ) { - push_indice_fx( st_fx->hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); + push_indice( st_fx->hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); } } ELSE IF( EQ_16( st_fx->bwidth, SWB ) && EQ_16( hqswb_clas_fx, HQ_HARMONIC ) && ( EQ_32( L_bwe_br, HQ_16k40 ) || EQ_32( L_bwe_br, HQ_13k20 ) ) ) @@ -2213,7 +2213,7 @@ static Word16 small_symbol_enc_fx( /* o : bits /* Encoding LSB bit packing */ FOR( i = 0; i < BANDS; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); } } @@ -2526,74 +2526,74 @@ static Word16 large_symbol_enc_fx( /* o : bits /* Encoding MSB bits */ IF( *hLCmode0 == 0 ) { - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE, 0, BITS_DE_8SMODE ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE, 0, BITS_DE_8SMODE ); bits = BITS_DE_8SMODE; move16(); IF( cnt_outlyer0 == 0 ) { - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N0, 0, BITS_DE_8SMODE_N0 ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 0, BITS_DE_8SMODE_N0 ); bits = add( bits, BITS_DE_8SMODE_N0 ); IF( EQ_16( cnt_outlyer, 1 ) ) { /* 01 */ - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice_fx( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); + push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); bits = add( bits, BITS_DE_8SPOS ); - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); bits = add( bits, BITS_ABS_ENG ); } ELSE { /* 00 */ - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ } FOR( i = 0; i < pos_outlyer; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ } FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ } } ELSE IF( EQ_16( cnt_outlyer0, 1 ) ) { - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); bits = add( bits, BITS_DE_8SMODE_N0 ); IF( EQ_16( cnt_outlyer, 1 ) ) { - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice_fx( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); + push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); bits = add( bits, BITS_DE_8SPOS ); - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); bits = add( bits, BITS_ABS_ENG ); - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); bits = add( bits, BITS_ABS_ENG ); } ELSE { - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); bits = add( bits, BITS_ABS_ENG ); /* Q0 */ } FOR( i = 1; i < pos_outlyer; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ } FOR( i = pos_outlyer + 1; i < BANDS; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ } } @@ -2601,12 +2601,12 @@ static Word16 large_symbol_enc_fx( /* o : bits ELSE { bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ - push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); - push_indice_fx( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); + push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); + push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); FOR( i = 0; i < BANDS; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ } @@ -2614,7 +2614,7 @@ static Word16 large_symbol_enc_fx( /* o : bits { FOR( i = 0; i < BANDS; ++i ) { - push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); } /*bits += BANDS * lsbdepth1; */ bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ @@ -3115,7 +3115,7 @@ static Word16 band_energy_quant_fx( { deng_cmode = 0; move16(); - push_indice_fx( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); + push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 ); deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ } @@ -3124,7 +3124,7 @@ static Word16 band_energy_quant_fx( /* setting energy difference coding mode and storing it */ deng_cmode = 1; move16(); - push_indice_fx( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); + push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ @@ -3479,7 +3479,7 @@ static Word16 p2a_threshold_quant_fx( move16(); } - push_indice_fx( hBstr, IND_HQ2_P2A_FLAGS, p2a_flags_fx[k], 1 ); + push_indice( hBstr, IND_HQ2_P2A_FLAGS, p2a_flags_fx[k], 1 ); j = add( j, 1 ); } @@ -3768,7 +3768,7 @@ static void mdct_spectrum_fine_gain_enc_fx( move16(); } - push_indice_fx( st_fx->hBstr, IND_HQ2_SUBBAND_GAIN, imin_fx, gqbits ); + push_indice( st_fx->hBstr, IND_HQ2_SUBBAND_GAIN, imin_fx, gqbits ); } return; diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index b06a1734dd6e65a8e17e029efdc5d5bb6a1f0347..a0acd0bfd63e5b6c69141b353503c9ee3a8f162f 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -335,7 +335,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits q_noise_level[i] = 0; move16(); } - push_indice_fx( st_fx->hBstr, IND_HVQ_BWE_NL, q_noise_level_idx[i], 2 ); + push_indice( st_fx->hBstr, IND_HVQ_BWE_NL, q_noise_level_idx[i], 2 ); bits_used = add( bits_used, 2 ); noise_level[i] = q_noise_level[i]; /* in Q15 */ diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index fc7c32fdbd7119867a844145f82b2c742ab98662..bfb4a7423ed63994a1b9dc655feb3880858bd88f 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -716,13 +716,8 @@ static void IGF_CalculateEnvelope_ivas_fx( Word32 mean_y_fx_tmp = 0; move32(); mean_xy_fx = mean_x2_fx = 0; -#ifdef FIX_ISSUE_1214 mean_x_e = 15; mean_xy_e = mean_y_e = mean_x2_e = 31; -#else - mean_x_e = mean_y_e = 15; - mean_xy_e = mean_x2_e = 31; -#endif move16(); move16(); move16(); @@ -738,21 +733,12 @@ static void IGF_CalculateEnvelope_ivas_fx( mean_x_fx = add( mean_x_fx, x ); /*Q0*/ mean_x2_fx = L_add( mean_x2_fx, L_mult0( x, x ) ); /*Q0*/ -#ifdef FIX_ISSUE_1214 /*y = 20.f * log10f( max( 1.f, powerSpectrum[i] ) );*/ IF( LE_64( W_deposit32_l( pPowerSpectrum_fx[sb] ), W_shl( 1, ( sub( 31, e_ps[sb] ) ) ) ) ) { y = 0; move16(); } -#else - - /*y = 20 * (int16_t) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/ - IF( LT_32( pPowerSpectrum_fx[sb], 1 ) ) - { - y = imult1616( 20, ( -18 /* log10f(1e-018f) */ ) ); - } -#endif ELSE { y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/ @@ -1258,21 +1244,12 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); } } -#ifdef FIX_ISSUE_1214 tmp_tb_fx = shr_sat( tmp_tb_fx, sub( 2, tmp_tb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ tmp_sb_fx = shr_sat( tmp_sb_fx, sub( 2, tmp_sb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ hPrivateData->SFM_tb_fx[sfb] = add_sat( tmp_tb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], sub( 2, hPrivateData->prevSFB_FIR_TB_e[sfb] ) ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], sub( 3, hPrivateData->prevSFB_IIR_TB_e[sfb] ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ hPrivateData->SFM_tb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_tb_fx[sfb] ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/ hPrivateData->SFM_sb_fx[sfb] = add_sat( tmp_sb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], sub( 2, hPrivateData->prevSFB_FIR_SB_e[sfb] ) ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], sub( 3, hPrivateData->prevSFB_IIR_SB_e[sfb] ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ hPrivateData->SFM_sb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_sb_fx[sfb] ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/ -#else - tmp_tb_fx = shl_sat( tmp_tb_fx, sub( 2, tmp_tb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ - tmp_sb_fx = shl_sat( tmp_sb_fx, sub( 2, tmp_sb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ - hPrivateData->SFM_tb_fx[sfb] = add_sat( tmp_tb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], sub( 2, tmp_tb_e ) ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], sub( 3, tmp_tb_e ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ - hPrivateData->SFM_tb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_tb_fx[sfb] ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/ - hPrivateData->SFM_sb_fx[sfb] = add_sat( tmp_sb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], sub( 2, tmp_sb_e ) ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], sub( 3, tmp_sb_e ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ - hPrivateData->SFM_sb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_sb_fx[sfb] ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/ -#endif move16(); move16(); move16(); @@ -2452,7 +2429,7 @@ void IGFEncSetMode_ivas_fx( * * IGF bitstream concatenation for TCX10 modes *-------------------------------------------------------------------*/ - +#ifndef HARM_PUSH_BIT /* Float code */ void IGFEncConcatenateBitstream( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ const Word16 bsBits, /* i : number of IGF bits written to list of indices */ @@ -2510,7 +2487,7 @@ move16(); return; } - +#endif /*-------------------------------------------------------------------* * IGFEncResetTCX10BitCounter_ivas_fx() @@ -2540,10 +2517,8 @@ void IGFEncResetTCX10BitCounter_ivas_fx( *-------------------------------------------------------------------*/ void IGFEncApplyMono_ivas_fx( - Encoder_State *st, /* i : Encoder state */ -#ifdef MSAN_FIX - Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ -#endif + Encoder_State *st, /* i : Encoder state */ + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ Word16 e_mdct, /* i : exponent of pMDCTspectrum */ @@ -2563,9 +2538,7 @@ void IGFEncApplyMono_ivas_fx( Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX]; -#ifdef MSAN_FIX set32_fx( common_pPowerSpectrum_fx, 0, N_MAX + L_MDCT_OVLP_MAX ); -#endif Word16 common_pPowerSpectrum_exp = MIN16B; move16(); @@ -2624,20 +2597,12 @@ void IGFEncApplyMono_ivas_fx( IF( pPowerSpectrumParameter_fx ) { -#ifndef MSAN_FIX - FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) -#else FOR( Word16 i = 0; i < powerSpectrum_len; i++ ) -#endif { common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, pPowerSpectrumParameter_exp[i] ); } -#ifndef MSAN_FIX - FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) -#else FOR( Word16 i = 0; i < powerSpectrum_len; i++ ) -#endif { common_pPowerSpectrum_fx[i] = L_shl( pPowerSpectrumParameter_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) ); move16(); @@ -2661,8 +2626,11 @@ void IGFEncApplyStereo_fx( const Word16 igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ + Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ const Word16 frameno, /* i : flag indicating index of current subfr. */ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ const Word32 element_brate, /* i : element bitrate */ @@ -2726,7 +2694,9 @@ void IGFEncApplyStereo_fx( last_core_acelp = extract_l( EQ_16( sts[ch]->last_core, ACELP_CORE ) ); IGF_UpdateInfo( hIGFEnc[ch], igfGridIdx ); - IGF_CalculateStereoEnvelope_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], inv_spectrum_fx[ch][frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], pPowerSpectrumParameterMsInv_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp ); + IGF_CalculateStereoEnvelope_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], inv_spectrum_fx[ch][frameno], + exp_inv_spectrum_fx[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrum_fx[ch], pPowerSpectrumParameterMsInv_fx[ch], + exp_pPowerSpectrumMsInv_fx[ch], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp ); IF( EQ_16( sts[ch]->core, TCX_20_CORE ) ) { @@ -2737,11 +2707,11 @@ void IGFEncApplyStereo_fx( pPowerSpectrumParameter_fx[ch] = NULL; } - set16_fx( exp_pPowerSpectrum, sts[ch]->hTcxEnc->spectrum_e[frameno], L_FRAME48k ); + set16_fx( exp_pPowerSpectrum, exp_pPowerSpectrum_fx[ch], L_FRAME48k ); IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &exp_pPowerSpectrum[0], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode ); - IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, mct_on ); + IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrum_fx[ch], igfGridIdx, mct_on ); } return; } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index cc48408763babac36e5f43a16ffc5c3777a222a1..f508b313f61988d03b1f5682a0b01de6d276c3ad 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -1449,7 +1449,7 @@ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, nb_bits_written ); return; } - +#ifndef HARM_PUSH_BIT /* old bitstream */ /**********************************************************************/ /* IGF bitsream concatenation for TCX10 modes **************************************************************************/ @@ -1475,7 +1475,7 @@ void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /** move16(); return; } - +#endif /**********************************************************************/ /* IGF reset bitsream bit counter for TCX10 modes **************************************************************************/ @@ -1513,13 +1513,13 @@ Word16 IGFEncWriteConcatenatedBitstream_fx( tmp = shr( hPrivateData->igfBitstreamBits, 3 ); FOR( i = 0; i < tmp; i++ ) { - push_next_indice_fx( hBstr, pBitstream[i], 8 ); + push_next_indice( hBstr, pBitstream[i], 8 ); } bitsLeft = s_and( hPrivateData->igfBitstreamBits, 0x7 ); IF( bitsLeft > 0 ) { - push_next_indice_fx( hBstr, shr( pBitstream[i], sub( 8, bitsLeft ) ), bitsLeft ); + push_next_indice( hBstr, shr( pBitstream[i], sub( 8, bitsLeft ) ), bitsLeft ); } return hInstance->infoTotalBitsWritten; diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c index 8659d53a166cb2a6f155bb85c4f3025c780424a7..ed52349dc034d32523fcd2cc412d5f27b2da50aa 100644 --- a/lib_enc/igf_scf_enc_fx.c +++ b/lib_enc/igf_scf_enc_fx.c @@ -358,7 +358,7 @@ Word16 IGFSCFEncoderEncode_fx( { FOR( i = 0; i < hPublicData->ptrBitIndex; ++i ) { - push_next_indice_fx( hBstr, ptr[i], 1 ); + push_next_indice( hBstr, ptr[i], 1 ); } } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 6744ca07a631e214bc8e66fa9cadb054ad04f3d9..21a99add798b804e4456ac8834e30ba70f93d65e 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -6,7 +6,7 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ +// #include "prot_fx.h" /* Function prototypes */ #include "stl.h" #include "ivas_cnst.h" #include "ivas_error.h" @@ -20,6 +20,7 @@ * * Initialization of state variables *-----------------------------------------------------------------------*/ +#if 1 ivas_error init_encoder_fx( Encoder_State *st_fx /* i/o: Encoder static variables structure */ ) @@ -946,6 +947,7 @@ ivas_error init_encoder_fx( move32(); return error; } +#endif /*-----------------------------------------------------------------------* * LPDmem_enc_init_fx() * @@ -998,16 +1000,18 @@ void LPDmem_enc_init_ivas_fx( set16_fx( hLPDmem->mem_syn2, 0, M ); set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); set16_fx( hLPDmem->mem_syn3, 0, M ); + hLPDmem->q_lpd_old_exc = Q15; + move16(); hLPDmem->q_lpd_syn = Q15; move16(); + hLPDmem->q_mem_syn = Q15; + move16(); hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; move16(); hLPDmem->gc_threshold = 0; move32(); - hLPDmem->q_mem_syn = Q15; - move16(); hLPDmem->dm_fx.prev_state = 0; move16(); /* This corresponds to st_fx->dispMem in FLP */ hLPDmem->dm_fx.prev_gain_code = 0; @@ -1019,14 +1023,6 @@ void LPDmem_enc_init_ivas_fx( move16(); } - hLPDmem->q_lpd_syn = Q15; - move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); - hLPDmem->q_mem_syn = Q15; - move16(); - - return; } @@ -1398,11 +1394,7 @@ ivas_error init_encoder_ivas_fx( st->exp_buf_wspeech_enc = 0; move16(); /* initializations */ -#ifndef MSAN_FIX - set32_fx( st->Bin_E_old_fx, 0, shr( L_FFT, 2 ) ); -#else set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); -#endif st->q_Bin_E_old = Q31; move16(); set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); @@ -1508,14 +1500,7 @@ ivas_error init_encoder_ivas_fx( IF( st->element_mode == EVS_MONO ) { /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */ - /* - if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); - } - */ st->hVAD_CLDFB = &st->vad_st; - vad_init_fx( st->hVAD_CLDFB ); } ELSE @@ -1680,9 +1665,23 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /* open analysis for input SR */ + st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + + if ( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st->input_Fs ), st->input_frame_fx ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE { - return error; + + IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) + { + return error; + } } } ELSE @@ -1794,11 +1793,20 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) + IF( st->element_mode == EVS_MONO ) + { + if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, CLDFB_getNumChannels( 16000 ), L_FRAME16k ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE { - return error; + IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) + { + return error; + } } - InitSWBencBuffer_ivas_fx( st ); ResetSHBbuffer_Enc_fx( st ); } @@ -1821,10 +1829,8 @@ ivas_error init_encoder_ivas_fx( } fd_bwe_enc_init_fx( st->hBWE_FD ); -#ifdef MSAN_FIX st->Q_old_wtda = 0; move16(); -#endif } ELSE { @@ -2069,7 +2075,6 @@ ivas_error init_encoder_ivas_fx( set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st->totalNoise_increase_len = 0; move16(); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; IF( hTcxEnc != NULL ) { @@ -2080,10 +2085,8 @@ ivas_error init_encoder_ivas_fx( move32(); st->currEnergyHF_e_fx = 0; move16(); -#ifdef MSAN_FIX st->prevEnergyHF_fx = 0; move32(); -#endif /* Initialize TCX */ @@ -2097,7 +2100,6 @@ ivas_error init_encoder_ivas_fx( st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); /* Initialize ACELP */ -#endif init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); IF( st->hLPDmem != NULL ) @@ -2160,7 +2162,13 @@ ivas_error init_encoder_ivas_fx( } ELSE { +#ifndef HARM_ENC_INIT InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); +#else + InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ), + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), + &st->transientDetection ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 46bec5f4d9e8b41563b4ab1ca6246fdf2dd54249..fe22ee398de7c7a3e1652e2229cdcd756af00fca 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -89,9 +89,7 @@ Word16 inov_encode_fx( Word16 Rw[L_SUBFR]; Word16 acelpautoc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) last_L_frame; -#endif stack_pulses = 0; move16(); @@ -422,19 +420,16 @@ Word16 inov_encode_ivas_fx( { acelpautoc = 1; move16(); - + Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_SUBFR ); /* h2: Q11, Rw: (Rw_e)Q */ - // Word16 Rw_e = E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 ); corr_hh_ivas_fx( h2, Rw, &Rw_q, L_subfr ); // Q(Rw) = Q11-2 - - E_ACELP_conv_ivas_fx( xn2, h2, cn ); // Qcn = Qxn2 + E_ACELP_conv_ivas_fx( xn2, h2, cn ); // Qcn = Qxn2 /* dn_e -> Rw_e*Q_xn */ - // Scale_sig(Rw, L_SUBFR, sub(5, Rw_e)); //Q9 j = E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 ); Qdn = add( add( Qxn, Rw_q ), add( j, 1 ) ); - // Scale_sig(Rw, L_subfr, -3); //Q9->Q6 } ELSE { @@ -443,7 +438,8 @@ Word16 inov_encode_ivas_fx( updt_tar_fx( cn, cn, &exc[i_subfr], gain_pit, L_subfr ); /* scaling of cn[] to limit dynamic at 12 bits */ Scale_sig( cn, L_subfr, shift ); - + Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1 } @@ -611,7 +607,7 @@ Word16 inov_encode_ivas_fx( } ELSE { - acelp_fast_fx( hBstr, nBits, dn, Qdn, cn, h2, code, y2, L_subfr ); + acelp_fast_fx( hBstr, nBits, dn, Qdn, cn, Q_new, h2, code, y2, L_subfr ); } } ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[idx2], 7 ) ) || ( st_fx->idchan == 0 && LE_16( st_fx->acelp_cfg.fixed_cdk_index[idx2], 3 ) ) ) @@ -622,7 +618,7 @@ Word16 inov_encode_ivas_fx( } ELSE { - acelp_fast_fx( hBstr, st_fx->acelp_cfg.fixed_cdk_index[idx2], dn, Qdn, cn, h2, code, y2, L_SUBFR ); + acelp_fast_fx( hBstr, st_fx->acelp_cfg.fixed_cdk_index[idx2], dn, Qdn, cn, Q_new, h2, code, y2, L_SUBFR ); } } ELSE diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c index 4851ed15552285743d2dcc88e6dda9ba61a7a2be..d58998565bdb404e232a6b7b8c5e0318eae1c3a4 100644 --- a/lib_enc/isf_enc_amr_wb_fx.c +++ b/lib_enc/isf_enc_amr_wb_fx.c @@ -173,11 +173,11 @@ static void qisf_ns_28b_fx( indice[4] = add( sub_VQ_fx( &isf[12], dico5_ns_28b_fx + 4, 4, DICO5_NS_28b - 1, &tmp ), 1 ); /* First vector has a problem -> do not allow */ move16(); /* write indices to array */ - push_indice_fx( hBstr, IND_ISF_0_0, indice[0], 6 ); - push_indice_fx( hBstr, IND_ISF_0_1, indice[1], 6 ); - push_indice_fx( hBstr, IND_ISF_0_2, indice[2], 6 ); - push_indice_fx( hBstr, IND_ISF_0_3, indice[3], 5 ); - push_indice_fx( hBstr, IND_ISF_0_4, indice[4], 5 ); + push_indice( hBstr, IND_ISF_0_0, indice[0], 6 ); + push_indice( hBstr, IND_ISF_0_1, indice[1], 6 ); + push_indice( hBstr, IND_ISF_0_2, indice[2], 6 ); + push_indice( hBstr, IND_ISF_0_3, indice[3], 5 ); + push_indice( hBstr, IND_ISF_0_4, indice[4], 5 ); /* decoding the ISFs */ disf_ns_28b_fx( indice, isf ); @@ -305,11 +305,11 @@ static void qisf_2s_36b_fx( indice[0] = Indirect_dico1[indice[0]]; move16(); /* Make interoperable with G722.2 */ - push_indice_fx( hBstr, IND_ISF_0_0, indice[0], 8 ); - push_indice_fx( hBstr, IND_ISF_0_1, indice[1], 8 ); - push_indice_fx( hBstr, IND_ISF_1_0, indice[2], 7 ); - push_indice_fx( hBstr, IND_ISF_1_1, indice[3], 7 ); - push_indice_fx( hBstr, IND_ISF_1_2, indice[4], 6 ); + push_indice( hBstr, IND_ISF_0_0, indice[0], 8 ); + push_indice( hBstr, IND_ISF_0_1, indice[1], 8 ); + push_indice( hBstr, IND_ISF_1_0, indice[2], 7 ); + push_indice( hBstr, IND_ISF_1_1, indice[3], 7 ); + push_indice( hBstr, IND_ISF_1_2, indice[4], 6 ); return; } @@ -442,13 +442,13 @@ static void qisf_2s_46b_fx( indice[0] = Indirect_dico1[indice[0]]; move16(); /* Make interoperable with G722.2 */ - push_indice_fx( hBstr, IND_ISF_0_0, indice[0], 8 ); - push_indice_fx( hBstr, IND_ISF_0_1, indice[1], 8 ); - push_indice_fx( hBstr, IND_ISF_1_0, indice[2], 6 ); - push_indice_fx( hBstr, IND_ISF_1_1, indice[3], 7 ); - push_indice_fx( hBstr, IND_ISF_1_2, indice[4], 7 ); - push_indice_fx( hBstr, IND_ISF_1_3, indice[5], 5 ); - push_indice_fx( hBstr, IND_ISF_1_4, indice[6], 5 ); + push_indice( hBstr, IND_ISF_0_0, indice[0], 8 ); + push_indice( hBstr, IND_ISF_0_1, indice[1], 8 ); + push_indice( hBstr, IND_ISF_1_0, indice[2], 6 ); + push_indice( hBstr, IND_ISF_1_1, indice[3], 7 ); + push_indice( hBstr, IND_ISF_1_2, indice[4], 7 ); + push_indice( hBstr, IND_ISF_1_3, indice[5], 5 ); + push_indice( hBstr, IND_ISF_1_4, indice[6], 5 ); return; } diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index cacbcabd36f4c3d36cc52d6c3bcd4ddf9c6daab4..3c62a0d184820697ae3019b943faf66aba8da570 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -118,14 +118,12 @@ ivas_error ivas_core_enc_fx( set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); -#ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k ); } set16_fx( shb_speech_fx, 0, L_FRAME16k ); -#endif push_wmops( "ivas_core_enc" ); @@ -215,7 +213,6 @@ ivas_error ivas_core_enc_fx( /*---------------------------------------------------------------------* * Pre-processing, incl. Decision matrix *---------------------------------------------------------------------*/ -#ifdef MSAN_FIX IF( st->cldfbAnaEnc ) { Word16 tmp_shift = L_norm_arr( enerBuffer_fx[n], st->cldfbAnaEnc->no_channels ); @@ -227,16 +224,6 @@ ivas_error ivas_core_enc_fx( move16(); } } -#else - Word16 tmp_shift = getScaleFactor32( enerBuffer_fx[n], CLDFB_NO_CHANNELS_MAX ); - tmp_shift = sub( tmp_shift, 5 ); - IF( tmp_shift < 0 ) - { - scale_sig32( enerBuffer_fx[n], CLDFB_NO_CHANNELS_MAX, tmp_shift ); - enerBuffer_fx_exp[n] = sub( enerBuffer_fx_exp[n], tmp_shift ); - move16(); - } -#endif Scale_sig( fft_buff_fx[n], ( 2 * L_FFT ), -1 ); // To create 1 headroom for addition of magnitude square spectrum // fft_buff_fx_exp = add(fft_buff_fx_exp,1); @@ -457,13 +444,6 @@ ivas_error ivas_core_enc_fx( st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc; move16(); } - - Scale_sig( st->input_fx, input_frame, negate( st->q_inp ) ); // Q0 - Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); // Q0 - st->q_old_inp = 0; - move16(); - st->q_inp = 0; - move16(); } Word16 Q_spec_old[2], L_spec; Q_spec_old[0] = hCPE->hCoreCoder[0]->hTcxEnc->spectrum_long_e; @@ -636,11 +616,6 @@ ivas_error ivas_core_enc_fx( { st = sts[n]; - Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); // Q0 - Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); // Q0 - st->q_old_inp = st->q_inp = 0; - move16(); - move16(); IF( st->hBWE_FD != NULL ) { Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( negate( 1 ), st->Q_old_wtda ) ); // Q(-1) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 45098926ecb19c6bca014e525e975845f050359f..0d6a5901a1f81f12be0f48ff345d024303d55ca7 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -56,7 +56,7 @@ #define SCE_SMC_THR 16000 -static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 *enerBuffer_dft_e ); +static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] ); #ifdef IVAS_FIXED_ENC static void calculate_energy_buffer_fx( CPE_ENC_HANDLE hCPE, Word64 enerBuffer_dft_fx[], Word16 *enerBuffer_dft_q_fx, const Word16 no_channels, const Word32 input_Fs ); @@ -87,7 +87,7 @@ ivas_error pre_proc_front_ivas_fx( 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_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/ 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*/ @@ -125,16 +125,14 @@ ivas_error pre_proc_front_ivas_fx( 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 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*/ -#endif - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ + const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ Word16 *Q_new #ifdef DEBUG_MODE_INFO , @@ -151,26 +149,6 @@ ivas_error pre_proc_front_ivas_fx( { st = hCPE->hCoreCoder[n]; } - Word16 old_inp_12k8_e; - Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, 240 ); - Scale_sig( st->old_inp_12k8_fx, 240, shift ); /* exp(st->exp_old_inp_12k8 - shift) */ - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); - shift = getScaleFactor16( old_inp_12k8_fx, 496 ); - Scale_sig( old_inp_12k8_fx, 496, shift ); /* exp(16 - shift) */ - old_inp_12k8_e = sub( Q16, shift ); - IF( GT_16( old_inp_12k8_e, st->exp_old_inp_12k8 ) ) - { - Scale_sig( st->old_inp_12k8_fx, 240, sub( st->exp_old_inp_12k8, old_inp_12k8_e ) ); /* exp(old_inp_12k8_e) */ - st->exp_old_inp_12k8 = old_inp_12k8_e; - move16(); - } - ELSE - { - Scale_sig( old_inp_12k8_fx, 496, sub( old_inp_12k8_e, st->exp_old_inp_12k8 ) ); /* exp(st->exp_old_inp_12k8) */ - old_inp_12k8_e = st->exp_old_inp_12k8; - move16(); - } Word16 q_tmpN_LR[CPE_CHANNELS]; Word16 q_tmpE_LR[CPE_CHANNELS]; @@ -212,10 +190,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 new_inp_out_size; Word16 Q_new_inp; Word16 mem_decim_size; -#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING - Word16 Q_new; - Word16 corr_shift_fx; -#endif Word16 dummy_fx; Word16 ncharX_fx; @@ -248,6 +222,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word16 res_cod_SNR_M_fx_e[STEREO_DFT_BAND_MAX]; Word16 Qfact_PS, q_lf_E_fx; + Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX]; #ifdef DEBUG_MODE_INFO Word32 *in_buff_temp; Word16 in_q_temp; @@ -257,51 +232,29 @@ ivas_error pre_proc_front_ivas_fx( temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); set16_fx( fft_buff_fx, 0, 512 ); - IF( hSCE != NULL ) - { -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( hSCE->hCoreCoder[n]->input_fx, hSCE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32_no_sat( hSCE->hCoreCoder[n]->input_fx - input_frame, hSCE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_old_inp ) ); /* Q11 */ -#else - Copy_Scale_sig_16_32_DEPREC( hSCE->hCoreCoder[n]->input_fx, hSCE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32_DEPREC( hSCE->hCoreCoder[n]->input_fx - input_frame, hSCE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_old_inp ) ); /* Q11 */ -#endif - hSCE->hCoreCoder[n]->q_inp32 = Q11; - move16(); - Scale_sig( hSCE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_inp ) ); /* Q(-1) */ - hSCE->hCoreCoder[n]->q_inp = -1; - move16(); - Scale_sig( hSCE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_old_inp ) ); /* Q(-1) */ - hSCE->hCoreCoder[n]->q_old_inp = -1; - move16(); + Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); + Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) + Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); + Q_min = s_max( -1, Q_min ); + Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min + st->q_inp = Q_min; + move16(); + st->q_old_inp = Q_min; + move16(); #ifdef DEBUG_MODE_INFO + IF( hSCE != NULL ) + { in_buff_temp = hSCE->hCoreCoder[n]->input32_fx; in_q_temp = hSCE->hCoreCoder[n]->q_inp32; -#endif } ELSE { -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->input_fx, hCPE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->input_fx - input_frame, hCPE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_old_inp ) ); /* Q11 */ -#else - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[n]->input_fx, hCPE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[n]->input_fx - input_frame, hCPE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_old_inp ) ); /* Q11 */ -#endif - hCPE->hCoreCoder[n]->q_inp32 = Q11; - move16(); - Scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_inp ) ); /* Q(-1) */ - hCPE->hCoreCoder[n]->q_inp = -1; - move16(); - Scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_old_inp ) ); /* Q(-1) */ - hCPE->hCoreCoder[n]->q_old_inp = -1; - move16(); -#ifdef DEBUG_MODE_INFO in_buff_temp = hCPE->hCoreCoder[n]->input32_fx; in_q_temp = hCPE->hCoreCoder[n]->q_inp32; -#endif } +#endif + #ifdef DEBUG_MODE_INFO if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) ) @@ -316,16 +269,14 @@ ivas_error pre_proc_front_ivas_fx( } #endif -#ifdef MSAN_FIX FOR( Word16 k = 0; k < CLDFB_NO_COL_MAX; k++ ) { set32_fx( realBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( imagBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); } -#endif Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; - Word16 Q_to_be_looked_into = -1; + Word16 Q_inp_const = -1; move16(); Word16 headroom = 0, preemp_len = 0, inp_max = 0; move16(); @@ -365,9 +316,6 @@ ivas_error pre_proc_front_ivas_fx( IF( hSCE != NULL ) { st = hSCE->hCoreCoder[n]; -#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING - signal_in = hSCE->hCoreCoder[n]->input; -#endif signal_in_fx = hSCE->hCoreCoder[n]->input_fx; /* hSCE->hCoreCoder[n]->q_inp */ signal32_in_fx = hSCE->hCoreCoder[n]->input32_fx; /* hSCE->hCoreCoder[n]->q_inp32 */ element_mode = IVAS_SCE; @@ -381,9 +329,6 @@ ivas_error pre_proc_front_ivas_fx( ELSE /* CPE */ { st = hCPE->hCoreCoder[n]; -#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING - signal_in = hCPE->hCoreCoder[n]->input; -#endif signal_in_fx = hCPE->hCoreCoder[n]->input_fx; /* hSCE->hCoreCoder[n]->q_inp */ signal32_in_fx = hCPE->hCoreCoder[n]->input32_fx; /* hSCE->hCoreCoder[n]->q_inp32 */ element_mode = hCPE->element_mode; @@ -480,11 +425,6 @@ ivas_error pre_proc_front_ivas_fx( L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */ move16(); - Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_to_be_looked_into, sub( Q15, old_inp_12k8_e ) ) ); /* Q_to_be_looked_into*/ - old_inp_12k8_e = sub( Q15, Q_to_be_looked_into ); - Scale_sig( st->old_inp_12k8_fx, 240, sub( Q_to_be_looked_into, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* Q_to_be_looked_into */ - st->exp_old_inp_12k8 = sub( Q15, Q_to_be_looked_into ); - move16(); new_inp_12k8_fx = old_inp_12k8_fx + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */ inp_12k8_fx = new_inp_12k8_fx - L_look; /* pointer to the current frame of input signal in 12.8kHz core */ @@ -495,15 +435,15 @@ ivas_error pre_proc_front_ivas_fx( IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8 ); /* exp(st->exp_old_inp_12k8) */ + Copy_Scale_sig( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* st->q_inp */ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { - Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ) ); /* exp(st->exp_old_inp_12k8) */ + Copy_Scale_sig( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ), sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* st->q_inp */ } ELSE { - Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT ); /* exp(st->exp_old_inp_12k8) */ + Copy_Scale_sig( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* st->q_inp */ } Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); /* exp(st->exp_old_wsp) */ @@ -528,16 +468,22 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_SCE ) || ( EQ_16( element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - analysisCldfbEncoder_ivas_fx( st, signal32_in_fx, 11, input_frame, realBuffer_fx, imagBuffer_fx, realBuffer16, imagBuffer16, enerBuffer_fx, enerBuffer_fx_exp, &cldfbScale ); + scale_sig32( signal32_in_fx - input_frame, input_frame_full, sub( 11, st->q_inp32 ) ); // Q11 + st->q_inp32 = 11; + move16(); + analysisCldfbEncoder_ivas_fx( st, signal32_in_fx, st->q_inp32, input_frame, realBuffer_fx, imagBuffer_fx, realBuffer16, imagBuffer16, enerBuffer_fx, enerBuffer_fx_exp, &cldfbScale ); } ELSE IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && st->idchan == 0 ) || ( EQ_16( st->idchan, 1 ) && st->tdm_LRTD_flag ) ) { /* cldfb analysis only for pri. channel */ - analysisCldfbEncoder_ivas_fx( st, signal32_in_fx - NS2SA_FX2( input_Fs, L_MEM_RECALC_TBE_NS ), 11, input_frame, realBuffer_fx, imagBuffer_fx, realBuffer16, imagBuffer16, enerBuffer_fx, enerBuffer_fx_exp, &cldfbScale ); + scale_sig32( signal32_in_fx - input_frame, input_frame_full, sub( 11, st->q_inp32 ) ); // Q11 + st->q_inp32 = 11; + move16(); + analysisCldfbEncoder_ivas_fx( st, signal32_in_fx - NS2SA_FX2( input_Fs, L_MEM_RECALC_TBE_NS ), st->q_inp32, input_frame, realBuffer_fx, imagBuffer_fx, realBuffer16, imagBuffer16, enerBuffer_fx, enerBuffer_fx_exp, &cldfbScale ); } ELSE IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - calculate_energy_buffer_ivas_fx( hCPE, enerBuffer_fx, st->cldfbAnaEnc->no_channels, input_Fs, enerBuffer_fx_exp ); + calculate_energy_buffer_ivas_fx( hCPE, enerBuffer_fx, st->cldfbAnaEnc->no_channels, input_Fs, enerBuffer_fx_exp_buf ); } ELSE { @@ -554,16 +500,17 @@ ivas_error pre_proc_front_ivas_fx( * (if not available from downsampled DMX) *----------------------------------------------------------------*/ + Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */ test(); IF( EQ_16( element_mode, IVAS_SCE ) ) { - new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */ - Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ + new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */ - Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ + new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -574,27 +521,38 @@ ivas_error pre_proc_front_ivas_fx( Word16 length_inp = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS ); Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); - new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */ - Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ + new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } - new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */ - Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ - Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ + new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* st->q_inp */ + Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ IF( lMemRecalc > 0 ) { - new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx + sub( input_frame, lMemRecalc ), lMemRecalc, input_Fs, new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */ - Scale_sig( new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ + new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx + sub( input_frame, lMemRecalc ), lMemRecalc, input_Fs, new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + Scale_sig( new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */ - Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ + new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } ELSE /* DFT stereo */ { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ - Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */ + Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ + scale_sig( old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8, sub( Q_inp_const, st->q_inp ) ); + scale_sig( st->input_fx - input_frame, input_frame_full, sub( Q_inp_const, st->q_inp ) ); + Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */ + st->q_inp = Q_inp_const; + move16(); + st->q_old_inp = Q_inp_const; + move16(); + } + IF( NE_16( Q_inp_const, st->q_inp ) ) + { + Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */ } Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) ); /* Q(-1) */ @@ -605,15 +563,15 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 ); /* Q_to_be_looked_into */ + Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8, sub( Q_inp_const, st->q_inp ) ); /* Q_inp_const */ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { - Copy( new_inp_12k8_fx - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) ); /* Q_to_be_looked_into */ + Copy_Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, add( L_FRAME + L_FILT, lMemRecalc_12k8 ), sub( Q_inp_const, st->q_inp ) ); /* Q_inp_const */ } ELSE { - Copy( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME ); /* Q_to_be_looked_into */ + Copy_Scale_sig( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME, sub( Q_inp_const, st->q_inp ) ); /* Q_inp_const */ } /*------------------------------------------------------------------* @@ -628,14 +586,18 @@ ivas_error pre_proc_front_ivas_fx( move16(); + st->mem_preemph_fx = shl_sat( st->mem_preemph_fx, sub( st->q_inp, -1 ) ); /*st->q_inp*/ + move16(); + st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx, sub( st->q_inp, -1 ) ); /*st->q_inp*/ + move16(); test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching Q_to_be_looked_into*/ + Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( Q_inp_const, st->q_inp ) ); /* memory for TD/DFT stereo switching Q_inp_const*/ - st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* Q(-1) */ + st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* st->q_inp */ move16(); - st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* Q_new - 1 */ + st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */ move16(); // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); @@ -656,9 +618,9 @@ ivas_error pre_proc_front_ivas_fx( { IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { - st->mem_preemph_fx = st->mem_preemph_DFT_fx; + st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* st->q_inp */ move16(); - Copy( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* Q(-1) */ + Copy_Scale_sig( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */ // PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx ); PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx ); preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); @@ -667,7 +629,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } - st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] Q_new - 1 */ + st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */ move16(); } @@ -686,7 +648,7 @@ ivas_error pre_proc_front_ivas_fx( // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - dummy_fx = st->mem_preemph_fx; /* Q(-1) */ + dummy_fx = st->mem_preemph_fx; /* st->q_inp */ move16(); // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); @@ -716,12 +678,15 @@ ivas_error pre_proc_front_ivas_fx( preemp_len = L_FRAME + L_FILT; move16(); } + st->mem_preemph_fx = shl_sat( st->mem_preemph_fx, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */ + move16(); + st->mem_preemph_DFT_fx = shl( st->mem_preemph_DFT_fx, sub( -1, st->q_inp ) ); /*Q(-1)*/ + move16(); maximum_abs_32_fx( sig_out, preemp_len, &max_32 ); inp_max = s_max( extract_h( max_32 ), 1 ); - shift = sub( norm_s( inp_max ), headroom ); - Word16 Q_min; + Word16 shift = add( sub( norm_s( inp_max ), headroom ), st->q_inp ); shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max, L_Q_MEM, &Q_min ); @@ -744,12 +709,12 @@ ivas_error pre_proc_front_ivas_fx( st->Q_max[i] = shift; move16(); - Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new ); /* Q_to_be_looked_into + Q_new */ + *Q_new = add( *Q_new, Q_inp_const ); + move16(); - Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), *Q_new ); /* Q(-1) */ + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, st->q_inp ) ); /* Q_new */ - *Q_new = add( *Q_new, Q_to_be_looked_into ); - move16(); + Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, st->q_inp ) ); /* Q_new */ cldfbScale.hb_scale = cldfbScale.lb_scale; move16(); @@ -810,14 +775,9 @@ ivas_error pre_proc_front_ivas_fx( move16(); } - Word16 scale = add( L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ), st->hNoiseEst->q_bckr ); - scale = s_min( scale, add( L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS ), st->hNoiseEst->q_enrO ) ); + Word16 scale = add( L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS ), st->hNoiseEst->q_enrO ); scale = s_min( scale, fr_bands_fx_q ); - scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) ); - st->hNoiseEst->q_bckr = scale; - move16(); - scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_enrO ) ); st->hNoiseEst->q_enrO = scale; move16(); @@ -885,22 +845,38 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * NB/WB/SWB/FB bandwidth detector *----------------------------------------------------------------*/ - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + + IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - sf_energySum[i] = *enerBuffer_fx_exp; - move16(); + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + sf_energySum[i] = enerBuffer_fx_exp_buf[i]; + move16(); + } + } + ELSE + { + set16_fx( sf_energySum, *enerBuffer_fx_exp, CLDFB_NO_CHANNELS_MAX ); } test(); IF( st->idchan == 0 && NE_16( element_mode, IVAS_CPE_MDCT ) ) { - Scale_sig( st->input_fx, 480, negate( Q_to_be_looked_into ) ); /*scaling from Q_to_be_looked_into to q0*/ - - bw_detect_fx( st, st->input_fx, NULL, enerBuffer_fx, sf_energySum, ivas_format, 0 ); + Word16 input_fx_tmp[480]; + Copy_Scale_sig( st->input_fx, input_fx_tmp, shr( input_frame, 1 ), negate( st->q_inp ) ); /*scaling from Q_inp_const to q0*/ - Scale_sig( st->input_fx, 480, Q_to_be_looked_into ); /*scaling back to Q_to_be_looked_into*/ + bw_detect_fx( st, input_fx_tmp, NULL, enerBuffer_fx, sf_energySum, ivas_format, 0, 0 ); } + IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) + { + maximum_fx( sf_energySum, CLDFB_NO_CHANNELS_MAX, enerBuffer_fx_exp ); + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + enerBuffer_fx[i] = L_shl( enerBuffer_fx[i], sub( sf_energySum[i], *enerBuffer_fx_exp ) ); + move32(); + } + } IF( NE_16( element_mode, IVAS_CPE_MDCT ) ) /* in MDCT stereo, set_bw_stereo() is used instead */ { @@ -936,44 +912,14 @@ ivas_error pre_proc_front_ivas_fx( * Correlation correction as a function of total noise level *----------------------------------------------------------------*/ - noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, + noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, &st->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band, &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_fx, &st->hNoiseEst->Etot_v_h2_fx ); - q_tmpN = fr_bands_fx_q; - q_tmpE = fr_bands_fx_q; - move16(); - move16(); test(); IF( lr_vad_enabled && st->idchan == 0 ) { - scale = add( L_norm_arr( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS ), hCPE->hFrontVad[0]->hNoiseEst->q_bckr ); - scale = s_min( scale, add( L_norm_arr( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS ), hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) ); - scale = s_min( scale, add( L_norm_arr( fr_bands_LR_fx[0], 2 * NB_BANDS ), fr_bands_LR_fx_q[0] ) ); - scale = s_min( scale, add( L_norm_arr( fr_bands_LR_fx[1], 2 * NB_BANDS ), fr_bands_LR_fx_q[1] ) ); - - scale_sig32( fr_bands_LR_fx[0], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[0] ) ); - fr_bands_LR_fx_q[0] = scale; - move16(); - scale_sig32( fr_bands_LR_fx[1], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[1] ) ); - fr_bands_LR_fx_q[1] = scale; - move16(); - - scale_sig32( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[0]->hNoiseEst->q_bckr ) ); - hCPE->hFrontVad[0]->hNoiseEst->q_bckr = scale; - move16(); - scale_sig32( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) ); - hCPE->hFrontVad[1]->hNoiseEst->q_bckr = scale; - move16(); - - noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, tmpN_LR_fx[0], tmpE_LR_fx[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx ); - noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, tmpN_LR_fx[1], tmpE_LR_fx[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx ); - - q_tmpN_LR[0] = q_tmpE_LR[0] = scale; - move16(); - move16(); - q_tmpN_LR[1] = q_tmpE_LR[1] = scale; - move16(); - move16(); + noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx ); + noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx ); corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx ); // Q15 corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx ); // Q15 @@ -1092,11 +1038,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef NONBE_1211_DTX_BR_SWITCHING dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); -#else - dtx_ivas_fx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); -#endif test(); test(); @@ -1184,10 +1126,8 @@ ivas_error pre_proc_front_ivas_fx( * LP analysis *----------------------------------------------------------------*/ Word16 stab_fac_fx; - Word16 Q_new_loc; Word16 Q_r[2]; set16_fx( Q_r, 0, 2 ); - Q_new_loc = *Q_new; move16(); alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ @@ -1211,7 +1151,7 @@ ivas_error pre_proc_front_ivas_fx( } analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, - INT_FS_12k8, i, Q_new_loc, Q_r ); + INT_FS_12k8, i, *Q_new, Q_r ); FOR( Word16 idx = 0; idx < M + 1; idx++ ) { @@ -1266,21 +1206,10 @@ ivas_error pre_proc_front_ivas_fx( Word16 shift1 = norm_arr( old_wsp_fx, L_WSP_MEM ); Word16 shift2 = norm_arr( wsp_fx, L_WSP - L_WSP_MEM ); - maximum_abs_16_fx( old_wsp_fx, L_WSP_MEM, &shift ); - if ( !shift ) - { - shift1 = Q15; - move16(); - } - maximum_abs_16_fx( wsp_fx, L_WSP - L_WSP_MEM, &shift ); - if ( !shift ) - { - shift2 = Q15; - move16(); - } shift = s_min( add( *q_old_wsp, shift1 ), add( Q_wsp, shift2 ) ); shift = s_min( shift, add( norm_arr( st->mem_decim2_fx, 3 ), st->Q_old_wsp2 ) ); shift = s_min( shift, add( norm_arr( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ), st->Q_old_wsp2 ) ); + shift = s_min( shift, 15 ); scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, *q_old_wsp ) ); scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_wsp ) ); @@ -1346,14 +1275,6 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ - { - // TODO: this scalings to be checked - scale = s_min( Q30, add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ); - scale = s_min( scale, sub( add( fr_bands_fx_q, L_norm_arr( fr_bands_fx, 2 * NB_BANDS ) ), 4 ) ); - scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) ); - scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) ); - st->hNoiseEst->q_bckr = fr_bands_fx_q = scale; - } scale = s_min( Q31, s_min( add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ), add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ) ); scale = sub( scale, 1 ); // guard bits @@ -1464,11 +1385,7 @@ ivas_error pre_proc_front_ivas_fx( st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, Etot_fx, hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); -#else - Copy_Scale_sig_16_32_DEPREC( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); -#endif #ifdef DEBUG_FORCE_DIR if ( st->force_dir[0] != '\0' ) @@ -1648,12 +1565,6 @@ ivas_error pre_proc_front_ivas_fx( move16(); } - IF( flag_16k_smc ) - { - Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) ); /* Q(-1) */ - st->q_inp = -1; - move16(); - } /* these are for ivas_acelp_tcx20_switching_fx */ Scale_sig32( st->hTcxEnc->spectrum_long_fx, N_MAX, sub( st->hTcxEnc->spectrum_long_e, 16 ) ); /* Q(-1) */ st->hTcxEnc->spectrum_long_e = 16; @@ -1664,6 +1575,12 @@ ivas_error pre_proc_front_ivas_fx( move16(); IF( flag_16k_smc ) { + Scale_sig( st->input_fx - input_frame, input_frame_full, sub( -1, st->q_inp ) ); /* Q(-1) */ + st->q_inp = -1; + move16(); + st->q_old_inp = -1; + move16(); + Word16 Q_old_inp_16k = -1; move16(); @@ -1710,7 +1627,7 @@ ivas_error pre_proc_front_ivas_fx( st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q0 move16(); - *Q_new = add( *Q_new, Q_to_be_looked_into ); // actual Q_new + *Q_new = add( *Q_new, Q_inp_const ); // actual Q_new move16(); Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_12k8 ) ); /* Q_new */ @@ -1801,9 +1718,15 @@ ivas_error pre_proc_front_ivas_fx( st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) ); move16(); + Scale_sig( st->input_fx - input_frame, input_frame_full, sub( -1, st->q_inp ) ); + st->q_inp = -1; + move16(); + st->q_old_inp = -1; + move16(); + // Scale_sig( old_inp_12k8_fx, L_INP_12k8, negate( add( *Q_new, 1 ) ) ); - *Q_new = sub( *Q_new, Q_to_be_looked_into ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1 + *Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1 move16(); free( mem_decim_dummy_fx ); @@ -1885,21 +1808,16 @@ static void calculate_energy_buffer_ivas_fx( Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/ const Word16 no_channels, /* i : no. of used CLDFB channels Q0*/ const Word32 input_Fs, /* i : input sampling rate Q0*/ - Word16 *enerBuffer_dft_e ) + Word16 enerBuffer_dft_e[] ) { - Word16 i, j; + Word16 i, j, guard_bits; Word64 nrg_DMX_fx[CLDFB_NO_CHANNELS_MAX]; Word64 *p_nrg_DMX_fx; Word32 *pDFT_DMX_fx; /*q_DFT_DMX_fx*/ Word32 chan_width_bins_fx; Word16 band_res_dft_fx, chan_width_f_fx, start, stop; - Word16 norm_nrg_DMX_fx; - Word64 max_abs_nrg_DMX_fx; - Flag overflow = 0; - move32(); + Word16 norm_nrg_DMX_fx[CLDFB_NO_CHANNELS_MAX]; - max_abs_nrg_DMX_fx = 0; - move64(); Word16 temp_q1 = sub( norm_l( input_Fs ), 1 ); Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT ); @@ -1913,47 +1831,46 @@ static void calculate_energy_buffer_ivas_fx( start = 1; move16(); - pDFT_DMX_fx = hCPE->hStereoDft->DFT_fx[0]; /*q_DFT_DMX_fx = 31-hCPE->hStereoDft->DFT_fx_e[0]*/ + guard_bits = add( find_guarded_bits_fx( extract_h( chan_width_bins_fx ) ), 1 ); /* Q0 */ + + pDFT_DMX_fx = hCPE->hStereoDft->DFT_fx[0]; /* q_DFT_DMX_fx = 31 - hCPE->hStereoDft->DFT_fx_e[0] */ p_nrg_DMX_fx = nrg_DMX_fx; - *p_nrg_DMX_fx = Mpy_32_32( pDFT_DMX_fx[0], pDFT_DMX_fx[0] ); /*2 * q_DFT_DMX_fx -31 */ + *p_nrg_DMX_fx = W_shr( W_mult_32_32( pDFT_DMX_fx[0], pDFT_DMX_fx[0] ), guard_bits ); /* 2 * q_DFT_DMX_fx + 1 - guard_bits */ move64(); FOR( i = 0; i < no_channels; i++ ) { - stop = extract_l( L_shr( L_add( Mpy_32_16_1( chan_width_bins_fx, add( i, 1 ) ), 1 ), 1 ) ); + stop = extract_l( L_shr( L_add( Mpy_32_16_1( chan_width_bins_fx, add( i, 1 ) ), 1 ), 1 ) ); /* Q0 */ FOR( j = start; j < stop; j++ ) { - *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, Mpy_32_32( pDFT_DMX_fx[2 * j], pDFT_DMX_fx[2 * j] ) ); /*2 * q_DFT_DMX_fx -31 */ + *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, W_shr( W_mult_32_32( pDFT_DMX_fx[2 * j], pDFT_DMX_fx[2 * j] ), guard_bits ) ); /* 2 * q_DFT_DMX_fx + 1 - guard_bits */ move64(); - *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, Mpy_32_32( pDFT_DMX_fx[2 * j + 1], pDFT_DMX_fx[2 * j + 1] ) ); + *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, W_shr( W_mult_32_32( pDFT_DMX_fx[2 * j + 1], pDFT_DMX_fx[2 * j + 1] ), guard_bits ) ); /* 2 * q_DFT_DMX_fx + 1 - guard_bits */ move64(); - // 2 * DFT_fx_e - } - IF( GT_64( W_abs( *p_nrg_DMX_fx ), max_abs_nrg_DMX_fx ) ) - { - max_abs_nrg_DMX_fx = W_abs( *p_nrg_DMX_fx ); } + norm_nrg_DMX_fx[i] = W_norm( W_abs( *p_nrg_DMX_fx ) ); + move16(); start = stop; move16(); p_nrg_DMX_fx++; } - norm_nrg_DMX_fx = W_norm( max_abs_nrg_DMX_fx ); FOR( i = 0; i < no_channels; i++ ) /* Consider only used channels, dependent on Fs */ { - enerBuffer_dft_fx[i] = W_extract_h( W_shl_o( nrg_DMX_fx[i], norm_nrg_DMX_fx, &overflow ) ) / 3; /*q_enerBuffer_dft_fx=2 * q_DFT_DMX_fx -31+ norm_nrg_DMX_fx -32*/ + enerBuffer_dft_fx[i] = Mpy_32_16_1( W_extract_h( W_shl( nrg_DMX_fx[i], norm_nrg_DMX_fx[i] ) ), 10923 /* 1/3 in Q15 */ ); /* 2 * q_DFT_DMX_fx + 1 - guard_bits + norm_nrg_DMX_fx[i] - 32 */ move32(); + enerBuffer_dft_e[i] = sub( add( shl( hCPE->hStereoDft->DFT_fx_e[0], 1 ), guard_bits ), norm_nrg_DMX_fx[i] ); + move16(); } - *enerBuffer_dft_e = sub( add( 32, shl( hCPE->hStereoDft->DFT_fx_e[0], 1 ) ), norm_nrg_DMX_fx ); /*31-q_enerBuffer_dft_fx*/ - move16(); - /* Set remaining entries of enerBuffer to zero */ FOR( ; i < CLDFB_NO_CHANNELS_MAX; i++ ) { enerBuffer_dft_fx[i] = 0; move32(); + enerBuffer_dft_e[i] = 0; + move16(); } return; } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 8d00e608c083a3d89eada175ce3256e9fd6cf4e2..781d290aca75f4549ce757d98faad2c652464777 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -282,11 +282,7 @@ ivas_error pre_proc_ivas_fx( } ELSE IF( GT_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) && ( ( st->vad_flag == 0 && GE_16( st->bwidth, SWB ) && GE_16( st->max_bwidth, SWB ) ) || ( st->localVAD == 0 && ( LE_16( st->bwidth, WB ) || LE_16( st->max_bwidth, WB ) ) ) ) ) { -#ifdef NONBE_FIX_GSC_BSTR /* inactive frames will be coded by AVQ technology (exceptionally it can be later rewritten to GSC technology in ivas_combined_format_brate_sanity()) */ -#else - /* inactive frames will be coded by AVQ technology */ -#endif st->coder_type = INACTIVE; move16(); } @@ -734,9 +730,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 *preemp_start_idx = NULL; Word32 sig_out[960], max_32; /*Word16 Q_exp, Q_wsp_exp*/; -#ifdef MSAN_FIX set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k ); -#endif set16_fx( epsP_h, 0, M + 1 ); set16_fx( epsP_l, 0, M + 1 ); signal_in_fx = st->input_fx; /* st->q_inp */ @@ -833,8 +827,8 @@ ivas_error ivas_compute_core_buffers_fx( /* no resampling needed, only delay adjustment to account for the FIR resampling delay */ delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ); move16(); - Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - sub( lMemRecalc, add( delay, L_FILT16k ) ), delay ); /* Q(-1) */ - Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - add( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* st->q_inp */ + Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - add( lMemRecalc, sub( delay, L_FILT16k ) ), delay ); /* Q(-1) */ + Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - sub( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* st->q_inp */ Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */ } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index a1f2196fb0af3dfb3311509761c86508740f644a..2e09c42ed88a3f672723a0f9465157a031f56563 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -221,12 +221,12 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { FOR( k = 0; k < nSCE_old; k++ ) { - shift = getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame ); + shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame ), Q1 ); Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ); - shift = getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ); + shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift ); move16(); @@ -241,12 +241,12 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - shift = getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame ); + shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame ), Q1 ); Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ); - shift = getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ); + shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift ); move16(); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 4e46973cf18eb3f75bca155eb5a81cd580c6cd21..ca33dea1f148f53ebb1ace3094c58712d15287df 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -78,9 +78,7 @@ ivas_error ivas_cpe_enc_fx( Word16 Q_new[CPE_CHANNELS] = { 0 }; Word16 fft_buff_fx[CPE_CHANNELS][2 * L_FFT]; /* FFT buffer */ Word16 fft_buff_fx_q[CPE_CHANNELS]; /* FFT buffer */ -#ifdef MSAN_FIX set16_fx( fft_buff_fx_q, 0, CPE_CHANNELS ); -#endif Word16 fft_buff_fx_final_q = MAX_16; move16(); Word32 ener_fx[CPE_CHANNELS]; /* residual energy from Levinson-Durbin Q6 */ @@ -129,6 +127,7 @@ ivas_error ivas_cpe_enc_fx( Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp; move16(); // Q_new move16(); // Q_new + Word16 q_com; error = IVAS_ERR_OK; move32(); @@ -176,7 +175,6 @@ ivas_error ivas_cpe_enc_fx( set16_fx( voicing_fr_fx[0], 0, NB_SUBFR ); set16_fx( voicing_fr_fx[1], 0, NB_SUBFR ); -#ifdef MSAN_FIX FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { set16_zero_fx( fft_buff_fx[i], 2 * L_FFT ); @@ -185,7 +183,6 @@ ivas_error ivas_cpe_enc_fx( set16_zero_fx( old_inp_12k8_16fx[i], L_INP_12k8 ); set_zero_fx( old_inp_12k8_fx[i], L_INP_12k8 ); } -#endif /*------------------------------------------------------------------* * CPE initialization - core coder *-----------------------------------------------------------------*/ @@ -220,30 +217,29 @@ ivas_error ivas_cpe_enc_fx( #endif } - Copy32( data_fx_ch0, sts[0]->input32_fx, input_frame ); // Q(q_data_fx) - sts[0]->q_inp32 = q_data_fx; + Word16 Q_min = s_min( q_data_fx, add( sts[0]->q_inp32, L_norm_arr( sts[0]->input32_fx - input_frame, input_frame ) ) ); + scale_sig32( sts[0]->input32_fx - input_frame, input_frame, sub( Q_min, sts[0]->q_inp32 ) ); + Copy_Scale_sig32( data_fx_ch0, sts[0]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min) + sts[0]->q_inp32 = Q_min; move16(); + Word16 norm = L_norm_arr( sts[0]->input32_fx, input_frame ); - scale_sig32( sts[0]->input32_fx, input_frame, norm ); - sts[0]->q_inp32 = add( sts[0]->q_inp32, norm ); - move16(); - Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, 0 ); - sts[0]->q_inp = sub( sts[0]->q_inp32, Q16 ); + Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, norm ); + sts[0]->q_inp = add( sub( sts[0]->q_inp32, Q16 ), norm ); move16(); IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/ { - Copy32( data_fx_ch1, sts[1]->input32_fx, input_frame ); // Q(q_data_fx) - sts[1]->q_inp32 = q_data_fx; + Q_min = s_min( q_data_fx, add( sts[1]->q_inp32, L_norm_arr( sts[1]->input32_fx - input_frame, input_frame ) ) ); + scale_sig32( sts[1]->input32_fx - input_frame, input_frame, sub( Q_min, sts[1]->q_inp32 ) ); + Copy_Scale_sig32( data_fx_ch1, sts[1]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min) + sts[1]->q_inp32 = Q_min; move16(); norm = L_norm_arr( sts[1]->input32_fx, input_frame ); - scale_sig32( sts[1]->input32_fx, input_frame, norm ); - sts[1]->q_inp32 = add( sts[1]->q_inp32, norm ); - move16(); - Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, 0 ); - sts[1]->q_inp = sub( sts[1]->q_inp32, Q16 ); + Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, norm ); + sts[1]->q_inp = add( sub( sts[1]->q_inp32, Q16 ), norm ); move16(); } @@ -288,9 +284,7 @@ ivas_error ivas_cpe_enc_fx( move16(); Word16 front_create_flag = 0; move16(); -#ifdef MSAN_FIX set32_fx( band_energies_LR_fx, 0, 2 * NB_BANDS ); -#endif IF( hCPE->hFrontVad[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) { @@ -375,31 +369,8 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Set TD stereo parameters *----------------------------------------------------------------*/ -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */ -#else - Copy_Scale_sig_16_32_DEPREC( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32_DEPREC( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */ -#endif - Word16 shift = getScaleFactor32( sts[1]->input32_fx, input_frame ); - scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* Q11 + shift */ - sts[1]->q_inp32 = add( Q11, shift ); - move16(); - - shift = getScaleFactor32( sts[0]->input32_fx, input_frame ); - scale_sig32( sts[0]->input32_fx, input_frame, shift ); /* Q11 + shift */ - sts[0]->q_inp32 = add( Q11, shift ); - move16(); - Q_inp = s_min( Q_inp, s_min( sts[0]->q_inp32, sts[1]->q_inp32 ) ); - scale_sig32( sts[0]->input32_fx, input_frame, sub( Q_inp, sts[0]->q_inp32 ) ); /* Q_inp */ - scale_sig32( sts[1]->input32_fx, input_frame, sub( Q_inp, sts[1]->q_inp32 ) ); /* Q_inp */ - sts[1]->q_inp32 = sts[0]->q_inp32 = Q_inp; - move16(); - move16(); - - IF( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ) != IVAS_ERR_OK ) + IF( ( error = stereo_set_tdm_fx( hCPE, input_frame, sts[1]->q_inp32 ) ) != IVAS_ERR_OK ) { return error; } @@ -408,8 +379,7 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Resets/updates in case of stereo switching *----------------------------------------------------------------*/ -#ifdef FIX_ISSUE_1247 - shift = norm_arr( sts[1]->old_input_signal_fx, input_frame ); + Word16 shift = norm_arr( sts[1]->old_input_signal_fx, input_frame ); Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */ sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift ); move16(); @@ -426,25 +396,6 @@ ivas_error ivas_cpe_enc_fx( Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */ sts[0]->q_inp = add( sts[0]->q_inp, shift ); move16(); -#else - shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame ); - Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */ - sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift ); - move16(); - shift = getScaleFactor16( sts[1]->input_fx, input_frame ); - Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */ - sts[1]->q_inp = add( sts[1]->q_inp, shift ); - move16(); - - shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame ); - Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */ - sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift ); - move16(); - shift = getScaleFactor16( sts[0]->input_fx, input_frame ); - Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */ - sts[0]->q_inp = add( sts[0]->q_inp, shift ); - move16(); -#endif Word16 q_inp = s_min( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), s_min( sts[1]->q_inp, sts[1]->q_old_inp ) ); @@ -682,9 +633,6 @@ ivas_error ivas_cpe_enc_fx( // printf("\n%f %f ", hCPE->hStereoClassif->is_speech, hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0]); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { -#ifndef MSAN_FIX - hCPE->hStereoClassif->xtalk_score_fx = floatToFixed( hCPE->hStereoClassif->xtalk_score, 31 ); -#endif // !MSAN_FIX /*flt2fix: dft_synthesize*/ test(); if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) @@ -702,35 +650,31 @@ ivas_error ivas_cpe_enc_fx( hCPE->hStereoDft->Spd_R_smooth_fx_e = sub( hCPE->hStereoDft->Spd_R_smooth_fx_e, temp ); move16(); - shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame ); - Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */ - sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift ); - move16(); - shift = getScaleFactor16( sts[1]->input_fx, input_frame ); - Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */ - sts[1]->q_inp = add( sts[1]->q_inp, shift ); - move16(); - Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp) */ - Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) ); /* min( sts[1]->q_old_inp, sts[1]->q_inp) */ - sts[1]->q_inp = s_min( sts[1]->q_inp, sts[1]->q_old_inp ); - move16(); - sts[1]->q_old_inp = sts[1]->q_inp; - move16(); - shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame ); - Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[0]->q_old_inp + shift */ - sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift ); - move16(); - shift = getScaleFactor16( sts[0]->input_fx, input_frame ); - Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[0]->q_inp + shift */ - sts[0]->q_inp = add( sts[0]->q_inp, shift ); - move16(); - Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp) */ - Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) ); /* min( sts[1]->q_old_inp, sts[1]->q_inp) */ - sts[0]->q_inp = s_min( sts[0]->q_inp, sts[0]->q_old_inp ); - move16(); - sts[0]->q_old_inp = sts[0]->q_inp; - move16(); + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + q_com = sub( add( L_norm_arr( sts[n]->input32_fx, input_frame ), sts[n]->q_inp32 ), 16 ); + q_com = s_min( q_com, add( norm_arr( sts[n]->old_input_signal_fx, input_frame ), sts[n]->q_old_inp ) ); + q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hCPE->hStereoDft->dft_ovl ), hCPE->q_input_mem[n] ) ); + + if ( EQ_16( q_com, Q15 ) ) + { + q_com = 0; + move16(); + } + + Copy_Scale_sig_32_16( sts[n]->input32_fx, sts[n]->input_fx, input_frame, sub( q_com, sts[n]->q_inp32 ) ); + sts[n]->q_inp = q_com; + move16(); + + scale_sig( sts[n]->old_input_signal_fx, input_frame, sub( q_com, sts[n]->q_old_inp ) ); + sts[n]->q_old_inp = q_com; + move16(); + + scale_sig( hCPE->input_mem_fx[n], hCPE->hStereoDft->dft_ovl, sub( q_com, hCPE->q_input_mem[n] ) ); + hCPE->q_input_mem[n] = q_com; + move16(); + } stereo_dft_hybrid_ITD_flag_fx( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); @@ -775,6 +719,8 @@ ivas_error ivas_cpe_enc_fx( move16(); } stereo_tdm_downmix_ivas_fx( hCPE->hStereoTD, sts[0]->input_fx, sts[1]->input_fx, input_frame, tdm_ratio_idx, tdm_SM_flag, tdm_ratio_idx_SM ); + Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( sts[0]->q_inp32, sts[0]->q_inp ) ); + Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( sts[1]->q_inp32, sts[1]->q_inp ) ); /* signal the bitrate for BW selection in the SCh */ sts[0]->bits_frame_channel = 0; @@ -839,6 +785,9 @@ ivas_error ivas_cpe_enc_fx( } stereo_td_itd_mdct_stereo_fx( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); + + Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx - input_frame, sts[0]->input32_fx - input_frame, shl( input_frame, 1 ), sub( sts[0]->q_inp32, sts[0]->q_inp ) ); + Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx - input_frame, sts[1]->input32_fx - input_frame, shl( input_frame, 1 ), sub( sts[1]->q_inp32, sts[1]->q_inp ) ); } /*----------------------------------------------------------------* @@ -865,8 +814,10 @@ ivas_error ivas_cpe_enc_fx( move16(); move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); + Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer + sts[0]->q_inp32 = Q15; + move16(); -#ifdef FIX_ISSUE_1135 // Normalise the input buffer from Q15 Word16 input_norm, q_inp32, common_q, fir_delay_len; input_norm = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( out_end_ind, out_start_ind ) ); @@ -887,9 +838,6 @@ ivas_error ivas_cpe_enc_fx( move16(); sts[0]->q_old_inp = common_q; move16(); -#else - Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, sts[0]->q_inp ), Q15 ) ); // Q15 -#endif /* iDFT & resampling to 12.8kHz internal sampling rate */ stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[0] + L_INP_MEM, &out_12k8_start_ind[0], &out_12k8_end_ind[0], 0, input_Fs, INT_FS_12k8, 0, NULL ); @@ -928,6 +876,9 @@ ivas_error ivas_cpe_enc_fx( set16_fx( sts[1]->input_fx, 0, input_frame ); sts[1]->q_inp = Q15; move16(); + set32_fx( sts[1]->input32_fx, 0, input_frame ); + sts[1]->q_inp32 = Q31; + move16(); } #ifdef DEBUG_MODE_INFO @@ -956,11 +907,7 @@ ivas_error ivas_cpe_enc_fx( &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, -#ifdef NONBE_1211_DTX_BR_SWITCHING band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] -#else - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate, &Q_new[n] -#endif #ifdef DEBUG_MODE_INFO , ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) @@ -1299,6 +1246,9 @@ ivas_error ivas_cpe_enc_fx( Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame ); /* Q_orig_inp */ sts[n]->q_old_inp = Q_orig_inp[n]; move16(); + Copy_Scale_sig_16_32_no_sat( sts[n]->input_fx - input_frame, sts[n]->input32_fx - input_frame, input_frame, 16 ); // duplicating the data for input32_fx + sts[n]->q_inp32 = add( Q_orig_inp[n], 16 ); + move16(); } } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) @@ -1306,6 +1256,7 @@ ivas_error ivas_cpe_enc_fx( Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */ sts[0]->q_old_inp = sts[0]->q_inp; move16(); + Copy32( sts[0]->input32_fx, sts[0]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ } ELSE IF( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */ { @@ -1315,6 +1266,7 @@ ivas_error ivas_cpe_enc_fx( Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */ sts[n]->q_old_inp = sts[n]->q_inp; move16(); + Copy32( sts[n]->input32_fx, sts[n]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ } } @@ -1443,9 +1395,7 @@ ivas_error create_cpe_enc_fx( hCPE->input_mem_fx[n] = NULL; } } -#ifdef MSAN_FIX set16_fx( hCPE->q_input_mem, Q15, CPE_CHANNELS ); -#endif /*-----------------------------------------------------------------* * stereo classifier: allocate and initialize diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index db5ee872becb1e0b4b4af63ed17377082f48ccfd..615a6f4b630124866a0aa9acc77837511514d3e6 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -51,13 +51,9 @@ static void computeIntensityVector_enc_fx( Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], const Word16 enc_param_start_band, /* i : first band to process */ const Word16 num_frequency_bands, - Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - , + Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS], Word16 q_cldfb, - Word16 q_intensity_real[DIRAC_MAX_NBANDS] -#endif -); + Word16 q_intensity_real[DIRAC_MAX_NBANDS] ); /*------------------------------------------------------------------------- * ivas_dirac_enc_open() @@ -761,7 +757,6 @@ void computeReferencePower_enc_fx_dirac( *dirac_mono_flag = ivas_dirac_get_mono_flag_fx( band_grouping, Cldfb_RealBuffer, Cldfb_ImagBuffer, e_Cldfb, nchan_ana, mono_frame_count ); /* Q0 */ move16(); } -#ifdef FIX_1127_IMPROVE_SBA_MLD Word16 gb = 0; move16(); FOR( i = 0; i < num_freq_bands; i++ ) @@ -774,7 +769,6 @@ void computeReferencePower_enc_fx_dirac( } e_reference_W = sub( 31, sub( add( shl( sub( 31, e_Cldfb ), 1 ), 1 ), gb ) ); e_reference_temp = e_reference_W; -#endif move16(); FOR( i = 0; i < num_freq_bands; i++ ) { @@ -791,14 +785,8 @@ void computeReferencePower_enc_fx_dirac( FOR( j = brange[0]; j < brange[1]; j++ ) { -#ifdef FIX_1127_IMPROVE_SBA_MLD reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), gb ) ); /* exp(2 * e_Cldfb) */ reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mult_32_32( Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ), gb ) ); /* exp(2 * e_Cldfb) */ -#else - reference_power_W[i] = W_mac_32_32( reference_power_W[i], Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ); - reference_power_W[i] = W_mac_32_32( reference_power_W[i], Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ); - e_reference_W = imult1616( (Word16) 2, e_Cldfb ); -#endif move64(); move64(); } @@ -810,14 +798,8 @@ void computeReferencePower_enc_fx_dirac( /* abs()^2 */ FOR( j = brange[0]; j < brange[1]; j++ ) { -#ifdef FIX_1127_IMPROVE_SBA_MLD reference_power_temp[i] = W_add( reference_power_temp[i], W_shr( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), gb ) ); /* exp(2 * e_Cldfb) */ reference_power_temp[i] = W_add( reference_power_temp[i], W_shr( W_mult_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), gb ) ); /* exp(2 * e_Cldfb) */ -#else - reference_power_temp[i] = W_mac_32_32( reference_power_temp[i], Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ); - reference_power_temp[i] = W_mac_32_32( reference_power_temp[i], Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ); - e_reference_temp = imult1616( (Word16) 2, e_Cldfb ); -#endif move64(); move64(); } @@ -974,11 +956,7 @@ void ivas_dirac_param_est_enc_fx( Word32 *p_Cldfb_ImagBuffer_fx[DIRAC_MAX_ANA_CHANS]; Word16 cldfb_q; Word32 intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS]; -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC Word16 intensity_real_q[DIRAC_MAX_NBANDS]; -#else - Word16 intensity_real_q; -#endif Word32 direction_vector_fx[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS]; Word16 direction_vector_q; Word32 diffuseness_vector_fx[DIRAC_MAX_NBANDS]; @@ -1008,10 +986,6 @@ void ivas_dirac_param_est_enc_fx( cldfb_q = 0; move16(); -#ifndef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - intensity_real_q = 0; - move16(); -#endif direction_vector_q = 0; move16(); @@ -1147,16 +1121,9 @@ void ivas_dirac_param_est_enc_fx( Cldfb_ImagBuffer_fx, hDirAC->hConfig->enc_param_start_band, num_freq_bands, - intensity_real_fx -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - , + intensity_real_fx, cldfb_q, - intensity_real_q -#endif - ); -#ifndef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - intensity_real_q = sub( shl( cldfb_q, 1 ), 31 ); // 2 * Q_Cldfb + 1 - 32; -#endif + intensity_real_q ); IF( !hodirac_flag ) { computeDirectionVectors_fixed( @@ -1167,15 +1134,8 @@ void ivas_dirac_param_est_enc_fx( num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], - direction_vector_fx[2] -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - , - 31, intensity_real_q -#else - , - sub( 31, intensity_real_q ) -#endif - ); + direction_vector_fx[2], + 31, intensity_real_q ); direction_vector_q = Q30; move16(); @@ -1190,11 +1150,7 @@ void ivas_dirac_param_est_enc_fx( { /* only real part needed */ Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); /* intensity_real_q */ -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC Copy( intensity_real_q, &hDirAC->buffer_intensity_real_q[i][index - 1][0], num_freq_bands ); -#else - set16_fx( &hDirAC->buffer_intensity_real_q[i][index - 1][0], intensity_real_q, num_freq_bands ); -#endif } Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); /* exp(reference_power_exp) */ FOR( i = 0; i < num_freq_bands; i++ ) @@ -1406,12 +1362,7 @@ void ivas_dirac_param_est_enc_fx( Scale_sig32( dir_v_fx, 3, -1 ); ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC Q29, -#else - - Q30, -#endif &q_direction->band_data[band_m_idx].azimuth_fx[block_m_idx], &q_direction->band_data[band_m_idx].elevation_fx[block_m_idx] ); } @@ -1506,12 +1457,9 @@ static void computeIntensityVector_enc_fx( const Word16 enc_param_start_band, /* i : first band to process Q0*/ const Word16 num_frequency_bands, /* Q0 */ Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] /* q_intensity_real */ -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC , Word16 q_cldfb, - Word16 q_intensity_real[DIRAC_MAX_NBANDS] -#endif -) + Word16 q_intensity_real[DIRAC_MAX_NBANDS] ) { /* Reminder * X = a + ib; Y = c + id @@ -1520,20 +1468,16 @@ static void computeIntensityVector_enc_fx( Word16 i, j; Word32 real, img; Word16 brange[2]; -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC Word16 shift_value = sub( shl( q_cldfb, 1 ), 31 ); -#endif FOR( i = 0; i < num_frequency_bands; i++ ) { brange[0] = hDirAC->band_grouping[i + enc_param_start_band]; /* Q0 */ move16(); brange[1] = hDirAC->band_grouping[i + enc_param_start_band + 1]; /* Q0 */ move16(); -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC Word16 num_bins = sub( brange[1], brange[0] ); Word16 gb = find_guarded_bits_fx( num_bins ); Word16 norm; -#endif intensity_real[0][i] = 0; move32(); intensity_real[1][i] = 0; @@ -1552,7 +1496,6 @@ static void computeIntensityVector_enc_fx( move32(); img = Cldfb_ImagBuffer[0][j]; move32(); -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC Word64 t1, t2, t3; t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */ t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */ @@ -1564,14 +1507,7 @@ static void computeIntensityVector_enc_fx( tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */ tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */ tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */ -#else - /* Intensity is XYZ order, audio is WYZX order. */ - tmp_1 = W_add( tmp_1, W_add( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), W_mult_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); - tmp_2 = W_add( tmp_2, W_add( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), W_mult_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); - tmp_3 = W_add( tmp_3, W_add( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), W_mult_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); -#endif } -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC norm = 63; move16(); IF( tmp_1 != 0 ) @@ -1593,15 +1529,6 @@ static void computeIntensityVector_enc_fx( intensity_real[2][i] = W_extract_h( W_shl( tmp_3, norm ) ); // shift_value - (gb - norm) q_intensity_real[i] = sub( shift_value, sub( gb, norm ) ); move16(); -#else - - intensity_real[0][i] = W_extract_h( tmp_1 ); // output Q= 2* input_q + 1 - 32 - move32(); - intensity_real[1][i] = W_extract_h( tmp_2 ); // output Q= 2* input_q + 1 - 32 - move32(); - intensity_real[2][i] = W_extract_h( tmp_3 ); // output Q= 2* input_q + 1 - 32 - move32(); -#endif } return; diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index e8e1bc59e5913762d56f4b6d28accf33176cb34e..ff5f65b32ac739159f0f5d74d2df5026a3d48a34 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -344,13 +344,22 @@ ivas_error ivas_enc_fx( { norm_data_in = s_min( norm_data_in, L_norm_arr( data_fx[i], input_frame ) ); } - norm_data_in = sub( norm_data_in, 7 ); /*guard bit is 4->to handle overflow in cldfbAnalysis*/ - FOR( i = 0; i < hEncoderConfig->nchan_ism + st_ivas->nchan_transport; i++ ) + IF( LT_16( norm_data_in, 31 ) ) + { + norm_data_in = sub( norm_data_in, 7 ); /*guard bit is 4->to handle overflow in cldfbAnalysis*/ + norm_data_in = s_min( norm_data_in, 20 ); // limit Q to 31 (11 + norm) + FOR( i = 0; i < hEncoderConfig->nchan_ism + st_ivas->nchan_transport; i++ ) + { + scale_sig32( data_fx[i], input_frame, norm_data_in ); /* st_ivas->q_data_fx + norm_data_in */ + } + st_ivas->q_data_fx = add( st_ivas->q_data_fx, norm_data_in ); + move16(); + } + ELSE { - scale_sig32( data_fx[i], input_frame, norm_data_in ); /* st_ivas->q_data_fx + norm_data_in */ + st_ivas->q_data_fx = 31; + move16(); } - st_ivas->q_data_fx = add( st_ivas->q_data_fx, norm_data_in ); - move16(); } /* Estimate MASA parameters for the objects */ diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index b37e618299f706dfe8bbfe83620a447895e1b225..b21a669528e03c94edff804b63e61db3c529f835 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -609,23 +609,13 @@ ivas_error front_vad_spar_fx( Q_inp_12k8 = hFrontVad->q_buffer_12k8; move16(); - scale = s_min( add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ), add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ) ) ); - scale_sig32( fr_bands_fx[0], 40, sub( scale, q_fr_bands[0] ) ); // scale - scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); // scale - hFrontVad->hNoiseEst->q_bckr = q_fr_bands[0] = scale; - move16(); - move16(); - - noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, + Word16 q_tmpN, q_tmpE; + noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, &hFrontVad->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx ); corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */ -#ifdef NONBE_1211_DTX_BR_SWITCHING dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); -#else - dtx_ivas_fx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); -#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ @@ -670,14 +660,45 @@ ivas_error front_vad_spar_fx( old_pitch = st->pitch[1]; move16(); - Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) ); // Q8 - pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q8 ); + Word16 shift, Q_wsp; + Word16 shift1 = norm_arr( old_wsp_fx, L_WSP_MEM ); + Word16 shift2 = norm_arr( wsp_fx, L_WSP - L_WSP_MEM ); + maximum_abs_16_fx( old_wsp_fx, L_WSP_MEM, &shift ); + if ( !shift ) + { + shift1 = Q15; + move16(); + } + maximum_abs_16_fx( wsp_fx, L_WSP - L_WSP_MEM, &shift ); + if ( !shift ) + { + shift2 = Q15; + move16(); + } + + shift = s_min( Q15, s_min( add( Q_inp_12k8, shift1 ), add( Q_inp_12k8, shift2 ) ) ); + shift = s_min( shift, add( norm_arr( st->mem_decim2_fx, 3 ), st->Q_old_wsp2 ) ); + shift = s_min( shift, add( norm_arr( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ), st->Q_old_wsp2 ) ); + + scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, Q_inp_12k8 ) ); + scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_inp_12k8 ) ); + + Q_wsp = shift; + move16(); + + scale_sig( st->mem_decim2_fx, 3, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q( mem_decim ) = Q( old_wsp2 ) + scale_sig( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q_wsp + + st->Q_old_wsp2 = Q_wsp; + move16(); + + pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp ); /* Updates for adaptive lag window memory */ st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); - Scale_sig( wsp_fx, 368, Q9 - Q8 ); /* Q9 */ - StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q12, st->lgBin_E_fx ); + + StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); IF( st->hSpMusClas != NULL ) { Word16 dummy_int; @@ -700,18 +721,18 @@ ivas_error front_vad_spar_fx( Scale_sig32( epsP_fx, M + 1, scale ); // Q_esp scale = add( hFrontVad->hNoiseEst->ave_enr_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ); - scale = s_min( scale, add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( tmpE_fx, NB_BANDS ) ) ); + scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) ); scale = sub( s_min( scale, Q31 ), 1 ); scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->ave_enr_q ) ); scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->ave_enr_q ) ); - scale_sig32( tmpE_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); + scale_sig32( tmpE_fx, NB_BANDS, sub( scale, q_tmpE ) ); hFrontVad->hNoiseEst->ave_enr_q = scale; move16(); - scale = add( hFrontVad->hNoiseEst->q_bckr, s_min( L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ), L_norm_arr( tmpN_fx, NB_BANDS ) ) ); + scale = s_min( add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ) ), add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ) ); scale = sub( s_min( Q31, scale ), 1 ); // guard bits scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); + scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) ); hFrontVad->hNoiseEst->q_bckr = scale; move16(); diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 57858b03ebb2b017899ab8a57e690e0b0be2cc36..04b99f039019bb15a831a85c5ef8fe516d11b782 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -269,7 +269,7 @@ Word16 getNumChanAnalysis_fx( return n; } - +#ifndef HARM_ENC_INIT /*-------------------------------------------------------------------* * copy_encoder_config_ivas_fx() * @@ -321,6 +321,7 @@ void copy_encoder_config_ivas_fx( return; } +#endif /*-------------------------------------------------------------------* * copy_encoder_config_fx() * @@ -463,7 +464,7 @@ void ivas_initialize_handles_enc_fx( * * Initialize IVAS encoder state structure *-------------------------------------------------------------------*/ - +#ifndef HARM_ENC_INIT ivas_error ivas_init_encoder( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) @@ -1073,6 +1074,7 @@ ivas_error ivas_init_encoder( } return error; } +#endif ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) @@ -1100,10 +1102,10 @@ ivas_error ivas_init_encoder_fx( hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */ move32(); - IF( NE_16( ivas_format, MONO_FORMAT ) ) + if ( NE_16( ivas_format, MONO_FORMAT ) ) { /* In IVAS, ensure that minimum coded bandwidth is WB */ - hEncoderConfig->max_bwidth = extract_l( L_max( hEncoderConfig->max_bwidth, WB ) ); /* Q0 */ + hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ move16(); } st_ivas->ism_mode = ISM_MODE_NONE; @@ -1142,7 +1144,10 @@ ivas_error ivas_init_encoder_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); } + set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); } + st_ivas->q_data_fx = Q11; + move16(); FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { st_ivas->p_data_fx[n] = NULL; @@ -1196,7 +1201,7 @@ ivas_error ivas_init_encoder_fx( /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ - test(); + IF( EQ_32( ivas_format, MONO_FORMAT ) ) { st_ivas->nSCE = 1; /* in mono, there is always only one SCE */ @@ -1207,23 +1212,19 @@ ivas_error ivas_init_encoder_fx( move16(); sce_id = 0; move16(); - +#ifndef HARM_SCE_INIT test(); - IF( st_ivas->hEncoderConfig->element_mode_init == EVS_MONO ) + IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) { - IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } - ELSE +#else + test(); + IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - +#endif /* prepare stereo downmix for EVS */ IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) { @@ -1342,7 +1343,7 @@ ivas_error ivas_init_encoder_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( hEncoderConfig->Opt_DTX_ON ) + if ( hEncoderConfig->Opt_DTX_ON ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; move16(); @@ -1350,7 +1351,7 @@ ivas_error ivas_init_encoder_fx( } } - IF( st_ivas->nCPE > 1 ) + IF( GT_16( st_ivas->nCPE, 1 ) ) { IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) { @@ -1358,7 +1359,7 @@ ivas_error ivas_init_encoder_fx( } } } - ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) + ELSE IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { Word32 ism_total_brate; Word16 k; @@ -1428,12 +1429,12 @@ ivas_error ivas_init_encoder_fx( ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { st_ivas->ism_mode = ISM_MODE_NONE; - move32(); + move16(); IF( GE_32( ivas_total_brate, IVAS_256k ) ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; - move32(); + move16(); } IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) @@ -1523,7 +1524,7 @@ ivas_error ivas_init_encoder_fx( return error; } - IF( NE_32( st_ivas->mc_mode, MC_MODE_MCT ) ) + IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { st_ivas->nSCE = 0; move16(); @@ -1596,7 +1597,9 @@ ivas_error ivas_init_encoder_fx( FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK ) + Word32 res_dec, res_frac; + iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 ); + IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK ) { return error; } @@ -1658,7 +1661,9 @@ ivas_error ivas_init_encoder_fx( *-----------------------------------------------------------------*/ /* set number of input channels used for analysis/coding */ - n = getNumChanAnalysis_fx( st_ivas ); + n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */ + move16(); + IF( n > 0 ) { IF( ( st_ivas->mem_hp20_in_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL ) diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 6aba283beac75621190c5b7832817fbe98af8c04..b06acfbac9d82312451262648f8cc39526dd1b19 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -174,11 +174,7 @@ Word16 ivas_ism_dtx_enc_fx( ( EQ_16( nchan_ism, 2 ) && LE_32( ivas_total_brate, IVAS_48k ) ) || ( EQ_16( nchan_ism, 3 ) && LE_32( ivas_total_brate, IVAS_80k ) ) || ( EQ_16( nchan_ism, 4 ) && LE_32( ivas_total_brate, IVAS_96k ) ) || -#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD LT_16( lp_noise_max_fx, ( DTX_THR << 8 ) ) ) ) -#else - LT_16( lp_noise_max_fx, ( 15 << 8 ) ) ) ) -#endif { dtx_flag = 0; move16(); diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index c2f77c159eb6fa180db94e04d81fde15bcda15fb..81c9e01ef8818e5f3d1976b93dd791b99b9966a1 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -116,12 +116,10 @@ ivas_error ivas_ism_enc_fx( error = IVAS_ERR_OK; move32(); -#ifdef MSAN_FIX FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) { set16_zero_fx( old_inp_12k8_fx[i][0], L_INP_12k8 ); } -#endif set16_fx( q_re_im_buf, 0, MAX_NUM_OBJECTS ); @@ -167,10 +165,14 @@ ivas_error ivas_ism_enc_fx( /*------------------------------------------------------------------* * Initialization - general *-----------------------------------------------------------------*/ - Copy32( data[sce_id], st->input32_fx, input_frame ); // Q(q_data) - q_st_inp_16 = sub( L_norm_arr( st->input32_fx, input_frame ), 16 ); - Copy_Scale_sig_32_16( st->input32_fx, st->input_fx, input_frame, q_st_inp_16 ); // q_data -> Q(q_inp + q_data) - st->q_inp = add( q_st_inp_16, q_data ); + Word16 Q_min = s_min( q_data, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) ); + scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) ); + Copy_Scale_sig32( data[sce_id], st->input32_fx, input_frame, sub( Q_min, q_data ) ); // Q(Q_min) + st->q_inp32 = Q_min; + move16(); + q_st_inp_16 = sub( getScaleFactor32( st->input32_fx, input_frame ), 16 ); + Copy_Scale_sig_32_16( st->input32_fx, st->input_fx, input_frame, q_st_inp_16 ); // Q_min -> Q(q_inp + Q_min) + st->q_inp = add( q_st_inp_16, Q_min ); move16(); st->element_mode = IVAS_SCE; @@ -247,11 +249,7 @@ ivas_error ivas_ism_enc_fx( error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], -#ifdef NONBE_1211_DTX_BR_SWITCHING fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] -#else - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] -#endif #ifdef DEBUG_MODE_INFO , st->id_element @@ -281,20 +279,6 @@ ivas_error ivas_ism_enc_fx( *-----------------------------------------------------------------*/ /* compute the dominant sce_id using long term energy */ - FOR( Word16 j = 0; j < st_ivas->nchan_transport; j++ ) - { - test(); - IF( st_ivas->hSCE[j] && st_ivas->hSCE[j]->hCoreCoder[0] ) - { -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( st_ivas->hSCE[j]->hCoreCoder[0]->input_fx, st_ivas->hSCE[j]->hCoreCoder[0]->input32_fx, input_frame, sub( Q11, st_ivas->hSCE[j]->hCoreCoder[0]->q_inp ) ); /* Q11 */ -#else - Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[j]->hCoreCoder[0]->input_fx, st_ivas->hSCE[j]->hCoreCoder[0]->input32_fx, input_frame, sub( Q11, st_ivas->hSCE[j]->hCoreCoder[0]->q_inp ) ); /* Q11 */ -#endif - st_ivas->hSCE[j]->hCoreCoder[0]->q_inp32 = Q11; - move16(); - } - } IF( st_ivas->hEncoderConfig->Opt_DTX_ON ) { @@ -490,6 +474,7 @@ ivas_error ivas_ism_enc_fx( Copy( st->input_fx, st->old_input_signal_fx, input_frame ); /* st->q_inp */ st->q_old_inp = st->q_inp; move16(); + Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ hSCE->last_element_brate = hSCE->element_brate; /* Q0 */ move32(); diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 8e6e0c93f773a621f921c1fb37a68bed252f81f3..1efbb2123e56790854df9a4a08a641ed61d94dfa 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -314,10 +314,8 @@ ivas_error ivas_ism_metadata_enc_fx( } ELSE IF( EQ_16( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX ) ) { -#ifdef NONBE_1273_ISM_METADATA_COUNTER hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; move16(); -#endif lowrate_metadata_flag[ch] = 1; move16(); hIsmMeta[ch]->position_angle.angle1_diff_cnt = ISM_FEC_MAX; @@ -650,10 +648,8 @@ ivas_error ivas_ism_metadata_enc_fx( { hIsmMeta[ch]->ism_md_fec_cnt_enc = add( hIsmMeta[ch]->ism_md_fec_cnt_enc, 1 ); move16(); -#ifdef NONBE_1273_ISM_METADATA_COUNTER hIsmMeta[ch]->ism_md_fec_cnt_enc = s_min( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX ); move16(); -#endif } ELSE { @@ -821,10 +817,8 @@ ivas_error ivas_ism_metadata_enc_fx( { hIsmMeta[ch]->ism_md_fec_cnt_enc = add( hIsmMeta[ch]->ism_md_fec_cnt_enc, 1 ); move16(); -#ifdef NONBE_1273_ISM_METADATA_COUNTER hIsmMeta[ch]->ism_md_fec_cnt_enc = s_min( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX ); move16(); -#endif } ELSE { diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index da1f836df340575c1183fad83627f59919608aae..2b9ffef15f53806e0f56f6d3bbf06b0ea710c928 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -987,11 +987,7 @@ ivas_error ivas_masa_enc_config_fx( /* Setup importance weights for two-direction band selection. */ IF( EQ_16( hMasa->config.numberOfDirections, 2 ) ) { -#ifdef MSAN_FIX set32_fx( hMasa->data.importanceWeight_fx, ONE_IN_Q30 /*1.0f Q30*/, MASA_FREQUENCY_BANDS ); -#else - set32_fx( hMasa->data.importanceWeight_fx, ONE_IN_Q30 /*1.0f Q30*/, hMasa->config.numCodingBands ); -#endif IF( EQ_16( hMasa->config.numCodingBands, 5 ) ) @@ -2301,7 +2297,9 @@ static void reduce_metadata_further_fx( UWord8 computeCoherence; Word32 onset_filter; Word16 onset_filter_e, exp; - Word32 bandEnergy; + Word64 bandEnergy; + Word32 bandEnergy32; + Word16 bandEnergy_exp, shift; UWord8 mergeOverFreqBands; Word32 meanRatio; Word16 tmp, tmp2; @@ -2441,13 +2439,16 @@ static void reduce_metadata_further_fx( move32(); bandEnergy = 0; - move32(); + move64(); FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { - bandEnergy = L_add( bandEnergy, energy[sf][band] ); + bandEnergy = W_mac_32_32( bandEnergy, energy[sf][band], 1 ); } + shift = W_norm( bandEnergy ); + bandEnergy32 = W_extract_h( W_shl( bandEnergy, shift ) ); + bandEnergy_exp = sub( 63, add( add( hMasa->data.q_energy, 1 ), shift ) ); - IF( BASOP_Util_Cmp_Mant32Exp( Mpy_32_32( L_shr( bandEnergy, 2 ), bandRatio ), sub( 31 + 1, hMasa->data.q_energy ), threshold, exp ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( Mpy_32_32( L_shr( bandEnergy32, 2 ), bandRatio ), add( 1, bandEnergy_exp ), threshold, exp ) > 0 ) { selectedBand = band; move16(); @@ -3983,9 +3984,7 @@ static void quantize_ratio_ism_vector_ivas_fx( FOR( i = 0; i < no_ism_loc; i++ ) { - idx[i] = mult( ratio_ism_loc[i], max_sum_idx ); // exponent : ratio_ism_e + 15 - move16(); - idx[i] = shl( idx[i], sub( add( ratio_ism_e, 15 ), 15 ) ); // Q0 + idx[i] = extract_l( L_shr( L_mult0( ratio_ism_loc[i], max_sum_idx ), sub( 15, ratio_ism_e ) ) ); // Q0 move16(); part_idx_sum = add( part_idx_sum, idx[i] ); @@ -4646,7 +4645,9 @@ static void ivas_encode_masaism_metadata_fx( UWord8 numCodingBands; UWord8 numSf; Word16 brange[2]; - Word32 eneBand; + Word64 eneBand; + Word32 eneBand32; + Word16 eneBand_exp, shift; Word16 bin; Word16 obj; Word16 bits_ism[MAX_NUM_OBJECTS]; @@ -4695,11 +4696,14 @@ static void ivas_encode_masaism_metadata_fx( eneBand = 0; move16(); move16(); - move32(); + move64(); FOR( bin = brange[0]; bin < brange[1]; bin++ ) { - eneBand = L_add( eneBand, hMasa->data.energy_fx[sf][bin] ); // hMasa->data.q_energy + eneBand = W_mac_32_32( eneBand, hMasa->data.energy_fx[sf][bin], 1 ); // hMasa->data.q_energy + 1 } + shift = W_norm( eneBand ); + eneBand32 = W_extract_h( W_shl( eneBand, shift ) ); + eneBand_exp = sub( 63, add( add( hMasa->data.q_energy, 1 ), shift ) ); energy_ism = 0; energy_ism_e = 0; @@ -4733,12 +4737,12 @@ static void ivas_encode_masaism_metadata_fx( hOmasaData->energy_ratio_ism_fx[sf][0][obj] = L_shl( hOmasaData->energy_ratio_ism_fx[sf][0][obj], sub( L_tmp_e, 1 ) ); // Q30 move32(); } - L_tmp = BASOP_Util_Add_Mant32Exp( eneBand, sub( 31, hMasa->data.q_energy ), energy_ism, energy_ism_e, &L_tmp_e ); + L_tmp = BASOP_Util_Add_Mant32Exp( eneBand32, eneBand_exp, energy_ism, energy_ism_e, &L_tmp_e ); IF( L_tmp != 0 ) { - hOmasaData->masa_to_total_energy_ratio_fx[sf][0] = BASOP_Util_Divide3232_Scale_cadence( eneBand, L_tmp, &tmp ); + hOmasaData->masa_to_total_energy_ratio_fx[sf][0] = BASOP_Util_Divide3232_Scale_cadence( eneBand32, L_tmp, &tmp ); move32(); - tmp = add( tmp, sub( sub( 31, hMasa->data.q_energy ), L_tmp_e ) ); + tmp = add( tmp, sub( eneBand_exp, L_tmp_e ) ); /* Scaling to Q30 */ hOmasaData->masa_to_total_energy_ratio_fx[sf][0] = L_shl( hOmasaData->masa_to_total_energy_ratio_fx[sf][0], sub( tmp, 1 ) ); // Q30 move32(); @@ -4800,21 +4804,24 @@ static void ivas_encode_masaism_metadata_fx( move16(); eneBand = 0; - move32(); + move64(); FOR( sf = 0; sf < omasa_nblocks; sf++ ) { FOR( bin = brange[0]; bin < brange[1]; bin++ ) { - eneBand = L_add( eneBand, hMasa->data.energy_fx[sf][bin] ); // hMasa->data.q_energy + eneBand = W_mac_32_32( eneBand, hMasa->data.energy_fx[sf][bin], 1 ); // hMasa->data.q_energy + 1 } } + shift = W_norm( eneBand ); + eneBand32 = W_extract_h( W_shl( eneBand, shift ) ); + eneBand_exp = sub( 63, add( add( hMasa->data.q_energy, 1 ), shift ) ); - L_tmp = BASOP_Util_Add_Mant32Exp( eneBand, sub( 31, hMasa->data.q_energy ), energy_ism, energy_ism_e, &L_tmp_e ); + L_tmp = BASOP_Util_Add_Mant32Exp( eneBand32, eneBand_exp, energy_ism, energy_ism_e, &L_tmp_e ); IF( L_tmp != 0 ) { - hOmasaData->masa_to_total_energy_ratio_fx[0][band] = BASOP_Util_Divide3232_Scale_cadence( eneBand, L_tmp, &tmp ); + hOmasaData->masa_to_total_energy_ratio_fx[0][band] = BASOP_Util_Divide3232_Scale_cadence( eneBand32, L_tmp, &tmp ); move32(); - tmp = add( tmp, sub( sub( 31, hMasa->data.q_energy ), L_tmp_e ) ); + tmp = add( tmp, sub( eneBand_exp, L_tmp_e ) ); /* Scaling to Q30 */ hOmasaData->masa_to_total_energy_ratio_fx[0][band] = L_shl( hOmasaData->masa_to_total_energy_ratio_fx[0][band], sub( tmp, 1 ) ); // Q30 move32(); @@ -4857,18 +4864,21 @@ static void ivas_encode_masaism_metadata_fx( move16(); eneBand = 0; - move32(); + move64(); FOR( bin = brange[0]; bin < brange[1]; bin++ ) { - eneBand = L_add( eneBand, hMasa->data.energy_fx[sf][bin] ); // hMasa->data.q_energy + eneBand = W_mac_32_32( eneBand, hMasa->data.energy_fx[sf][bin], 1 ); // hMasa->data.q_energy + 1 } + shift = W_norm( eneBand ); + eneBand32 = W_extract_h( W_shl( eneBand, shift ) ); + eneBand_exp = sub( 63, add( add( hMasa->data.q_energy, 1 ), shift ) ); - L_tmp = BASOP_Util_Add_Mant32Exp( eneBand, sub( 31, hMasa->data.q_energy ), hOmasaData->energy_ism_fx[sf][band], hOmasaData->energy_ism_fx_e[sf][band], &L_tmp_e ); + L_tmp = BASOP_Util_Add_Mant32Exp( eneBand32, eneBand_exp, hOmasaData->energy_ism_fx[sf][band], hOmasaData->energy_ism_fx_e[sf][band], &L_tmp_e ); IF( L_tmp != 0 ) { - hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_cadence( eneBand, L_tmp, &tmp ); + hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_cadence( eneBand32, L_tmp, &tmp ); move32(); - tmp = add( tmp, sub( sub( 31, hMasa->data.q_energy ), L_tmp_e ) ); + tmp = add( tmp, sub( eneBand_exp, L_tmp_e ) ); /* Scaling to Q30 */ hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = L_shl( hOmasaData->masa_to_total_energy_ratio_fx[sf][band], sub( tmp, 1 ) ); // Q30 move32(); diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 17fefec7e780e2ed1ed4ae6b23bbc0d0dc06e6c9..d0316be0ff0de173e84415dc2bfe26286c531749 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -59,7 +59,7 @@ static void ivas_param_mc_range_encoder_fx( const Word16 *seq_in, const Word16 n #define ATTACKTHRESHOLD_E 4 -static void ivas_param_mc_quantize_ilds_fx( PARAM_MC_ENC_HANDLE hParamMC, Word32 Cy_fx[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], Word16 Cy_e[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], Word32 Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], Word16 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const Word16 freq_idx, const Word16 nchan_input, const Word16 nchan_transport, Word16 *ILD_idx_out, Word16 ILD_q[PARAM_MC_SZ_ILD_MAP] ); +static void ivas_param_mc_quantize_ilds_fx( PARAM_MC_ENC_HANDLE hParamMC, Word32 Cy_fx[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], Word16 Cy_e[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], Word32 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], Word16 Cx_e[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const Word16 freq_idx, const Word16 nchan_input, const Word16 nchan_transport, Word16 *ILD_idx_out, Word16 ILD_q[PARAM_MC_SZ_ILD_MAP] ); static void ivas_param_mc_parameter_quantizer_fx( const Word32 *x, const Word16 *x_e, const Word16 L, const Word16 sz_quantizer, const Word16 *quantizer_fx, const Word16 Q_quant, Word16 *quant_idx, Word16 *y ); @@ -655,8 +655,13 @@ static void ivas_param_mc_param_est_enc_fx( Word16 dmx_imag_e[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Imag Part */ Word32 a_fx, b_fx, c_fx, d_fx; /* Tmp complex values */ Word16 a_e, b_e, c_e, d_e; /* Tmp complex values */ +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Word64 Cy_sum_real_64[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; + Word64 Cy_sum_imag_64[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; +#else Word32 Cy_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; Word16 Cy_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; +#endif Word32 Cx_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 Cx_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 real_part_fx, imag_part_fx; @@ -685,13 +690,26 @@ static void ivas_param_mc_param_est_enc_fx( move16(); band_step = 1; move16(); +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAMETER_BANDS; cur_param_band++ ) + { + FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) + { + set64_fx( Cy_sum_real_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); + } + } +#endif FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC; cur_param_band++ ) { FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) { - set32_fx( Cy_sum_imag_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); - set16_fx( Cy_sum_imag_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + set64_fx( Cy_sum_imag_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); +#else + set32_fx( Cy_sum_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); + set16_fx( Cy_sum_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); +#endif } FOR( ch_idx1 = 0; ch_idx1 < PARAM_MC_MAX_TRANSPORT_CHANS; ch_idx1++ ) @@ -720,9 +738,16 @@ static void ivas_param_mc_param_est_enc_fx( } } +#if defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) || defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE ) + Word16 gb = find_guarded_bits_fx( l_ts ); + Word16 add20gb = add( 20, gb ); +#endif + FOR( ts = start_ts; ts < num_time_slots; ts++ ) { +#if !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) && !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE ) Word16 gb = find_guarded_bits_fx( l_ts ); +#endif ivas_fb_mixer_get_windowed_fr_fx( hParamMC->hFbMixer, pcm_in_fx, p_slot_frame_f_real_fx, p_slot_frame_f_imag_fx, l_ts, l_ts, hParamMC->hFbMixer->fb_cfg->num_in_chans, gb ); ivas_fb_mixer_update_prior_input_fx( hParamMC->hFbMixer, pcm_in_fx, l_ts, hParamMC->hFbMixer->fb_cfg->num_in_chans ); @@ -731,6 +756,7 @@ static void ivas_param_mc_param_est_enc_fx( FOR( i = 0; i < nchan_input; i++ ) { pcm_in_fx[i] += l_ts; + move32(); } /* Computing the downmix */ FOR( cur_param_band = 0; cur_param_band < hParamMC->max_param_band_abs_cov; cur_param_band++ ) @@ -748,6 +774,7 @@ static void ivas_param_mc_param_est_enc_fx( FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 ) { +#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE dmx_real_fx[ch_idx1] = 0; move32(); dmx_real_e[ch_idx1] = 0; @@ -766,6 +793,28 @@ static void ivas_param_mc_param_est_enc_fx( move32(); p_dmx_fac_fx++; } +#else + Word32 real_fx = L_add( 0, 0 ); + Word16 real_e = add( 0, 0 ); + Word32 imag_fx = L_add( 0, 0 ); + Word16 imag_e = add( 0, 0 ); + FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) + { + L_tmp = Mpy_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); + real_fx = BASOP_Util_Add_Mant32Exp( real_fx, real_e, L_tmp, add20gb, &real_e ); + L_tmp = Mpy_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); + imag_fx = BASOP_Util_Add_Mant32Exp( imag_fx, imag_e, L_tmp, add20gb, &imag_e ); + p_dmx_fac_fx++; + } + dmx_real_fx[ch_idx1] = real_fx; + dmx_real_e[ch_idx1] = real_e; + dmx_imag_fx[ch_idx1] = imag_fx; + dmx_imag_e[ch_idx1] = imag_e; + move32(); + move16(); + move32(); + move16(); +#endif } /* Cx for transport channels */ @@ -801,17 +850,79 @@ static void ivas_param_mc_param_est_enc_fx( move32(); } } - +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + { + a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; + b_fx = slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band]; + move32(); + FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) + { + Word16 norm; + c_fx = slot_frame_f_real_fx[ch_idx2][cur_cldfb_band]; + d_fx = slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band]; + move32(); + // Conjugated complex multiplication (a-ib)(c+id) = ac+bd + i(ad-bc) + Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], + W_add( W_mult0_32_32( a_fx, c_fx ), W_mult0_32_32( b_fx, d_fx ) ) ); + move64(); + Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] = W_add( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2], + W_sub( W_mult0_32_32( a_fx, d_fx ), W_mult0_32_32( b_fx, c_fx ) ) ); + move64(); + + // convert the 64 bit fixpoint back into the 48 bit float format + norm = W_norm( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); + Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], norm ) ); + Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] = sub( sub( 62, gb ), norm ); + } + } +#else /* Cy for input channels */ FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { +#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE + a_e = norm_l( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band] ); + a_fx = L_shl( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], a_e ); + a_e = sub( add20gb, a_e ); + if ( a_fx == 0 ) + { + a_e = 0; + move16(); + } + b_e = norm_l( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band] ); + b_fx = L_shl( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], b_e ); + b_e = sub( add20gb, b_e ); + if ( b_fx == 0 ) + { + b_e = 0; + move16(); + } +#endif FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { +#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE a_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &a_e ); b_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &b_e ); c_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &c_e ); d_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &d_e ); - +#else + c_e = norm_l( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band] ); + c_fx = L_shl( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], c_e ); + c_e = sub( add20gb, c_e ); + if ( c_fx == 0 ) + { + c_e = 0; + move16(); + } + d_e = norm_l( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band] ); + d_fx = L_shl( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], d_e ); + d_e = sub( add20gb, d_e ); + if ( d_fx == 0 ) + { + d_e = 0; + move16(); + } +#endif /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], @@ -823,6 +934,7 @@ static void ivas_param_mc_param_est_enc_fx( move32(); } } +#endif } } @@ -841,6 +953,7 @@ static void ivas_param_mc_param_est_enc_fx( FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 ) { +#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE dmx_real_fx[ch_idx1] = 0; move32(); dmx_real_e[ch_idx1] = 0; @@ -860,13 +973,49 @@ static void ivas_param_mc_param_est_enc_fx( move32(); p_dmx_fac_fx++; } +#else + Word32 real_fx = L_add( 0, 0 ); + Word16 real_e = 0; + move16(); + Word32 imag_fx = L_add( 0, 0 ); + Word16 imag_e = 0; + move16(); + + FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) + { + L_tmp = Mpy_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); + real_fx = BASOP_Util_Add_Mant32Exp( real_fx, real_e, L_tmp, add20gb, &real_e ); + L_tmp = Mpy_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); + imag_fx = BASOP_Util_Add_Mant32Exp( imag_fx, imag_e, L_tmp, add20gb, &imag_e ); + p_dmx_fac_fx++; + } + dmx_real_fx[ch_idx1] = real_fx; + move32(); + dmx_real_e[ch_idx1] = real_e; + move16(); + dmx_imag_fx[ch_idx1] = imag_fx; + move32(); + dmx_imag_e[ch_idx1] = imag_e; + move16(); +#endif } /* Cx for transport channels */ FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 ) { +#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE + a_fx = dmx_real_fx[ch_idx1]; + move32(); + a_e = dmx_real_e[ch_idx1]; + move16(); + b_fx = dmx_imag_fx[ch_idx1]; + move32(); + b_e = dmx_imag_e[ch_idx1]; + move16(); +#endif FOR( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) { +#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE a_fx = dmx_real_fx[ch_idx1]; move32(); a_e = dmx_real_e[ch_idx1]; @@ -888,6 +1037,12 @@ static void ivas_param_mc_param_est_enc_fx( L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); +#else + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, dmx_real_fx[ch_idx2] ), add( a_e, dmx_real_e[ch_idx2] ), Mpy_32_32( b_fx, dmx_imag_fx[ch_idx2] ), add( b_e, dmx_imag_e[ch_idx2] ), &tmp_e ); + Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, + &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); +#endif move32(); } } @@ -895,19 +1050,78 @@ static void ivas_param_mc_param_est_enc_fx( /* Cy for input channels */ FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { +#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE + a_e = norm_l( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band] ); + a_fx = L_shl( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], a_e ); + a_e = sub( add20gb, a_e ); + if ( a_fx == 0 ) + { + a_e = 0; + move16(); + } + b_e = norm_l( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band] ); + b_fx = L_shl( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], b_e ); + b_e = sub( add20gb, b_e ); + if ( b_fx == 0 ) + { + b_e = 0; + move16(); + } +#endif +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; + b_fx = slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band]; + move32(); + move32(); + FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) + { + Word16 norm; + c_fx = slot_frame_f_real_fx[ch_idx2][cur_cldfb_band]; + d_fx = slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band]; + move32(); + move32(); + // Conjugated complex multiplication (a-ib)(c+id) = ac+bd + i(ad-bc) + Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], + W_add( W_mult0_32_32( a_fx, c_fx ), W_mult0_32_32( b_fx, d_fx ) ) ); + move64(); + // convert the 64 bit fixpoint back into the 48 bit float format + norm = W_norm( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); + Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], norm ) ); + Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] = sub( sub( 62, gb ), norm ); + } +#else FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { +#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE a_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &a_e ); b_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &b_e ); c_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &c_e ); d_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &d_e ); - +#else + c_e = norm_l( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band] ); + c_fx = L_shl( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], c_e ); + c_e = sub( add20gb, c_e ); + if ( c_fx == 0 ) + { + c_e = 0; + move16(); + } + d_e = norm_l( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band] ); + d_fx = L_shl( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], d_e ); + d_e = sub( add20gb, d_e ); + if ( d_fx == 0 ) + { + d_e = 0; + move16(); + } +#endif /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, &Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] ); move32(); } +#endif } } } @@ -929,6 +1143,16 @@ static void ivas_param_mc_param_est_enc_fx( move32(); Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; move16(); +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; + move64(); + Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; + move64(); + Cy_sum_imag_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; + move64(); + Cy_sum_imag_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; + move64(); +#else Cy_sum_imag_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; move32(); Cy_sum_imag_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; @@ -937,6 +1161,7 @@ static void ivas_param_mc_param_est_enc_fx( move32(); Cy_sum_imag_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; move16(); +#endif } } @@ -944,6 +1169,12 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; + move64(); + Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; + move64(); +#endif Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; move32(); Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; @@ -988,10 +1219,18 @@ static void ivas_param_mc_param_est_enc_fx( /* get ICLDs */ FOR( k = 0; k < nchan_input; ++k ) { +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Word16 norm; + // convert the 64 bit fixpoint back into the 48 bit float format + norm = W_norm( Cy_sum_real_64[cur_param_band][k][k] ); + Nrg_fx[k] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][k][k], norm ) ); + Nrg_e[k] = sub( sub( 62, gb ), norm ); +#else Nrg_fx[k] = Cy_sum_fx[cur_param_band][k][k]; move32(); Nrg_e[k] = Cy_sum_e[cur_param_band][k][k]; move16(); +#endif } FOR( k = 0; k < num_ilds_to_code; ++k ) { @@ -1010,11 +1249,7 @@ static void ivas_param_mc_param_est_enc_fx( Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx], &ref_ener_e ); } L_tmp = Mpy_32_16_1( ref_ener_fx, hParamMC->hMetadataPMC.ild_factors_fx[k] ); -#ifdef FIX_ISSUE_1154 L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], L_add( L_tmp, EPSILLON_FX ), &tmp_e ) ); -#else - L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], L_tmp, &tmp_e ) ); -#endif tmp_e = add( sub( Nrg_e[h_ild_mapping->ild_index[k]], ref_ener_e ), tmp_e ); @@ -1062,6 +1297,13 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); + move64(); + Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] ); + move64(); + +#else Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], &Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2] ); @@ -1070,6 +1312,7 @@ static void ivas_param_mc_param_est_enc_fx( Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2], &Cy_sum_imag_e[cur_param_band - 1][ch_idx1][ch_idx2] ); move32(); +#endif } } } @@ -1093,10 +1336,14 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); +#else Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], &Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2] ); move32(); +#endif } } } @@ -1105,7 +1352,24 @@ static void ivas_param_mc_param_est_enc_fx( band_step = 2; move16(); } - +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + { + // convert the 64 bit fixpoint back into the 48 bit float format + FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAMETER_BANDS; cur_param_band++ ) + { + FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 < MAX_CICP_CHANNELS; ch_idx2++ ) + { + Word16 norm; + norm = W_norm( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); + Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], norm ) ); + Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] = sub( sub( 62, gb ), norm ); + } + } + } + } +#endif /* map complex covariances to real values */ FOR( cur_param_band = 0; cur_param_band < hParamMC->max_param_band_abs_cov; cur_param_band += band_step ) @@ -1142,15 +1406,22 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ ) { - real_part_fx = Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2]; - move32(); - real_part_e = Cy_sum_e[cur_param_band][ch_idx1][ch_idx2]; - move16(); +#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE + Word16 norm; + // convert the 64 bit fixpoint back into the 48 bit float format + norm = W_norm( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] ); + imag_part_fx = W_extract_h( W_shl( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2], norm ) ); + imag_part_e = sub( sub( 62, gb ), norm ); +#else imag_part_fx = Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2]; move32(); imag_part_e = Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2]; move16(); - +#endif + real_part_fx = Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2]; + move32(); + real_part_e = Cy_sum_e[cur_param_band][ch_idx1][ch_idx2]; + move16(); real_part_fx = Mpy_32_32( real_part_fx, real_part_fx ); imag_part_fx = Mpy_32_32( imag_part_fx, imag_part_fx ); @@ -1280,8 +1551,21 @@ static void ivas_param_mc_quantize_ilds_fx( dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, Cx_fx[k][k], Cx_e[k][k], &dmx_ener_e ); } /*ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) )*/ - tot_ener_fx = BASOP_Util_Add_Mant32Exp( tot_ener_fx, tot_ener_e, EPSILON_FX, 0, &tot_ener_e ); - dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, EPSILON_FX, 0, &dmx_ener_e ); + IF( tot_ener_fx == 0 ) + { + tot_ener_fx = 9223; // 1e-15(EPSILON) in Q63 + tot_ener_e = -32; + move32(); + move16(); + } + IF( dmx_ener_fx == 0 ) + { + dmx_ener_fx = 9223; // 1e-15(EPSILON) in Q63 + dmx_ener_e = -32; + move32(); + move16(); + } + L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tot_ener_fx, dmx_ener_fx, &tmp_e ) ); tmp_e = add( sub( tot_ener_e, dmx_ener_e ), tmp_e ); ener_fac_fx = BASOP_Util_Log10( L_tmp, tmp_e ); // Q25 @@ -1392,11 +1676,7 @@ static void ivas_param_mc_quantize_ilds_fx( ref_ener_fx = BASOP_Util_Add_Mant32Exp( ref_ener_fx, ref_ener_e, Cx_fx[ref_channel_idx][ref_channel_idx], Cx_e[ref_channel_idx][ref_channel_idx], &ref_ener_e ); } ref_ener_fx = Mpy_32_16_1( ref_ener_fx, hParamMC->hMetadataPMC.ild_factors_fx[k] ); -#ifdef FIX_ISSUE_1154 L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], L_add( ref_ener_fx, EPSILLON_FX ), &tmp_e ) ); -#else - L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], ref_ener_fx, &tmp_e ) ); -#endif tmp_e = add( sub( Nrg_e[h_ild_mapping->ild_index[k]], ref_ener_e ), tmp_e ); /*10 in Q21 = 1342177280*/ ILD_fx[k] = Mpy_32_32( 1342177280, BASOP_Util_Log10( L_tmp, tmp_e ) ); // Q21 diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index fd5cb6217312681796dd7e0a35c92230fb7efc2f..cad29b1461033258b0bc71d37f575a2d8552c7e1 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -1040,12 +1040,6 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx( IF( LT_16( maxbands, IVAS_MAX_NUM_BANDS ) ) { -#ifndef FIX_1133_IMPROVE_MC_MLD - *exp_alphas = 0; - move16(); - *exp_betas = 0; - move16(); -#endif FOR( b = 0; b < MC_PARAMUPMIX_COMBINATIONS; b++ ) { FOR( bnd = maxbands; bnd < IVAS_MAX_NUM_BANDS; bnd++ ) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 22f21dceb020c4852d8d97ed129dbd7a9b48d25b..7a5718e9958d3eb7989f4168b4c8876fcc84f3c5 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -940,13 +940,11 @@ void ivas_mcmasa_param_est_enc_fx( Word16 surroundingCoherence_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 numAnalysisChannels; -#ifdef MSAN_FIX FOR( i = 0; i < MCMASA_MAX_ANA_CHANS; i++ ) { set_zero_fx( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ); set_zero_fx( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ); } -#endif num_freq_bins = idiv1616( input_frame, MDFT_NO_COL_MAX ); num_freq_bands = hMcMasa->nbands; @@ -1180,12 +1178,8 @@ void ivas_mcmasa_param_est_enc_fx( num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], - direction_vector_fx[2], c_e -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - , - NULL -#endif - ); + direction_vector_fx[2], c_e, + NULL ); /* Power and intensity estimation for diffuseness */ computeIntensityVector_enc_fx( diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 71515571d02cb289ea4d7438f1370decbcff0162..548a5671741574d9d44a77d61906e8c9e8c8e2e9 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -270,7 +270,6 @@ void ivas_mct_core_enc_fx( nCPE = add( nCPE, 1 ); } -#ifdef MSAN_FIX FOR( ch = 0; ch < MCT_MAX_CHANNELS; ch++ ) { set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); @@ -278,7 +277,6 @@ void ivas_mct_core_enc_fx( move16(); set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX ); } -#endif // MSAN_FIX FOR( ch = 0; ch < nChannels; ch++ ) { set32_fx( inv_spectrum_long_fx[ch], 0, L_FRAME48k ); @@ -334,7 +332,6 @@ void ivas_mct_core_enc_fx( IF( switch_bw ) { -#ifdef FIX_USAN_ISSUES IF( sts[ch_core]->hIGFEnc == NULL ) { initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, @@ -345,10 +342,6 @@ void ivas_mct_core_enc_fx( initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 ); } -#else - initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, - sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 ); -#endif } IF( sts[ch_core]->igf ) @@ -653,11 +646,7 @@ void ivas_mct_core_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); -#ifndef MSAN_FIX - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); -#else ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); -#endif st->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec ); st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index a8ba9a3202c2f5ad298c482148b2292a7b95ca8b..66bdb1235b492cfd383cd176295a6c5afbc656ee 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -1072,7 +1072,7 @@ void mctStereoIGF_enc_fx( IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[n] ) || EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) ) { - + Word16 exp_powerSpec_tmp[CPE_CHANNELS]; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { s = s_min( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[n] ) ); @@ -1095,10 +1095,12 @@ void mctStereoIGF_enc_fx( move16(); move16(); } - - ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, - p_orig_spectrum_fx, q_origSpec, q_origSpec, - p_powerSpec_fx, p_powerSpecMsInv_fx, p_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 ); + exp_powerSpec_tmp[0] = p_st[0]->hTcxEnc->spectrum_e[0]; + exp_powerSpec_tmp[1] = p_st[1]->hTcxEnc->spectrum_e[0]; + move16(); + move16(); + ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_tmp, + p_powerSpecMsInv_fx, exp_powerSpec_tmp, p_inv_spectrum_fx, exp_powerSpec_tmp, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 ); } ELSE { @@ -1116,11 +1118,7 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX ); -#ifndef MSAN_FIX - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); -#else ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); -#endif st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); move16(); @@ -1161,11 +1159,7 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); -#ifndef MSAN_FIX - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); -#else ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); -#endif st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); move16(); diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 9f674473ecec6f4e2b009791b04c1debadaf6f7b..e744c7f47379813ea4e9b180f2e91de1c8b0e821 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -370,15 +370,16 @@ static void kernel_switch_trafo_fx( static void kernel_switch_update_transforms_fx( - Word32 *sigR, /* i/o: MDCT samples of the given channel (*q_sig) */ - Word32 *sigI, /* i/o: MDST samples of the given channel (*q_sig) */ - Word16 *q_sig, /* i/o: Common Q of MDCT and MDST samples of the given channel */ - const Word16 tcxTransType, /* i : TCX transform type, cf also above */ - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration handle, pointer */ - const Word16 bwidthSwCnt, /* i : bandwidth switching counter in st */ - const UWord16 kernelType, /* i : TCX transform kernel type (0 - 3) */ - Word16 *tcxTimeSignal, /* i : hTcxEnc->new_speech_TCX buf in st */ - const Word16 *speech_TCX, /* i : hTcxEnc->speech_TCX buffer in st */ + Word32 *sigR, /* i/o: MDCT samples of the given channel (*q_sig) */ + Word32 *sigI, /* i/o: MDST samples of the given channel (*q_sig) */ + Word16 *q_sig, /* i/o: Common Q of MDCT and MDST samples of the given channel */ + const Word16 tcxTransType, /* i : TCX transform type, cf also above */ + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration handle, pointer */ + const Word16 bwidthSwCnt, /* i : bandwidth switching counter in st */ + const UWord16 kernelType, /* i : TCX transform kernel type (0 - 3) */ + Word16 *tcxTimeSignal, /* i : hTcxEnc->new_speech_TCX buf in st */ + const Word16 *speech_TCX, /* i : hTcxEnc->speech_TCX buffer in st */ + const Word16 q_speech, Word32 *windowedTimeSignal, /* i/o: windowed input and scratch buffer (*q_windowedTimeSignal) */ Word16 *q_windowedTimeSignal, /* i/o: Q of windowed input and scratch buffer */ const Word16 L_subframe /* i : transform length (number of bins) */ @@ -429,19 +430,11 @@ static void kernel_switch_update_transforms_fx( Word32 factor; n = extract_l( Mpy_32_32( s, 603979776 /* N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q31 */ ) ); -#ifdef MSAN_FIX - Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), -Q1 ); // Q0 -> Q-1 -#else - Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), -Q1 ); // Q0 -> Q-1 -#endif + Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), sub( -Q1, q_speech ) ); // q_speech -> Q-1 wtda_ext_fx( tcxTimeSignal, windowedTimeSignal_16, extract_l( windowedTimeSignal[0] ), extract_l( windowedTimeSignal[1] ), s, kernelType ); // Q-2 -#ifdef MSAN_FIX - Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), Q1 ); // Q-1 -> Q0 -#else - Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), Q1 ); // Q-1 -> Q0 -#endif - Copy_Scale_sig_16_32_no_sat( windowedTimeSignal_16 /* Q(-2) */, windowedTimeSignal, s, Q16 ); // Q14 - scale_sig32( windowedTimeSignal, s, -Q8 /* guard bits */ ); // Q6 + Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), sub( q_speech, -Q1 ) ); // Q-1 -> q_speech + Copy_Scale_sig_16_32_no_sat( windowedTimeSignal_16 /* Q(-2) */, windowedTimeSignal, s, Q16 ); // Q14 + scale_sig32( windowedTimeSignal, s, -Q8 /* guard bits */ ); // Q6 edxt_fx( windowedTimeSignal, sigR, s, kernelType, FALSE ); tmp = BASOP_Util_Divide1616_Scale( NORM_MDCT_FACTOR, s, &exp_tmp ); @@ -473,21 +466,22 @@ static void kernel_switch_update_transforms_fx( { Word16 tmp = shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ); Word32 L_tmp; + Word16 shift = sub( *q_windowedTimeSignal, add( Q16, q_speech ) ); IF( GE_32( kernelType, MDCT_II ) ) { FOR( i = minWindowLen; i >= tmp; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( speech_TCX[-1 - i], hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( *q_windowedTimeSignal, Q16 ) ); // *q_windowedTimeSignal + L_tmp = L_mult( speech_TCX[-1 - i], hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (q_speech, Q15) -> Q16 + q_speech + L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_speech, Q15) -> Q16 + q_speech + L_tmp = L_shl( L_tmp, shift ); // *q_windowedTimeSignal windowedTimeSignal[2 + leftOverlap + i] = L_add( windowedTimeSignal[2 + leftOverlap + i], L_tmp ); // *q_windowedTimeSignal move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( speech_TCX[-1 - i], hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( *q_windowedTimeSignal, Q16 ) ); // *q_windowedTimeSignal + L_tmp = L_mult( speech_TCX[-1 - i], hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (q_speech, Q15) -> Q16 + q_speech + L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_speech, Q15) -> Q16 + q_speech + L_tmp = L_shl( L_tmp, shift ); // *q_windowedTimeSignal windowedTimeSignal[2 + leftOverlap + i] = L_add( windowedTimeSignal[2 + leftOverlap + i], L_tmp ); // *q_windowedTimeSignal move32(); } @@ -496,17 +490,17 @@ static void kernel_switch_update_transforms_fx( { FOR( i = minWindowLen; i >= tmp; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( negate( speech_TCX[-1 - i] ), hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( *q_windowedTimeSignal, Q16 ) ); // *q_windowedTimeSignal + L_tmp = L_mult( negate( speech_TCX[-1 - i] ), hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (q_speech, Q15) -> Q16 + q_speech + L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_speech, Q15) -> Q16 + q_speech + L_tmp = L_shl( L_tmp, shift ); // *q_windowedTimeSignal windowedTimeSignal[2 + leftOverlap + i] = L_add( windowedTimeSignal[2 + leftOverlap + i], L_tmp ); // *q_windowedTimeSignal move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - L_tmp = L_mult( negate( speech_TCX[-1 - i] ), hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 - L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( *q_windowedTimeSignal, Q16 ) ); // *q_windowedTimeSignal + L_tmp = L_mult( negate( speech_TCX[-1 - i] ), hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] ); // (q_speech, Q15) -> Q16 + q_speech + L_tmp = Mpy_32_16_1( L_tmp, hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_speech, Q15) -> Q16 + q_speech + L_tmp = L_shl( L_tmp, shift ); // *q_windowedTimeSignal windowedTimeSignal[2 + leftOverlap + i] = L_add( windowedTimeSignal[2 + leftOverlap + i], L_tmp ); // *q_windowedTimeSignal move32(); } @@ -545,11 +539,7 @@ static void kernel_switch_update_transforms_fx( Copy_Scale_sig_32_16( windowedTimeSignal + 2, windowedTimeSignal_16 + 2, add( s, shr( add( leftOverlap, rightOverlap ), 1 ) ), -Q16 ); // *q_windowedTimeSignal - Q16 WindowSignal( hTcxCfg, shr( leftOverlap, 1 ), RECTANGULAR_OVERLAP, MIN_OVERLAP, &leftOverlap, &rightOverlap, windowedTimeSignal_16 + 2, &s, tcx5Win, 0, 1 ); // *q_windowedTimeSignal - Q16 Copy_Scale_sig_16_32_no_sat( tcx5Win, tcx5Win_32, add( s, shr( add( leftOverlap, rightOverlap ), 1 ) ), Q16 ); // *q_windowedTimeSignal -#ifdef FIX_ISSUE_1157 q_shift = -Q8; -#else - q_shift = -Q7; -#endif move16(); scale_sig32( tcx5Win_32, add( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), q_shift ); // *q_windowedTimeSignal + q_shift kernel_switch_trafo_fx( tcx5Win_32, sigR, leftOverlap, sub( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), rightOverlap, kernelType ); // *q_windowedTimeSignal + q_shift @@ -579,11 +569,7 @@ static void kernel_switch_update_transforms_fx( ELSE /* tcxTransType != TCX_5 */ { Word16 q_shift, q_com, q_temp; -#ifdef FIX_ISSUE_1157 q_shift = -Q8; -#else - q_shift = -Q7; -#endif move16(); scale_sig32( windowedTimeSignal + 2, add( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), q_shift ); // *q_windowedTimeSignal + q_shift kernel_switch_trafo_fx( windowedTimeSignal + 2, sigR, leftOverlap, sub( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), rightOverlap, kernelType ); // *q_windowedTimeSignal + q_shift @@ -912,13 +898,8 @@ static UWord16 enc_ste_pre_mdct( absMagnR_fx = Sqrt32( L_add( Mpy_32_32( sigR1_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI1_fx[s], sigI1_fx[s] ) ), &absMagnR_e ); corr_fx = L_add( corr_fx, L_add( Mpy_32_32( sigR0_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI0_fx[s], sigI1_fx[s] ) ) ); // q_com*2 - 31 -#ifdef FIX_ISSUE_1092 - sumL_fx = L_add( sumL_fx, L_add( L_shr( sigR0_fx[s], 1 ), L_shr( sigI0_fx[s], 1 ) ) ); // q_com -1 - sumR_fx = L_add( sumR_fx, L_add( L_shr( sigR1_fx[s], 1 ), L_shr( sigI1_fx[s], 1 ) ) ); // q_com - 1 -#else - sumL_fx = L_add( sumL_fx, L_add( sigR0_fx[s], sigI0_fx[s] ) ); // q_com - sumR_fx = L_add( sumR_fx, L_add( sigR1_fx[s], sigI1_fx[s] ) ); // q_com -#endif + sumL_fx = L_add( sumL_fx, L_add( L_shr( sigR0_fx[s], 1 ), L_shr( sigI0_fx[s], 1 ) ) ); // q_com -1 + sumR_fx = L_add( sumR_fx, L_add( L_shr( sigR1_fx[s], 1 ), L_shr( sigI1_fx[s], 1 ) ) ); // q_com - 1 sumMagnL_fx = BASOP_Util_Add_Mant32Exp( sumMagnL_fx, sumMagnL_e, absMagnL_fx, absMagnL_e, &sumMagnL_e ); sumMagnR_fx = BASOP_Util_Add_Mant32Exp( sumMagnR_fx, sumMagnR_e, absMagnR_fx, absMagnR_e, &sumMagnR_e ); sumPrdLR_fx = BASOP_Util_Add_Mant32Exp( sumPrdLR_fx, sumPrdLR_e, Mpy_32_32( absMagnL_fx, absMagnR_fx ), add( absMagnL_e, absMagnR_e ), &sumPrdLR_e ); @@ -930,11 +911,7 @@ static UWord16 enc_ste_pre_mdct( temp1 = L_shl( preproLen, x1 ); corr_fx = Mpy_32_32( corr_fx, temp1 ); x1 = sub( 62, add( shl( *q_com, 1 ), x1 ) ); -#ifdef FIX_ISSUE_1092 corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( sub( *q_com, 1 ), 1 ) ), &x1 ); -#else - corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( *q_com, 1 ) ), &x1 ); -#endif IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( corr_fx, x1, -maxSqrValue_fx, 52 ), -1 ) ) { @@ -1181,7 +1158,6 @@ void ivas_mdct_core_whitening_enc_fx( push_wmops( "mdct_core_whitening" ); -#ifdef MSAN_FIX FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { FOR( i = 0; i < NB_DIV; i++ ) @@ -1195,7 +1171,6 @@ void ivas_mdct_core_whitening_enc_fx( set16_fx( orig_spectrum_e[ch], 0, NB_DIV ); } set16_fx( q_windowedSignal, Q31, CPE_CHANNELS ); -#endif q_com = Q31; q_min = 0; move16(); @@ -1235,9 +1210,7 @@ void ivas_mdct_core_whitening_enc_fx( orig_spectrum[ch][1] = orig_spectrum_long[ch] + N_TCX10_MAX; mdst_spectrum_fx[ch][0] = mdst_spectrum_long_fx[ch]; mdst_spectrum_fx[ch][1] = mdst_spectrum_long_fx[ch] + N_TCX10_MAX; -#ifdef MSAN_FIX set32_fx( temp_buffer, 0, 15 * L_FRAME48k / 8 ); -#endif } windowedSignal_fx[0] = orig_spectrum_long[0]; /* NOTE temporarily available */ @@ -1280,6 +1253,9 @@ void ivas_mdct_core_whitening_enc_fx( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; + init_tcx_enc_info_fx( st, &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); + st->hTcxEnc->spectrum_length = L_subframeTCX; + IF( GE_16( add( imult1616( hCPE->cpe_id, CPE_CHANNELS ), ch ), nChannels ) ) { CONTINUE; @@ -1309,16 +1285,17 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { Word16 spect_fx[L_FRAME48k]; - Word16 q_spectrum, l_frame; + Word16 q_spectrum, lshift, l_frame; /*l_frame = (int16_t)(st->input_Fs / FRAMES_PER_SEC); 1 / FRAMES_PER_SEC = 0.2f */ l_frame = extract_l( Mpy_32_32( st->input_Fs, 42949673 /* 0.2f in Q31 */ ) ); if ( EQ_16( st->core, TCX_10_CORE ) ) { l_frame = shr( l_frame, 1 ); } - q_spectrum = L_norm_arr( st->hTcxEnc->spectrum_fx[n], l_frame ); - Copy_Scale_sig32_16( st->hTcxEnc->spectrum_fx[n], spect_fx, l_frame, q_spectrum ); - bw_detect_fx( st, NULL, spect_fx, NULL, NULL, MC_FORMAT /*just cannot be ISM_FORMAT*/, mct_on ); + lshift = L_norm_arr( st->hTcxEnc->spectrum_fx[n], l_frame ); + Copy_Scale_sig32_16( st->hTcxEnc->spectrum_fx[n], spect_fx, l_frame, lshift ); + q_spectrum = sub( add( sub( Q31, st->hTcxEnc->spectrum_e[n] ), lshift ), 16 ); + bw_detect_fx( st, NULL, spect_fx, NULL, NULL, MC_FORMAT /*just cannot be ISM_FORMAT*/, mct_on, q_spectrum ); test(); if ( EQ_16( nSubframes, NB_DIV ) && n == 0 ) @@ -1402,16 +1379,16 @@ void ivas_mdct_core_whitening_enc_fx( q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); // q_com - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); // q_com - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); // q_com - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); // q_com + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); // q_com + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); // q_com + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); // q_com + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); // q_com const Word16 switchKernel = /* these 4 transform types can be applied: 0 = MDCT-IV, 1 = MDST-II, 2 = MDCT-II, 3 = MDST-IV */ kernel_switch_detect_fx( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], q_com, nSampCore / nSubframes, @@ -1499,11 +1476,11 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( mdst_spectrum_e[0][n], hTcxEnc0->spectrum_e[n] ); q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); // q_com - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); // q_com + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); // q_com + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->spectrum_length, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); // q_com speech = NULL; if ( NE_16( n, 1 ) ) @@ -1511,7 +1488,7 @@ void ivas_mdct_core_whitening_enc_fx( speech = hTcxEnc0->speech_TCX; } kernel_switch_update_transforms_fx( hTcxEnc0->spectrum_fx[n], mdst_spectrum_fx[0][n], &q_com, hTcxEnc0->transform_type[n], sts[0]->hTcxCfg, sts[0]->bwidth_sw_cnt, hTcxEnc0->kernel_type[n], - hTcxEnc0->new_speech_TCX, speech, windowedSignal_fx[0] + i_mult( n, L_FRAME48k ), &q_windowedSignal[0], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); + hTcxEnc0->new_speech_TCX, speech, sts[0]->q_inp, windowedSignal_fx[0] + i_mult( n, L_FRAME48k ), &q_windowedSignal[0], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); mdst_spectrum_e[0][n] = sub( Q31, q_com ); hTcxEnc0->spectrum_e[n] = sub( Q31, q_com ); move16(); @@ -1520,11 +1497,11 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( mdst_spectrum_e[1][n], hTcxEnc1->spectrum_e[n] ); q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); // q_com - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); // q_com + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); // q_com + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->spectrum_length, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); // q_com speech = NULL; if ( NE_16( n, 1 ) ) @@ -1532,7 +1509,7 @@ void ivas_mdct_core_whitening_enc_fx( speech = hTcxEnc1->speech_TCX; } kernel_switch_update_transforms_fx( hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[1][n], &q_com, hTcxEnc1->transform_type[n], sts[1]->hTcxCfg, sts[1]->bwidth_sw_cnt, hTcxEnc1->kernel_type[n], - hTcxEnc1->new_speech_TCX, speech, windowedSignal_fx[1] + i_mult( n, L_FRAME48k ), &q_windowedSignal[1], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); + hTcxEnc1->new_speech_TCX, speech, sts[1]->q_inp, windowedSignal_fx[1] + i_mult( n, L_FRAME48k ), &q_windowedSignal[1], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); mdst_spectrum_e[1][n] = sub( Q31, q_com ); hTcxEnc1->spectrum_e[n] = sub( Q31, q_com ); move16(); @@ -1561,7 +1538,7 @@ void ivas_mdct_core_whitening_enc_fx( move16(); /* length = max(nSampCore / (2 * NB_DIV), L_subframeTCX / (2 * NB_DIV), NB_DIV = 2 */ length = shr( s_max( nSampCore, L_subframeTCX ), 2 ); - len_sbfr = shr( hTcxEnc0->L_frameTCX, shift ); + len_sbfr = shr( hTcxEnc0->spectrum_length, shift ); assert( hTcxEnc0->L_frameTCX == hTcxEnc1->L_frameTCX ); exp_max = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); exp_max = s_max( exp_max, mdst_spectrum_e[0][n] ); @@ -1653,22 +1630,22 @@ void ivas_mdct_core_whitening_enc_fx( { Word16 length; length = shr( s_max( nSampCore, L_subframeTCX ), shift ); // max(/* nSampCore/nSubframes, L_subframeTCX/nSubframes) */ - Word16 offset2 = sub( shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, length ); + Word16 offset2 = sub( shr( hTcxEnc0->spectrum_length, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, length ); exp_max = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); exp_max = s_max( exp_max, mdst_spectrum_e[0][n] ); exp_max = s_max( exp_max, mdst_spectrum_e[1][n] ); - exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->spectrum_length, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->spectrum_length, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->spectrum_length, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->spectrum_length, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 ); exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->spectrum_length, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->spectrum_length, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->spectrum_length, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->spectrum_length, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e Word16 q_com_orig = q_com; move16(); @@ -1753,12 +1730,12 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( mdst_spectrum_e[ch][n], hTcxEncCh->spectrum_e[n] ); q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/ ), L_norm_arr( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->spectrum_length, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/ ), L_norm_arr( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->spectrum_length, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEncCh->spectrum_e[n] ) ) ); // q_com - Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); // q_com + Scale_sig32( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->spectrum_length, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEncCh->spectrum_e[n] ) ) ); // q_com + Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->spectrum_length, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); // q_com speech = hTcxEncCh->speech_TCX; if ( n != 0 ) @@ -1766,7 +1743,7 @@ void ivas_mdct_core_whitening_enc_fx( speech = NULL; } kernel_switch_update_transforms_fx( hTcxEncCh->spectrum_fx[n], mdst_spectrum_fx[ch][n], &q_com, hTcxEncCh->transform_type[n], sts[ch]->hTcxCfg, sts[ch]->bwidth_sw_cnt, hTcxEncCh->kernel_type[n], - hTcxEncCh->new_speech_TCX, speech, windowedSignal_fx[ch] + i_mult( n, L_FRAME48k ), &q_windowedSignal[ch], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); + hTcxEncCh->new_speech_TCX, speech, sts[ch]->q_inp, windowedSignal_fx[ch] + i_mult( n, L_FRAME48k ), &q_windowedSignal[ch], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); mdst_spectrum_e[ch][n] = sub( Q31, q_com ); move16(); hTcxEncCh->spectrum_e[n] = sub( Q31, q_com ); @@ -1798,7 +1775,7 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { q_min = s_max( q_min, hTcxEnc->spectrum_e[n] ); - q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); } } q_min = sub( Q31, q_min ); @@ -1820,7 +1797,7 @@ void ivas_mdct_core_whitening_enc_fx( } FOR( n = 0; n < nSubframes; n++ ) { - Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); // q_com + Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); // q_com hTcxEnc->spectrum_e[n] = sub( Q31, q_com ); move16(); } @@ -1854,8 +1831,8 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( q_min, hTcxEnc->spectrum_e[n] ); q_min = s_max( q_min, mdst_spectrum_e[ch][n] ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); - q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); } } q_min = sub( Q31, q_min ); @@ -1878,8 +1855,8 @@ void ivas_mdct_core_whitening_enc_fx( } FOR( n = 0; n < nSubframes; n++ ) { - Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); // q_com - Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); // q_com + Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); // q_com + Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); // q_com hTcxEnc->spectrum_e[n] = sub( Q31, q_com ); move16(); mdst_spectrum_e[ch][n] = sub( Q31, q_com ); @@ -2166,7 +2143,7 @@ void ivas_mdct_core_whitening_enc_fx( { q_min = s_max( q_min, hTcxEnc->spectrum_e[n] ); - q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); } } q_min = sub( Q31, q_min ); @@ -2190,7 +2167,7 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { - Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( 31, hTcxEnc->spectrum_e[n] ) ) ); // q_com + Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->spectrum_length, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( 31, hTcxEnc->spectrum_e[n] ) ) ); // q_com hTcxEnc->spectrum_e[n] = sub( 31, q_com ); move16(); } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index d31e6d53d63eb92bba1ec19c146fcbd29a9b12c3..f1187bc6cfe77f5deb5328174eececa5a15aa0cb 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1050,10 +1050,8 @@ static void ivas_omasa_param_est_enc_fx( move16(); /* Need to initialize renormalization_factors, and variables to be normalized */ -#ifdef MSAN_FIX set_zero_fx( &Foa_RealBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ); set_zero_fx( &Foa_ImagBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ); -#endif set_zero_fx( renormalization_factor_diff_fx, hOMasa->nbands ); set_zero_fx( diffuseness_m_fx, hOMasa->nbands ); @@ -1201,12 +1199,8 @@ static void ivas_omasa_param_est_enc_fx( computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, guard_bits ); intensity_real_e = sub( add( 62, guard_bits ), shl( q, 1 ) ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - , - NULL -#endif - ); + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e, + NULL ); /* Power estimation for diffuseness */ diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 0ca93e1a1dc16bab0cd8bf2b00d17d1674e9580c..dbff29d68514b1e32c846e9963c1c03c3386dc38 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -77,11 +77,7 @@ static void ivas_merge_sba_transports_fx( { FOR( j = 0; j < input_frame; j++ ) { -#ifdef NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS data_out_f[i][j] = L_shr( L_add( L_shr( data_in_f1[i][j], 1 ), L_shr( data_in_f2[i][j], sub( Q_f2, sub( Q_f1, 1 ) ) ) ), Q1 ); -#else - data_out_f[i][j] = L_add( L_shr( data_in_f1[i][j], 1 ), L_shr( data_in_f2[i][j], sub( Q_f2, sub( Q_f1, 1 ) ) ) ); -#endif move32(); } } @@ -479,9 +475,6 @@ static void ivas_osba_render_ism_to_sba_fx( Word16 azimuth_fx, elevation_fx; Word32 gains_fx[MAX_INPUT_CHANNELS]; Word32 g1_fx, g2_fx; -#ifndef NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS - Word32 output_gain_fx; -#endif Word16 nchan_sba; nchan_sba = imult1616( add( sba_analysis_order, 1 ), add( sba_analysis_order, 1 ) ); @@ -524,21 +517,6 @@ static void ivas_osba_render_ism_to_sba_fx( } *Q_data = sub( *Q_data, 2 ); -#ifndef NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS - /* Gain with loudness-matching gains */ - // output_gain = 0.7499f; - output_gain_fx = 1610397988; // 0.7499f in Q31 - move32(); - FOR( j = 0; j < nchan_sba; j++ ) - { - FOR( k = 0; k < input_frame; k++ ) - { - // data_out_f[j][k] *= output_gain; - data_out_fx[j][k] = Mpy_32_32( data_out_fx[j][k], output_gain_fx ); - move32(); - } - } -#endif return; } diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 7de54c482bf7a2a7b8d8f5153206d76a7c15d822..10380f422357db94d0dd102c7e8b2dfc80a8faae 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -2500,11 +2500,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( } ELSE { -#ifdef FIX_USAN_ISSUES avg_elevation_index = (UWord16) L_add( avg_elevation_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_elevation_offset ) ); -#else - avg_elevation_index = u_extract_l( UL_addNsD( avg_elevation_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_elevation_offset ) ) ); -#endif } // avg_elevation_index = (uint16_t) ( ( avg_elevation_index + avg_elevation_alphabet ) % avg_elevation_alphabet ); avg_elevation_index = u_extract_l( UL_addNsD( avg_elevation_index, avg_elevation_alphabet ) % avg_elevation_alphabet ); @@ -2639,13 +2635,8 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( FOR( avg_azimuth_offset = 0; avg_azimuth_offset < q_direction->cfg.search_effort; avg_azimuth_offset++ ) { set_zero_fx( avg_direction_vector, 3 ); -#ifdef FIX_USAN_ISSUES avg_azimuth_index = (UWord16) L_add( avg_azimuth_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_azimuth_offset ) ); avg_azimuth_index = (UWord16) ( L_add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet ); -#else - avg_azimuth_index = (UWord16) add( avg_azimuth_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_azimuth_offset ) ); - avg_azimuth_index = (UWord16) ( add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet ); -#endif all_zero_dist_azimuth_indexes = 1; move16(); azimuth_bits_ec = ivas_qmetadata_encode_quasi_uniform_length_fx( ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet ); @@ -5452,11 +5443,7 @@ static Word16 encode_surround_coherence_hr_fx( } ELSE { -#ifdef FIX_USAN_ISSUES no_idx16 = add( shr( nbits_fr, 4 ), 1 ); -#else - no_idx16 = shr_r( nbits_fr, 4 ); -#endif } /* write combined index */ @@ -5478,11 +5465,7 @@ static Word16 encode_surround_coherence_hr_fx( } ELSE { -#ifdef FIX_USAN_ISSUES no_idx16 = add( shr( nbits_fr1, 4 ), 1 ); -#else - no_idx16 = shr_r( nbits_fr1, 4 ); -#endif } assert( no_idx16 <= 4 ); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 3a0f19c505c59a7a7e5456edc8e2777e9a727953..a578a3cfaeacc1fa9b70066613cf8549931cf6e8 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -120,14 +120,16 @@ ivas_error ivas_sce_enc_fx( * Initialization - general *-----------------------------------------------------------------*/ -#ifdef MSAN_FIX set16_zero_fx( old_inp_12k8_fx[0], L_INP_12k8 ); -#endif - Copy32( data_fx, st->input32_fx, input_frame ); // Q(q_data_fx) - q_input = sub( add( L_norm_arr( st->input32_fx, input_frame ), q_data_fx ), 16 ); + Word16 Q_min = s_min( q_data_fx, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) ); + scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) ); + Copy_Scale_sig32( data_fx, st->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min) + st->q_inp32 = Q_min; + move16(); + q_input = sub( add( L_norm_arr( st->input32_fx, input_frame ), Q_min ), 16 ); - Copy_Scale_sig32_16( st->input32_fx, st->input_fx, input_frame, sub( add( Q16, q_input ), q_data_fx ) ); // Q(q_data_fx) -> Q(q_input) + Copy_Scale_sig32_16( st->input32_fx, st->input_fx, input_frame, sub( add( Q16, q_input ), Q_min ) ); // Q(Q_min) -> Q(q_input) st->q_inp = q_input; move16(); @@ -253,11 +255,7 @@ ivas_error ivas_sce_enc_fx( &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, -#ifdef NONBE_1211_DTX_BR_SWITCHING st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] -#else - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] -#endif #ifdef DEBUG_MODE_INFO , st->id_element @@ -368,6 +366,7 @@ ivas_error ivas_sce_enc_fx( Copy( st->input_fx, st->old_input_signal_fx, input_frame ); st->q_old_inp = st->q_inp; move16(); + Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ hSCE->last_element_brate = hSCE->element_brate; move32(); @@ -467,6 +466,9 @@ ivas_error create_sce_enc_fx( st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move32(); move32(); + st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; + st->input_Fs = st_ivas->hEncoderConfig->input_Fs; + st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) { @@ -484,7 +486,7 @@ ivas_error create_sce_enc_fx( * * Create, allocate and initialize EVS encoder SCE handle *-------------------------------------------------------------------------*/ - +#ifndef HARM_SCE_INIT ivas_error create_evs_sce_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const Word16 sce_id, /* i : SCE # identifier */ @@ -606,16 +608,33 @@ ivas_error create_evs_sce_enc_fx( { return error; } +#ifdef HARM_PUSH_BIT + /*-----------------------------------------------------------------* + * Bitstream + *-----------------------------------------------------------------*/ + + /* set pointer to the buffer of indices */ + st_fx->hBstr->ind_list = st_ivas->ind_list; + st_fx->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; + st_fx->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; + st_fx->hBstr->nb_ind_tot = 0; + move16(); + st_fx->hBstr->nb_bits_tot = 0; + move16(); + st_fx->hBstr->st_ivas = st_ivas; +#else st_fx->hBstr->ind_list = ind_list; // st_fx->hBstr->ind_list_fx = st->hBstr->ind_list; reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); +#endif + hSCE->hCoreCoder[0] = st_fx; st_ivas->hSCE[sce_id] = hSCE; return error; } - +#endif /*------------------------------------------------------------------------- * destroy_sce_enc_fx() * diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index dfd207c3e4d30c8841684d661401349efb8553a1..b7de878a12a6e567f1b868deb3d55472a407d51f 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -59,115 +59,215 @@ static Word16 sns_1st_cod_fx( Word32 *snsq_fx /* o : quantized sns Q16 */ ) { - Word16 index, i; - const Word16 split_len = M / 2; - move16(); - const Word16 *means; - const Word16 means_fix = 2; // Q15 - move16(); - /* remove means */ - means = NULL; - SWITCH( L_frame ) - { - case L_FRAME16k: - means = &sns_1st_means_16k[core - 1][0]; - break; - case L_FRAME25_6k: - means = &sns_1st_means_25k6[core - 1][0]; - break; - case L_FRAME32k: - means = &sns_1st_means_32k[core - 1][0]; - break; - default: - assert( !"illegal frame length in sns_1st_cod" ); - } - Word16 exp_snsq_buffer[M] = { 0 }, exp_snsq = 0; - move16(); - move16(); - FOR( i = 0; i < M; ++i ) + IF( exp_sns == Q15 ) { - Word32 tmp = L_mult( means[i], means_fix ); // Q16 - exp_snsq_buffer[i] = 0; + Word16 index; + const Word16 split_len = M / 2; move16(); - snsq_fx[i] = BASOP_Util_Add_Mant32Exp( sns_fx[i], exp_sns, L_negate( tmp ), 15, &exp_snsq_buffer[i] ); - move32(); - } - FOR( i = 0; i < M; i++ ) - { - exp_snsq = s_max( exp_snsq_buffer[i], exp_snsq ); - } - FOR( i = 0; i < M; i++ ) - { - snsq_fx[i] = L_shr( snsq_fx[i], exp_snsq - exp_snsq_buffer[i] ); - move32(); - } + const Word16 *means; + const Word16 means_fix = 2; // Q15 + move16(); + /* remove means */ + means = NULL; + SWITCH( L_frame ) + { + case L_FRAME16k: + means = &sns_1st_means_16k[core - 1][0]; // Q14 + break; + case L_FRAME25_6k: + means = &sns_1st_means_25k6[core - 1][0]; // Q14 + break; + case L_FRAME32k: + means = &sns_1st_means_32k[core - 1][0]; // Q14 + break; + default: + assert( !"illegal frame length in sns_1st_cod" ); + } + FOR( Word16 i = 0; i < M; ++i ) + { + Word32 tmp = L_mult( means[i], means_fix ); // Q14->Q16 + snsq_fx[i] = L_sub( sns_fx[i], tmp ); // Q16 + move32(); + } - index = 0; - move16(); - FOR( Word16 split = 0; split < 2; ++split ) - { - const Word16 *cdbk_ptr; - Word16 j0, j1, index_split; - Word32 dist_min_fx; - const Word16 cdbk_fix = 8; // 1.f / powf( 2, SNS_CDBKS_BITS_4_FRAC ) in Q15 + index = 0; move16(); - const Word16 *const cdbk = &sns_1st_cdbk[split][core - 1][0]; + FOR( Word16 split = 0; split < 2; ++split ) + { + const Word16 *cdbk_ptr; + Word16 j0, j1; + Word16 index_split; + Word32 dist_min_fx; + const Word16 cdbk_fix = 8; // 1.f / powf( 2, SNS_CDBKS_BITS_4_FRAC ) in Q15 + move16(); + const Word16 *const cdbk = &sns_1st_cdbk[split][core - 1][0]; // Q12 - j0 = imult1616( split, split_len ); - j1 = add( j0, split_len ); + j0 = imult1616( split, split_len ); + j1 = add( j0, split_len ); - cdbk_ptr = cdbk; - dist_min_fx = MAXVAL_WORD32; - Word16 exp_dist_min = 31; - index_split = 0; - FOR( i = 0; i < 32; ++i ) - { - Word32 dist_fx = 0; + cdbk_ptr = cdbk; + dist_min_fx = MAXVAL_WORD32; + index_split = 0; move32(); - Word16 exp_dist = 0; move16(); - FOR( Word16 j = j0; j < j1; ++j ) + FOR( Word16 i = 0; i < 32; ++i ) { - Word32 tmp_fx; - Word16 exp_tmp = 0; - move16(); - Word32 tmp_1 = L_mult( ( *cdbk_ptr++ ), cdbk_fix ); // Q16 - tmp_fx = BASOP_Util_Add_Mant32Exp( snsq_fx[j], exp_snsq, L_negate( tmp_1 ), 15, &exp_tmp ); - Word32 tmp_2 = Mpy_32_32( tmp_fx, tmp_fx ); // exp_tmp*2 - dist_fx = BASOP_Util_Add_Mant32Exp( dist_fx, exp_dist, tmp_2, exp_tmp * 2, &exp_dist ); // exp_tmp*2 + Word32 dist_fx = 0; + move32(); + FOR( Word16 j = j0; j < j1; ++j ) // j1-j0=split_len. split_len=M/2. M=16 + { + Word32 tmp; + Word32 dist; + + tmp = L_mult( *cdbk_ptr++, cdbk_fix ); // Q12->Q16 + dist = L_sub( snsq_fx[j], tmp ); // Q16 + dist = L_shl( dist, 11 ); // cdbk_ptr is a 16 bit LUT with 3.12 values, used as 3.16. assumption: snsq_fx has the same representation. thus, the subtraction results are in 4.16, which leaves 11 bit headroom. + dist = Mpy_32_32( dist, dist ); + dist = L_shr( dist, 3 ); // make sure that the sum of 8 values does not overflow + dist_fx = L_add( dist_fx, dist ); + } + + IF( LT_32( dist_fx, dist_min_fx ) ) + { + dist_min_fx = dist_fx; + move32(); + index_split = i; + move16(); + } } - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( dist_fx, exp_dist, dist_min_fx, exp_dist_min ), -1 ) ) + /* set quantized vector */ + cdbk_ptr = &cdbk[imult1616( index_split, split_len )]; + FOR( Word16 j = j0; j < j1; ++j ) { - dist_min_fx = dist_fx; + Word32 tmp_3 = L_mult( means[j], means_fix ); // Q16 + Word32 tmp_4 = L_mult( *cdbk_ptr++, cdbk_fix ); // Q16 + snsq_fx[j] = L_add( tmp_4, tmp_3 ); // Q16 move32(); - exp_dist_min = exp_dist; - move16(); - index_split = i; - move16(); } - } - /* set quantized vector */ - cdbk_ptr = &cdbk[imult1616( index_split, split_len )]; - FOR( Word16 j = j0; j < j1; ++j ) + /* for second split shift by five bits to store both indices as one 10 bit value */ + if ( EQ_16( split, 1 ) ) + { + index_split = shl( index_split, 5 ); + } + + index = add( index, index_split ); + } + return index; + } + ELSE + { + Word16 index, i; + const Word16 split_len = M / 2; + move16(); + const Word16 *means; + const Word16 means_fix = 2; // Q15 + move16(); + /* remove means */ + means = NULL; + SWITCH( L_frame ) + { + case L_FRAME16k: + means = &sns_1st_means_16k[core - 1][0]; + break; + case L_FRAME25_6k: + means = &sns_1st_means_25k6[core - 1][0]; + break; + case L_FRAME32k: + means = &sns_1st_means_32k[core - 1][0]; + break; + default: + assert( !"illegal frame length in sns_1st_cod" ); + } + Word16 exp_snsq_buffer[M] = { 0 }, exp_snsq = 0; + move16(); + move16(); + FOR( i = 0; i < M; ++i ) { - Word32 tmp_3 = L_mult( means[j], means_fix ); // Q16 - Word32 tmp_4 = L_mult( ( *cdbk_ptr++ ), cdbk_fix ); // Q16 - snsq_fx[j] = L_add( tmp_4, tmp_3 ); // Q16 + Word32 tmp = L_mult( means[i], means_fix ); // Q16 + exp_snsq_buffer[i] = 0; + move16(); + snsq_fx[i] = BASOP_Util_Add_Mant32Exp( sns_fx[i], exp_sns, L_negate( tmp ), 15, &exp_snsq_buffer[i] ); + move32(); + } + FOR( i = 0; i < M; i++ ) + { + exp_snsq = s_max( exp_snsq_buffer[i], exp_snsq ); + } + FOR( i = 0; i < M; i++ ) + { + snsq_fx[i] = L_shr( snsq_fx[i], exp_snsq - exp_snsq_buffer[i] ); move32(); } - /* for second split shift by five bits to store both indices as one 10 bit value */ - IF( EQ_16( split, 1 ) ) + index = 0; + move16(); + FOR( Word16 split = 0; split < 2; ++split ) { - index_split = shl( index_split, 5 ); + const Word16 *cdbk_ptr; + Word16 j0, j1, index_split; + Word32 dist_min_fx; + const Word16 cdbk_fix = 8; // 1.f / powf( 2, SNS_CDBKS_BITS_4_FRAC ) in Q15 + move16(); + const Word16 *const cdbk = &sns_1st_cdbk[split][core - 1][0]; + + j0 = imult1616( split, split_len ); + j1 = add( j0, split_len ); + + cdbk_ptr = cdbk; + dist_min_fx = MAXVAL_WORD32; + Word16 exp_dist_min = 31; + index_split = 0; + FOR( i = 0; i < 32; ++i ) + { + Word32 dist_fx = 0; + move32(); + Word16 exp_dist = 0; + move16(); + FOR( Word16 j = j0; j < j1; ++j ) + { + Word32 tmp_fx; + Word16 exp_tmp = 0; + move16(); + Word32 tmp_1 = L_mult( ( *cdbk_ptr++ ), cdbk_fix ); // Q16 + tmp_fx = BASOP_Util_Add_Mant32Exp( snsq_fx[j], exp_snsq, L_negate( tmp_1 ), 15, &exp_tmp ); + Word32 tmp_2 = Mpy_32_32( tmp_fx, tmp_fx ); // exp_tmp*2 + dist_fx = BASOP_Util_Add_Mant32Exp( dist_fx, exp_dist, tmp_2, exp_tmp * 2, &exp_dist ); // exp_tmp*2 + } + + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( dist_fx, exp_dist, dist_min_fx, exp_dist_min ), -1 ) ) + { + dist_min_fx = dist_fx; + move32(); + exp_dist_min = exp_dist; + move16(); + index_split = i; + move16(); + } + } + + /* set quantized vector */ + cdbk_ptr = &cdbk[imult1616( index_split, split_len )]; + FOR( Word16 j = j0; j < j1; ++j ) + { + Word32 tmp_3 = L_mult( means[j], means_fix ); // Q16 + Word32 tmp_4 = L_mult( ( *cdbk_ptr++ ), cdbk_fix ); // Q16 + snsq_fx[j] = L_add( tmp_4, tmp_3 ); // Q16 + move32(); + } + + /* for second split shift by five bits to store both indices as one 10 bit value */ + IF( EQ_16( split, 1 ) ) + { + index_split = shl( index_split, 5 ); + } + + index = add( index, index_split ); } - index = add( index, index_split ); + return index; } - - return index; } /*------------------------------------------------------------------- @@ -717,15 +817,10 @@ Word16 quantize_sns_fx( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { -#ifdef MSAN_FIX FOR( k = 0; k < nSubframes; k++ ) { scale_sig32( snsQ_out_fx[ch][k], M, sub( sns_e_tmp[ch][k], sns_e ) ); // Q(31-sns_e_tmp[ch][k]) } -#else - scale_sig32( snsQ_out_fx[ch][0], M, sub( sns_e_tmp[ch][0], *sns_e ) ); - scale_sig32( snsQ_out_fx[ch][1], M, sub( sns_e_tmp[ch][1], *sns_e ) ); -#endif } /* get back to L/F representation */ test(); diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 918acc41711f5135bfa0ede33d664e6d43363de2..f421fd034f4f3e6ab0cfe60915568b6d288abb9a 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -88,12 +88,8 @@ typedef struct stereo_itd_data_struct Word16 prev_sum_nrg_L_lb_fx_e; Word32 prev_xcorr_lb_fx[STEREO_DFT_XCORR_LB_MAX]; Word16 prev_xcorr_lb_fx_e; -#ifdef FIX_ISSUE_1092 Word32 E_band_n_fx[STEREO_DFT_ITD_VAD_BAND_NUM]; /*E_band_n_exp*/ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM]; -#else - Word32 E_band_n_fx[STEREO_DFT_ITD_VAD_BAND_NUM]; /*Q0*/ -#endif Word32 xcorr_smooth_fx[STEREO_DFT_N_32k_ENC]; Word16 xcorr_smooth_fx_e[STEREO_DFT_N_32k_ENC]; Word32 lp_phat_peak_fx; /* low-pass GCC PHAT peak value */ // Q31 @@ -1183,7 +1179,7 @@ typedef struct stereo_dmx_evs_correlation_filter_structure { Word16 init_frmCntr; - Word16 isd_rate_s_fx; // Q15 + Word32 isd_rate_s_fx; // Q31 Word32 iccr_s_fx; // Q31 Word32 ipd_ff_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31 Word32 Pr_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31 @@ -1224,8 +1220,7 @@ typedef struct stereo_dmx_evs_enc_data_structure STEREO_DMX_EVS_POC_HANDLE hPOC; STEREO_DMX_EVS_PHA_HANDLE hPHA; - - Word32 itd_fx; // Q16 + Word16 itd_fx; // Q0 Word32 pre_dmx_energy_fx[1]; Word16 pre_dmx_energy_fx_e[1]; diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 3e148a5aeb36fbfe22286463f8f5aa5b1643a9f4..3e69a0ca660fbc73ad7cf1ca250e59d02d8a0997 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -1697,11 +1697,7 @@ static void edge_detect_fx( } } -#ifndef FIX_1297_OVERFLOW - *edge_str = extract_l( L_shr( edge_min, 10 ) ); // Q15 -#else *edge_str = extract_h( L_shl_sat( edge_min, 16 - 10 ) ); // Q15 -#endif move16(); *edge_type = et; // Q0 move16(); diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 3eb6c0e8232af7ddfc96be1a8625e2dddf501b2b..01318af28c5aca29760bd9db19eba5c4905e1055 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -593,10 +593,8 @@ void stereo_dft_enc_reset_fx( move16(); hStereoDft->dmx_res_all_prev_fx = 1; move32(); -#ifdef MSAN_FIX hStereoDft->dmx_res_all_prev_fx_e = 31; move16(); -#endif hStereoDft->last_res_cod_mode_modify_flag = 0; move16(); hStereoDft->res_cod_sw_flag = 0; @@ -750,9 +748,7 @@ void stereo_enc_itd_init_fx( hItd->prev_xcorr_lb_fx_e = 0; move16(); set32_fx( hItd->E_band_n_fx, ITD_VAD_E_BAND_N_INIT, STEREO_DFT_ITD_VAD_BAND_NUM ); -#ifdef FIX_ISSUE_1092 set16_fx( hItd->E_band_n_exp, Q31, STEREO_DFT_ITD_VAD_BAND_NUM ); -#endif hItd->vad_frm_cnt = 0; move16(); hItd->pre_vad = 0; @@ -1068,23 +1064,14 @@ void stereo_dft_enc_analyze_fx( Word16 q_shift, guarded_bits; guarded_bits = find_guarded_bits_fx( NFFT ); - q_shift = sub( getScaleFactor32( pDFT_L, NFFT ), guarded_bits ); - q_shift = s_min( q_shift, sub( getScaleFactor32( pDFT_R, NFFT ), guarded_bits ) ); - FOR( Word16 j = 0; j < NFFT; j++ ) - { - pDFT_L[j] = L_shl( pDFT_L[j], q_shift ); - move32(); - } + q_shift = sub( L_norm_arr( pDFT_L, NFFT ), guarded_bits ); + scale_sig32( pDFT_L, NFFT, q_shift ); DFT_e[0] = sub( DFT_e[0], q_shift ); move16(); - FOR( Word16 j = 0; j < NFFT; j++ ) - { - pDFT_R[j] = L_shl( pDFT_R[j], q_shift ); - move32(); - } - + q_shift = sub( L_norm_arr( pDFT_R, NFFT ), guarded_bits ); + scale_sig32( pDFT_R, NFFT, q_shift ); DFT_e[1] = sub( DFT_e[1], q_shift ); move16(); @@ -1102,11 +1089,7 @@ void stereo_dft_enc_analyze_fx( { FOR( n = 0; n < n_channels; n++ ) { -#ifdef MSAN_FIX Scale_sig( hStereoDft->input_mem_itd_fx[n], dft_ovl, sub( sts[n]->q_inp, hStereoDft->q_input_mem_itd[n] ) ); // Q(sts[n]->q_inp) -#else - Scale_sig( hStereoDft->input_mem_itd_fx[n], STEREO_DFT_OVL_MAX, sts[n]->q_inp - hStereoDft->q_input_mem_itd[n] ); -#endif // MSAN_FIX hStereoDft->q_input_mem_itd[n] = sts[n]->q_inp; move16(); Copy( hStereoDft->input_mem_itd_fx[n], input_mem[n], dft_ovl ); @@ -1657,11 +1640,7 @@ void stereo_dft_enc_process_fx( pDFT_L_fx = hStereoDft->DFT_fx[0]; pDFT_R_fx = hStereoDft->DFT_fx[1]; -#ifdef MSAN_FIX FOR( i = 0; i < hStereoDft->NFFT; i++ ) -#else - FOR( i = 0; i < STEREO_DFT_N_MAX_ENC; i++ ) -#endif // MSAN_FIX { tmp_e = norm_l( hStereoDft->DFT_fx[0][i] ); pDFT_L_fx[i] = L_shl( hStereoDft->DFT_fx[0][i], tmp_e ); diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index af10f7dea96e2cd49be4d2038f452cd834fd09f8..b7429e2e796656a838a89b3a0f99a4f7b2a28175 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -203,12 +203,8 @@ static void stereo_dft_quantize_itd_fx( *-------------------------------------------------------------------------*/ static Word32 itd_vad_ms_snr_calc_fx( -#ifdef FIX_ISSUE_1092 Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM], -#else - Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0 -#endif Word32 *Spd, // Q(31-Spd_e) Word16 *Spd_e, Word32 *E_band, // Q(31-E_band_e) @@ -251,11 +247,7 @@ static Word32 itd_vad_ms_snr_calc_fx( // snr[i] = E_band[i] / E_band_n[i]; snr[i] = BASOP_Util_Divide3232_Scale_cadence( E_band[i], E_band_n[i], &snr_e[i] ); move32(); -#ifdef FIX_ISSUE_1092 snr_e[i] = add( snr_e[i], sub( E_band_e[i], E_band_n_exp[i] ) ); -#else - snr_e[i] = add( snr_e[i], sub( E_band_e[i], 31 ) ); -#endif move16(); // if ( snr[i] < 1 ) IF( BASOP_Util_Cmp_Mant32Exp( snr[i], snr_e[i], 1, 31 ) < 0 ) @@ -291,12 +283,8 @@ static Word32 itd_vad_ms_snr_calc_fx( * *-------------------------------------------------------------------------*/ static void itd_vad_background_update_fx( -#ifdef FIX_ISSUE_1092 Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM], -#else - Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0 -#endif Word16 *vad_frm_cnt, const Word32 ms_snr, // Q(31-ms_snr_e) const Word16 ms_snr_e, @@ -338,19 +326,10 @@ static void itd_vad_background_update_fx( Word16 q_temp = norm_l( *vad_frm_cnt ); L_temp = L_shl( *vad_frm_cnt, q_temp ); L_temp_e = sub( 31, q_temp ); -#ifdef FIX_ISSUE_1092 L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( E_band_n_exp[i], L_temp_e ), E_band[i], E_band_e[i], &L_temp_e ); -#else - L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( 31, L_temp_e ), E_band[i], E_band_e[i], &L_temp_e ); -#endif E_band_n[i] = BASOP_Util_Divide3232_Scale_cadence( L_temp, L_add( *vad_frm_cnt, 1 ), &E_band_n_e_tmp ); move32(); -#ifdef FIX_ISSUE_1092 E_band_n_exp[i] = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) ); -#else - E_band_n_e_tmp = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) ); - E_band_n[i] = L_shr_r( E_band_n[i], sub( 31, E_band_n_e_tmp ) ); // Q31 -#endif move16(); } } @@ -362,7 +341,6 @@ static void itd_vad_background_update_fx( FOR( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ ) { // E_band_n[i] = 0.96f * E_band_n[i] + 0.04f * E_band[i]; -#ifdef FIX_ISSUE_1092 E_band_n[i] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( 2061584302 /*0.96 in Q31*/, E_band_n[i] ), E_band_n_exp[i], Mpy_32_32( 85899346 /*0.04 in Q31*/, E_band[i] ), E_band_e[i], &E_band_n_e_tmp ); move32(); E_band_n_exp[i] = E_band_n_e_tmp; @@ -375,20 +353,6 @@ static void itd_vad_background_update_fx( E_band_n_exp[i] = 0; move16(); } -#else - E_band_n[i] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( 2061584302, E_band_n[i] ), 31, Mpy_32_32( 85899346, E_band[i] ), E_band_e[i], &E_band_n_e_tmp ); - move32(); - // if ( E_band_n[i] < 1.0f ) - IF( BASOP_Util_Cmp_Mant32Exp( E_band_n[i], E_band_n_e_tmp, MAX_32, 0 ) < 0 ) - { - E_band_n[i] = MAX_32; - move32(); - E_band_n_e_tmp = 0; - move16(); - } - E_band_n[i] = L_shr_r( E_band_n[i], sub( 31, E_band_n_e_tmp ) ); // Q31 - move32(); -#endif } } } @@ -402,12 +366,8 @@ static void itd_vad_background_update_fx( *-------------------------------------------------------------------------*/ static Word16 stereo_dft_enc_itd_vad_fx( -#ifdef FIX_ISSUE_1092 Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM], -#else - Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0 -#endif Word16 *vad_frm_cnt, Word32 *Spd_L, // Q(31-Spd_L_e) Word16 *Spd_L_e, @@ -434,17 +394,10 @@ static Word16 stereo_dft_enc_itd_vad_fx( Spd_e[i] = sub( Spd_e[i], 1 ); move16(); } -#ifdef FIX_ISSUE_1092 *mssnr = itd_vad_ms_snr_calc_fx( E_band_n, E_band_n_exp, Spd, Spd_e, E_band, E_band_e, mssnr_e ); move32(); itd_vad_background_update_fx( E_band_n, E_band_n_exp, vad_frm_cnt, *mssnr, *mssnr_e, E_band, E_band_e ); -#else - *mssnr = itd_vad_ms_snr_calc_fx( E_band_n, Spd, Spd_e, E_band, E_band_e, mssnr_e ); - move32(); - - itd_vad_background_update_fx( E_band_n, vad_frm_cnt, *mssnr, *mssnr_e, E_band, E_band_e ); -#endif // if ( *mssnr < ITD_VAD_THRSHOLD ) IF( BASOP_Util_Cmp_Mant32Exp( *mssnr, *mssnr_e, ITD_VAD_THRSHOLD_Q31, 0 ) < 0 ) { @@ -1476,11 +1429,7 @@ void stereo_dft_enc_compute_itd_fx( } // L_temp = sum2_32_fx( &Spd_L[1], 11, &L_temp_e ); sum_nrg_L_lb = BASOP_Util_Add_Mant32Exp( sum_nrg_L_lb, sum_nrg_L_lb_e, L_temp, L_temp_e, &sum_nrg_L_lb_e ); -#ifdef FIX_ISSUE_1092 vad_flag_itd = stereo_dft_enc_itd_vad_fx( hItd->E_band_n_fx, hItd->E_band_n_exp, &( hItd->vad_frm_cnt ), Spd_L, Spd_L_e, Spd_R, Spd_R_e, &mssnr, &mssnr_e ); -#else - vad_flag_itd = stereo_dft_enc_itd_vad_fx( hItd->E_band_n_fx, &( hItd->vad_frm_cnt ), Spd_L, Spd_L_e, Spd_R, Spd_R_e, &mssnr, &mssnr_e ); -#endif vad_flag_itd = vad_flag_itd && vad_flag_dtx[0]; // if ( sum_nrg_L < EPSILON ) diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index df4fe3edd15fe29ac3813dec4130beccfd7487cd..c457faa4f97bd09da06ee2738486bdab5e8aff4c 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -380,15 +380,6 @@ void stereo_td_itd_fx( move16(); set16_fx( shift_input, 0, input_frame ); - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - - Scale_sig( &input_mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] ); // Q(sts[n]->q_inp) - // Scale_sig(&sts[n]->old_input_signal_fx, 1965, sts[n]->q_inp - sts[n]->q_old_inp); - // sts[n]->q_old_inp = sts[n]->q_inp; - q_input_mem[n] = sts[n]->q_inp; - move16(); - } IF( EQ_16( sts[0]->element_mode, IVAS_CPE_MDCT ) ) { FOR( n = 0; n < CPE_CHANNELS; n++ ) @@ -540,7 +531,7 @@ void stereo_td_itd_mdct_stereo_fx( const Word16 input_frame /* i : frame length */ ) { - Word16 i; + Word16 i, n, q_com; Word32 bin_nrgL_fx[STEREO_DFT_N_32k_ENC]; Word16 bin_nrgL_e[STEREO_DFT_N_32k_ENC]; Word32 bin_nrgR_fx[STEREO_DFT_N_32k_ENC]; @@ -584,6 +575,37 @@ void stereo_td_itd_mdct_stereo_fx( /*call ITD function*/ stereo_dft_enc_compute_itd_fx( hCPE, DFT_fx[0], DFT_tmp_e[0], DFT_fx[1], DFT_tmp_e[1], STEREO_DFT_OFFSET, input_frame, vad_flag_dtx, vad_hover_flag, bin_nrgL_fx, bin_nrgL_e, bin_nrgR_fx, bin_nrgR_e ); + q_com = MAX_16; + move16(); + + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + q_com = s_min( q_com, add( norm_arr( hCPE->hCoreCoder[n]->input_fx, input_frame ), hCPE->hCoreCoder[n]->q_inp ) ); + q_com = s_min( q_com, add( norm_arr( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame ), hCPE->hCoreCoder[n]->q_old_inp ) ); + q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hStereoMdct->hDft_ana->dft_ovl ), hCPE->q_input_mem[n] ) ); + + if ( EQ_16( q_com, Q15 ) ) + { + q_com = 0; + move16(); + } + } + + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( q_com, hCPE->hCoreCoder[n]->q_inp ) ); + hCPE->hCoreCoder[n]->q_inp = q_com; + move16(); + + scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, hCPE->hCoreCoder[n]->q_old_inp ) ); + hCPE->hCoreCoder[n]->q_old_inp = q_com; + move16(); + + scale_sig( hCPE->input_mem_fx[n], hStereoMdct->hDft_ana->dft_ovl, sub( q_com, hCPE->q_input_mem[n] ) ); + hCPE->q_input_mem[n] = q_com; + move16(); + } + /* Time Domain ITD compensation using extrapolation */ stereo_td_itd_fx( hStereoMdct->hItd, NULL, NULL, 1, hStereoMdct->hDft_ana->dft_ovl, hCPE->hCoreCoder, input_frame, hCPE->input_mem_fx, hCPE->q_input_mem ); } diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index ae8a8203e815b5597d27cb4d6ffeb44070301274..625ff8ee90fc1f2eeeb5dc932c1312b3b861106f 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -65,12 +65,14 @@ #define Q_BAND_FX 536870912 /*Q31*/ -#define STEREO_DMX_EVS_ISD_FORGETTING_Q15 31129 #define STEREO_DMX_EVS_ISD_THRES_L_Q31 1932735283 #define STEREO_DMX_EVS_ISD_DIST_THRES_IPD_Q15 ONE_IN_Q14 -#define STEREO_DMX_EVS_ISD_DIST_HYST_L_Q15 11796 -#define STEREO_DMX_EVS_ISD_DIST_HYST_H_Q15 14090 +#define STEREO_DMX_EVS_ISD_FORGETTING_Q31 2040109465 +#define STEREO_DMX_EVS_ISD_1MFORGETTING_Q15 1638 +#define STEREO_DMX_EVS_ISD_DIST_HYST_L_Q31 773094113 +#define STEREO_DMX_EVS_ISD_DIST_HYST_H_Q31 923417968 +#define STEREO_DMX_EVS_ISD_INVTHRES_H 1270700383 #define STEREO_DMX_EVS_ICCR_FORGETTING_Q31 1503238554 #define STEREO_DMX_EVS_ICCR_HYST_L_Q31 1610612736 @@ -153,7 +155,7 @@ static ivas_error estimate_itd_fx( STEREO_DMX_EVS_PHA_HANDLE hPHA, /* i/o: correlation filter structure */ const Word32 srcL[], /* i : Lch input signal Q16 */ const Word32 srcR[], /* i : Rch input signal Q16 */ - Word32 itd[], /* o : estimated itd Q16 */ + Word16 itd[], /* o : estimated itd Q0 */ const Word16 input_frame /* i : input frame length per channel */ ); static void adapt_gain_fx( @@ -196,7 +198,7 @@ static void create_M_signal_fx( ); static Word32 find_poc_peak_fx( STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ - Word32 itd_fx[], /* o : estimated itd */ + Word16 itd_fx[], /* o : estimated itd */ const Word16 input_frame, /* i : input frame length per channel */ const Word32 ratio_fixed /* i : adapting ratio */ ); @@ -604,12 +606,13 @@ static void calc_poc_fx( Ni = L_sub( specLi[i], specRi[i] ); // spec_e Dr = L_add( specLr[i], specRr[i] ); // spec_e Di = L_add( specLi[i], specRi[i] ); // spec_e - // if ( ( Nr * Nr + Ni * Ni ) > STEREO_DMX_EVS_ISD_THRES_H * ( Dr * Dr + Di * Di ) ) - IF( GT_32( Mpy_32_32_r( L_add( Mpy_32_32_r( Nr, Nr ), Mpy_32_32_r( Ni, Ni ) ), 1270700383 /*1/STEREO_DMX_EVS_ISD_THRES_H in Q31*/ ), L_add( Mpy_32_32_r( Dr, Dr ), Mpy_32_32_r( Di, Di ) ) ) ) + // if ( ( Nr * Nr + Ni * Ni ) > STEREO_DMX_EVS_ISD_THRES_H * ( Dr * Dr + Di * Di ) ) + IF( GT_32( Mpy_32_32_r( L_add( Mpy_32_32_r( Nr, Nr ), Mpy_32_32_r( Ni, Ni ) ), STEREO_DMX_EVS_ISD_INVTHRES_H ), L_add( Mpy_32_32_r( Dr, Dr ), Mpy_32_32_r( Di, Di ) ) ) ) { isd_cnt_h = add( isd_cnt_h, 1 ); } - IF( LT_32( L_add( Mpy_32_32_r( Nr, Nr ), Mpy_32_32_r( Ni, Ni ) ), Mpy_32_32_r( STEREO_DMX_EVS_ISD_THRES_L_Q31, L_add( Mpy_32_32_r( Dr, Dr ), Mpy_32_32_r( Di, Di ) ) ) ) ) + W_tmp = W_add( W_mult0_32_32( Mpy_32_32_r( Dr, STEREO_DMX_EVS_ISD_THRES_L_Q31 ), Dr ), W_mult0_32_32( Mpy_32_32_r( Di, STEREO_DMX_EVS_ISD_THRES_L_Q31 ), Di ) ); // Q62 + IF( LT_64( W_add( W_mult0_32_32( Nr, Nr ), W_mult0_32_32( Ni, Ni ) ), W_tmp ) ) // Q62 { isd_cnt_l = add( isd_cnt_l, 1 ); } @@ -618,10 +621,10 @@ static void calc_poc_fx( isd_rate = BASOP_Util_Divide1616_Scale( isd_cnt_h, freq_8k, &isd_rate_e ); // Saturation to handle values close to 1.0f isd_rate = shl_sat( isd_rate, isd_rate_e ); // Q15 - hPHA->isd_rate_s_fx = add( mult_r( STEREO_DMX_EVS_ISD_FORGETTING_Q15, hPHA->isd_rate_s_fx ), mult_r( MAX_16 - STEREO_DMX_EVS_ISD_FORGETTING_Q15, isd_rate ) ); - move16(); + hPHA->isd_rate_s_fx = L_add( Mpy_32_32_r( STEREO_DMX_EVS_ISD_FORGETTING_Q31, hPHA->isd_rate_s_fx ), L_mult( STEREO_DMX_EVS_ISD_1MFORGETTING_Q15, isd_rate ) ); + move32(); - IF( GT_16( hPHA->isd_rate_s_fx, STEREO_DMX_EVS_ISD_DIST_HYST_H_Q15 ) ) + IF( GT_32( hPHA->isd_rate_s_fx, STEREO_DMX_EVS_ISD_DIST_HYST_H_Q31 ) ) { IF( NE_32( hPHA->curr_pha, STEREO_DMX_EVS_PHA_IPD ) ) { @@ -646,7 +649,7 @@ static void calc_poc_fx( hPHA->prev_pha = STEREO_DMX_EVS_PHA_IPD; move32(); } - ELSE IF( LT_16( hPHA->isd_rate_s_fx, STEREO_DMX_EVS_ISD_DIST_HYST_L_Q15 ) ) + ELSE IF( LT_32( hPHA->isd_rate_s_fx, STEREO_DMX_EVS_ISD_DIST_HYST_L_Q31 ) ) { IF( NE_32( hPHA->curr_pha, STEREO_DMX_EVS_PHA_IPD2 ) ) { @@ -711,10 +714,28 @@ static void calc_poc_fx( FOR( j = 0; j < STEREO_DMX_EVS_SUBBAND_SIZE; ( j++, i++ ) ) { + /* Energy */ - tEl[n] = BASOP_Util_Add_Mant32Exp( tEl[n], tEl_e[n], L_add( Mpy_32_32_r( specLr[i], specLr[i] ), Mpy_32_32_r( specLi[i], specLi[i] ) ), shl( spec_e, 1 ), &tEl_e[n] ); + + + // Left + W_tmp = W_add( W_mult0_32_32( specLr[i], specLr[i] ), W_mult0_32_32( specLi[i], specLi[i] ) ); // Q(62-(2*specL_e)) -> Q(63 - ((2*specL_e) +1)) + L_tmp_e = W_norm( W_tmp ); + IF( L_tmp_e != 0 ) + { + W_tmp = W_shl( W_tmp, L_tmp_e ); // Q(63 - ((2*spec_e) - (L_tmp_e - 1)) + } + tEl[n] = BASOP_Util_Add_Mant32Exp( tEl[n], tEl_e[n], W_round64_L( W_tmp ), sub( shl( spec_e, 1 ), sub( L_tmp_e, 1 ) ), &tEl_e[n] ); move32(); - tEr[n] = BASOP_Util_Add_Mant32Exp( tEr[n], tEr_e[n], L_add( Mpy_32_32_r( specRr[i], specRr[i] ), Mpy_32_32_r( specRi[i], specRi[i] ) ), shl( spec_e, 1 ), &tEr_e[n] ); + + // Right + W_tmp = W_add( W_mult0_32_32( specRr[i], specRr[i] ), W_mult0_32_32( specRi[i], specRi[i] ) ); // Q(62-(2*specR_e)) -> Q(63 - ((2*specR_e) +1)) + L_tmp_e = W_norm( W_tmp ); + IF( L_tmp_e != 0 ) + { + W_tmp = W_shl( W_tmp, L_tmp_e ); // Q(63 - ((2*spec_e) - (L_tmp_e - 1)) + } + tEr[n] = BASOP_Util_Add_Mant32Exp( tEr[n], tEr_e[n], W_round64_L( W_tmp ), sub( shl( spec_e, 1 ), sub( L_tmp_e, 1 ) ), &tEr_e[n] ); move32(); /* IPD */ @@ -746,11 +767,27 @@ static void calc_poc_fx( tIPDr = L_sub( Mpy_32_32_r( specRr[i], IPDr ), Mpy_32_32_r( specRi[i], IPDi ) ); // spec_e tIPDi = L_add( Mpy_32_32_r( specRr[i], IPDi ), Mpy_32_32_r( specRi[i], IPDr ) ); // spec_e - Nr = BASOP_Util_Add_Mant32Exp( Nr, Nr_e, L_add( Mpy_32_32_r( specLr[i], tIPDr ), Mpy_32_32_r( specLi[i], tIPDi ) ), shl( spec_e, 1 ), &Nr_e ); - Ni = BASOP_Util_Add_Mant32Exp( Ni, Ni_e, L_sub( Mpy_32_32_r( specLi[i], tIPDr ), Mpy_32_32_r( specLr[i], tIPDi ) ), shl( spec_e, 1 ), &Ni_e ); - eneL = BASOP_Util_Add_Mant32Exp( eneL, eneL_e, L_add( Mpy_32_32_r( specLr[i], specLr[i] ), Mpy_32_32_r( specLi[i], specLi[i] ) ), shl( spec_e, 1 ), &eneL_e ); - eneR = BASOP_Util_Add_Mant32Exp( eneR, eneR_e, L_add( Mpy_32_32_r( specRr[i], specRr[i] ), Mpy_32_32_r( specRi[i], specRi[i] ) ), shl( spec_e, 1 ), &eneR_e ); + Nr = BASOP_Util_Add_Mant32Exp( Nr, Nr_e, L_add( Mpy_32_32_r( specLr[i], tIPDr ), Mpy_32_32_r( specLi[i], tIPDi ) ), 0, &Nr_e ); + Ni = BASOP_Util_Add_Mant32Exp( Ni, Ni_e, L_sub( Mpy_32_32_r( specLi[i], tIPDr ), Mpy_32_32_r( specLr[i], tIPDi ) ), 0, &Ni_e ); + + // eneL = BASOP_Util_Add_Mant32Exp( eneL, eneL_e, L_add( Mpy_32_32_r( specLr[i], specLr[i] ), Mpy_32_32_r( specLi[i], specLi[i] ) ), 0, &eneL_e ); + W_tmp = W_add( W_mult0_32_32( specLr[i], specLr[i] ), W_mult0_32_32( specLi[i], specLi[i] ) ); + L_tmp_e = W_norm( W_tmp ); + IF( L_tmp_e != 0 ) + { + W_tmp = W_shl( W_tmp, L_tmp_e ); + } + eneL = BASOP_Util_Add_Mant32Exp( eneL, eneL_e, W_round64_L( W_tmp ), sub( 1, L_tmp_e ), &eneL_e ); + + // eneR = BASOP_Util_Add_Mant32Exp( eneR, eneR_e, L_add( Mpy_32_32_r( specRr[i], specRr[i] ), Mpy_32_32_r( specRi[i], specRi[i] ) ), 0, &eneR_e ); + W_tmp = W_add( W_mult0_32_32( specRr[i], specRr[i] ), W_mult0_32_32( specRi[i], specRi[i] ) ); + L_tmp_e = W_norm( W_tmp ); + IF( L_tmp_e != 0 ) + { + W_tmp = W_shl( W_tmp, L_tmp_e ); + } + eneR = BASOP_Util_Add_Mant32Exp( eneR, eneR_e, W_round64_L( W_tmp ), sub( 1, L_tmp_e ), &eneR_e ); } // Pn = (float) inv_sqrt( ( tPr * tPr + tPi * tPi ) + EPSILON ); @@ -768,14 +805,12 @@ static void calc_poc_fx( move32(); Pi[n] = L_add( Mpy_32_32_r( ipd_ff[n], Pi[n] ), Mpy_32_32_r( L_sub( MAX_32, ipd_ff[n] ), tPi ) ); move32(); + // Pn = (float) inv_sqrt( ( Pr[n] * Pr[n] + Pi[n] * Pi[n] ) + EPSILON ); - L_tmp = L_add( L_shr( Mpy_32_32_r( Pr[n], Pr[n] ), 1 ), L_shr( Mpy_32_32_r( Pi[n], Pi[n] ), 1 ) ); - L_tmp_e = 1; - move16(); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp_e ); - Pn_e = L_tmp_e; - move16(); - Pn = ISqrt32( L_tmp, &Pn_e ); + Pn = L_add( L_shr( Mpy_32_32_r( Pr[n], Pr[n] ), 1 ), L_shr( Mpy_32_32_r( Pi[n], Pi[n] ), 1 ) ); + Pn = BASOP_Util_Add_Mant32Exp( Pn, 1, EPSILON_FX_M, EPSILON_FX_E, &Pn_e ); + Pn = Isqrt_lc( Pn, &Pn_e ); + Pr[n] = L_shl_sat( Mpy_32_32_r( Pr[n], Pn ), Pn_e ); // Q31 move32(); Pi[n] = L_shl_sat( Mpy_32_32_r( Pi[n], Pn ), Pn_e ); // Q31 @@ -981,11 +1016,7 @@ static void calc_poc_fx( FOR( i = 0; i < hPHA->pha_len; i++ ) { // hPHA->p_curr_taps[n][i] *= hPHA->win[i]; -#ifdef FIX_ISSUE_1153 hPHA->p_curr_taps_fx[n][i] = Mpy_32_16_1( hPHA->p_curr_taps_fx[n][i], hPHA->win_fx[i] ); // Q30 -#else - hPHA->p_curr_taps_fx[n][i] = L_shl( Mpy_32_16_1( hPHA->p_curr_taps_fx[n][i], hPHA->win_fx[i] ), 1 ); // Q31 -#endif move32(); } @@ -993,29 +1024,16 @@ static void calc_poc_fx( move32(); energy_e = 0; move16(); -#ifdef FIX_ISSUE_1153 - Word16 shift = L_norm_arr( hPHA->p_curr_taps_fx[n], hPHA->pha_len ); - IF( shift ) - { - scale_sig32( hPHA->p_curr_taps_fx[n], hPHA->pha_len, 1 ); - shift = 1; - move16(); - } -#endif FOR( i = 0; i < hPHA->pha_len; i++ ) { -#ifdef FIX_ISSUE_1153 - energy = BASOP_Util_Add_Mant32Exp( energy, energy_e, Mpy_32_32_r( hPHA->p_curr_taps_fx[n][i], hPHA->p_curr_taps_fx[n][i] ), shl( sub( 1, shift ), 1 ), &energy_e ); -#else energy = BASOP_Util_Add_Mant32Exp( energy, energy_e, Mpy_32_32_r( hPHA->p_curr_taps_fx[n][i], hPHA->p_curr_taps_fx[n][i] ), 0, &energy_e ); -#endif } // energy = (float) inv_sqrt( energy + EPSILON ); energy = BASOP_Util_Add_Mant32Exp( energy, energy_e, EPSILON_FX_M, EPSILON_FX_E, &energy_e ); energy = ISqrt32( energy, &energy_e ); FOR( i = 0; i < hPHA->pha_len; i++ ) { - hPHA->p_curr_taps_fx[n][i] = L_shl_r( Mpy_32_32_r( hPHA->p_curr_taps_fx[n][i], energy ), energy_e ); // Q31 + hPHA->p_curr_taps_fx[n][i] = L_shl_r( Mpy_32_32_r( hPHA->p_curr_taps_fx[n][i], energy ), sub( energy_e, 1 ) ); // Q30 move32(); } } @@ -1118,7 +1136,7 @@ static void calc_poc_fx( *-------------------------------------------------------------------*/ static Word32 find_poc_peak_fx( STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ - Word32 itd_fx[], /* o : estimated itd Q16 */ + Word16 itd_fx[], /* o : estimated itd Q0 */ const Word16 input_frame, /* i : input frame length per channel */ const Word32 ratio_fixed /* i : adapting ratio Q31 */ ) @@ -1430,7 +1448,7 @@ static ivas_error estimate_itd_fx( STEREO_DMX_EVS_PHA_HANDLE hPHA, /* i/o: correlation filter structure */ const Word32 srcL[], /* i : Lch input signal Q16 */ const Word32 srcR[], /* i : Rch input signal Q16 */ - Word32 itd[], /* o : estimated itd Q16 */ + Word16 itd[], /* o : estimated itd Q0 */ const Word16 input_frame /* i : input frame length per channel */ ) { @@ -1938,9 +1956,9 @@ void stereo_dmx_evs_enc_fx( hStereoDmxEVS->dmx_weight_fx, hStereoDmxEVS->pre_dmx_energy_fx, hStereoDmxEVS->pre_dmx_energy_fx_e, hStereoDmxEVS->aux_dmx_energy_fx, hStereoDmxEVS->aux_dmx_energy_fx_e ); // Downscaling signals to avoid accumulation overflows - scale_sig32( data_fx[0], input_frame, -5 ); // Q16->Q11 - scale_sig32( data_fx[1], input_frame, -5 ); // Q16->Q11 - scale_sig32( dmx_poc_data, input_frame, -5 ); // Q16->Q11 + scale_sig32( data_fx[0], input_frame, -5 ); // Q31->Q26 + scale_sig32( data_fx[1], input_frame, -5 ); // Q31->Q26 + scale_sig32( dmx_poc_data, input_frame, -5 ); // Q31->Q26 /* pha */ @@ -1969,9 +1987,9 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_prev_taps[m]; - // fx_tmp = BASOP_Util_Add_Mant32Exp(fx_tmp, fx_tmp_e, Mpy_32_32(p_data_mem[n - m], p_prev_taps[m]),15,&fx_tmp_e); - fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_prev_taps[m] ) ); // Q11 + fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_prev_taps[m] ) ); // Q25 } + fx_tmp = L_shl( fx_tmp, 1 ); // Q26 mem_prev[n] = L_add( mem_prev[n], Mpy_32_32( fx_tmp, INV_SQRT_2_Q31 ) ); move32(); } @@ -1981,7 +1999,7 @@ void stereo_dmx_evs_enc_fx( FOR( n = 0; n < fad_len; n++ ) { // mem_prev[n] += p_data[n] * INV_SQRT_2; - mem_prev[n] = L_add( mem_prev[n], Mpy_32_32( p_data[n], INV_SQRT_2_Q31 ) ); // Q11 + mem_prev[n] = L_add( mem_prev[n], Mpy_32_32( p_data[n], INV_SQRT_2_Q31 ) ); // Q26 move32(); } } @@ -1994,10 +2012,11 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_curr_taps[m]; - fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_curr_taps[m] ) ); // Q11 + fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_curr_taps[m] ) ); // Q25 } + fx_tmp = L_shl( fx_tmp, 1 ); // Q26 // dmx_pha_data[n] += ftmp * INV_SQRT_2; - dmx_pha_data[n] = L_add( dmx_pha_data[n], Mpy_32_32( fx_tmp, INV_SQRT_2_Q31 ) ); // Q11 + dmx_pha_data[n] = L_add( dmx_pha_data[n], Mpy_32_32( fx_tmp, INV_SQRT_2_Q31 ) ); // Q26 move32(); } } @@ -2006,7 +2025,7 @@ void stereo_dmx_evs_enc_fx( FOR( n = 0; n < n_samples; n++ ) { // dmx_pha_data[n] += p_data[n] * INV_SQRT_2; - dmx_pha_data[n] = L_add( dmx_pha_data[n], Mpy_32_32( p_data[n], INV_SQRT_2_Q31 ) ); // Q11 + dmx_pha_data[n] = L_add( dmx_pha_data[n], Mpy_32_32( p_data[n], INV_SQRT_2_Q31 ) ); // Q26 move32(); } } @@ -2016,7 +2035,7 @@ void stereo_dmx_evs_enc_fx( { dmx_pha_data[n] = Mpy_32_32( dmx_pha_data[n], fad_g[n] ); move32(); - dmx_pha_data[n] = L_add( dmx_pha_data[n], Mpy_32_32( mem_prev[n], fad_g[m] ) ); // Q11 + dmx_pha_data[n] = L_add( dmx_pha_data[n], Mpy_32_32( mem_prev[n], fad_g[m] ) ); // Q26 move32(); } @@ -2025,7 +2044,7 @@ void stereo_dmx_evs_enc_fx( curr_prc = hStereoDmxEVS->hPHA->curr_prc; move32(); // if ( abs( (int16_t) hStereoDmxEVS->itd ) > hStereoDmxEVS->hPHA->prc_thres ) - IF( GT_16( abs_s( round_fx( hStereoDmxEVS->itd_fx ) ), hStereoDmxEVS->hPHA->prc_thres ) ) + IF( GT_16( abs_s( hStereoDmxEVS->itd_fx ), hStereoDmxEVS->hPHA->prc_thres ) ) { IF( NE_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { @@ -2102,9 +2121,9 @@ void stereo_dmx_evs_enc_fx( FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len; ( n++, m-- ) ) { - p_dmx_data[n] = Mpy_32_32( p_dmx_data[n], fad_g[n] ); // Q11 + p_dmx_data[n] = Mpy_32_32( p_dmx_data[n], fad_g[n] ); // Q26 move32(); - p_dmx_data[n] = L_add( p_dmx_data[n], Mpy_32_32( fad_g[m], dmx_pha_data[n] ) ); // Q11 + p_dmx_data[n] = L_add( p_dmx_data[n], Mpy_32_32( fad_g[m], dmx_pha_data[n] ) ); // Q26 move32(); } } @@ -2121,16 +2140,15 @@ void stereo_dmx_evs_enc_fx( FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len; ( n++, m-- ) ) { - p_dmx_data[n] = Mpy_32_32( p_dmx_data[n], fad_g[n] ); // Q11 + p_dmx_data[n] = Mpy_32_32( p_dmx_data[n], fad_g[n] ); // Q26 move32(); - p_dmx_data[n] = L_add( p_dmx_data[n], Mpy_32_32( fad_g[m], dmx_poc_data[n] ) ); // Q11 + p_dmx_data[n] = L_add( p_dmx_data[n], Mpy_32_32( fad_g[m], dmx_poc_data[n] ) ); // Q26 move32(); } } } - Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q11->Q0 - + Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 return; } @@ -2149,9 +2167,9 @@ ivas_error stereo_dmx_evs_init_encoder_fx( STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS; Word16 n, input_frame; - Word16 m, len, pha_len, fad_len, fad_len2, trans_len /*, itrh*/, rfft_ipd_coef_step, n0, input_frame_pha; - Word32 *fad_g, fad_r /*, a_min, a_max, a_step*/, *ipd_ff; - Word16 *win, tmp_r; + Word16 m, len, pha_len, fad_len, fad_len2, rfft_ipd_coef_step, n0, input_frame_pha; + Word32 *fad_g, fad_r, *ipd_ff; + Word16 *win; const Word16 *p_ipd_w; Word16 tmp_e; @@ -2383,17 +2401,19 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_len = hStereoDmxEVS->hPHA->fad_len; move16(); - trans_len = idiv1616( pha_len, 20 ); - set16_fx( hStereoDmxEVS->hPHA->win_fx, 29491 /*1.8f in Q15*/, sub( pha_len, trans_len ) ); + set16_fx( hStereoDmxEVS->hPHA->win_fx, 29491 /*1.8f in Q14*/, pha_len ); hStereoDmxEVS->hPHA->win_fx[0] = ONE_IN_Q14; move16(); - // tmp_r = 1.0f / ( ( trans_len * 2 ) + 1 ); - tmp_r = div_s( 1, add( shl( trans_len, 1 ), 1 ) ); - win = &( hStereoDmxEVS->hPHA->win_fx[pha_len - trans_len] ); - FOR( n = 0; n < trans_len; n++ ) + IF( EQ_32( input_Fs, 16000 ) ) { - // win[n] = ( 0.5f * ( 1.0f + cosf( ( PI2 * ( n + 1 ) ) * tmp_r ) ) ) * 1.8f; - win[n] = mult_r( add( ONE_IN_Q14, getCosWord16R2( imult1616( add( n, 1 ), tmp_r ) ) ), 29491 /*1.8/2 in Q15*/ ); + hStereoDmxEVS->hPHA->win_fx[pha_len - 1] = 7373; /*0.45f in Q14*/ + move16(); + } + ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) + { + hStereoDmxEVS->hPHA->win_fx[sub( pha_len, 2 )] = 19302; /*1.1781f in Q14*/ + move16(); + hStereoDmxEVS->hPHA->win_fx[sub( pha_len, 1 )] = 2816; /*0.1718f in Q14*/ move16(); } diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 0577987067b0619181a31f741ac782884febb4a2..a8a088f209906e8817948a6de6915e0926e82a27 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -408,8 +408,8 @@ static void deEmphResample_fx( /* De-emphasis, 1/(1-mu z^-1), and resample, stage 1 */ - deemph_fx_32( 0, buf1_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[0] ); - deemph_fx_32( 0, buf2_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[1] ); + deemph_fx_32( buf1_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[0] ); + deemph_fx_32( buf2_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[1] ); FOR( i = 0; i < ( input_frame / dsFac1 ); i++ ) { @@ -420,8 +420,8 @@ static void deEmphResample_fx( } /* De-emphasis, 1/(1-mu z^-1), and resample, stage 2 */ - deemph_fx_32( 0, tempBuf1_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[2] ); - deemph_fx_32( 0, tempBuf2_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[3] ); + deemph_fx_32( tempBuf1_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[2] ); + deemph_fx_32( tempBuf2_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[3] ); FOR( i = 0; i < ( input_frame / dsFactor ); i++ ) { @@ -1094,13 +1094,9 @@ static void corrStatsEst_fx( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 429496730 /* 0.2 in Q31*/ ), hStereoTCA->delay_0_mem_exp, L_mult0( 26214 /* 0.8 in Q15*/, corrLagStats[0] ), Q16, &temp ); /* Q31-temp */ move32(); -#ifdef FIX_USAN_ISSUES Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, L_negate( hStereoTCA->delay_0_mem_fx[0] ), hStereoTCA->delay_0_mem_exp, &exp ) ); /* Q31-exp */ -#else - Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -hStereoTCA->delay_0_mem_fx[0], hStereoTCA->delay_0_mem_exp, &exp ) ); /* Q31-exp */ -#endif - inpp = L_shl_sat( inpp, sub( exp, 5 ) ); /* Q26 */ - IF( GT_32( inpp, 1677721600 ) ) // 25 in Q26 + inpp = L_shl_sat( inpp, sub( exp, 5 ) ); /* Q26 */ + IF( GT_32( inpp, 1677721600 ) ) // 25 in Q26 { set32_fx( &( hStereoTCA->delay_0_mem_fx[0] ), hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], MAX_DELAYREGLEN - 1 ); hStereoTCA->delay_0_mem_exp = temp; @@ -1968,22 +1964,8 @@ void stereo_tca_enc_fx( Word16 temp_exp, tempF_16fx; Word16 scalar_value = BASOP_Util_Divide1616_Scale( currentNCShift, dsFactor, &temp_exp ); /* Q15-temp_exp */ -#ifndef FIX_1300_ICA_SHIFT_QUANT_IMPROV - IF( temp_exp < 0 ) - { - scalar_value = shl( scalar_value, sub( temp_exp, Q3 ) ); // Q12 - hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, ONE_IN_Q11, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ - move16(); - } - ELSE - { - hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, shl( 1, sub( 14, temp_exp ) ), ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ - move16(); - } -#else - scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ - hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ -#endif + scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ + hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ tempF_fx = tempF_16fx; move32(); @@ -2263,7 +2245,6 @@ static void unclr_calc_corr_features_fx( side_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_negate( L_shr( buf2[i], 1 ) ), sub( 31, q_com ), &exp ); /* Q31-exp */ ener_side = BASOP_Util_Add_Mant32Exp( ener_side, ener_side_exp, Mpy_32_32( side_i, side_i ), shl( exp, 1 ), &ener_side_exp ); /* Q31-ener_side_exp */ -#ifdef FIX_ISSUE_1125 Word16 n1, n2, prod_i_exp; Word32 x, y, prod_i; n1 = norm_l( buf1[i] ); @@ -2273,9 +2254,6 @@ static void unclr_calc_corr_features_fx( prod_i = Mpy_32_32( x, y ); // q: q_com * 2 + n1 + n2 - 31 prod_i_exp = sub( 62, add( shl( q_com, 1 ), add( n1, n2 ) ) ); sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, prod_i, prod_i_exp, &sum_prod_exp ); /* Q31-sum_prod_exp */ -#else - sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, Mpy_32_32( buf1[i], buf2[i] ), sub( 62, shl( q_com, 1 ) ), &sum_prod_exp ); /* Q31-sum_prod_exp */ -#endif } /* average energy of L and R channels */ diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index ad038f0fa33392763ccb3751d73ca3deebd2895c..eba30f7621eb97cad131d197a949d7d98704f5ee 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -102,14 +102,15 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/ Word16 shb_frame_target_e, Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/ - Word16 shb_synth_nonref_e, + Word16 *shb_synth_nonref_e, Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/ - Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Qx*/ - Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/ + Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Q31-memShbSpecMapping_e*/ + Word16 *memShbSpecMapping_e, + Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/ Word16 *memShbSpecXcorr_e ) { Word16 idx; - + Word16 max_exp; Word16 Txx1_fx = 0, Txx2_fx = 0, Txx3_fx = 0, T_desired_fx = 0; Word16 Txx1_e = 0, Txx2_e = 0, Txx3_e = 0, T_desired_e = 0; Word16 T_nonref_target_fx, temp_fx; @@ -136,10 +137,10 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( temp11_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp11_exp ); /* Q31-temp1_exp */ /* Calculate rxx(1)/rxx(0) of the non ref synth */ - temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp ); /* Q31-temp0_exp */ - temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 1, shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp ); /* Q31-temp1_exp */ - temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 2, shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp ); /* Q31-temp2_exp */ - temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 3, shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp ); /* Q31-temp3_exp */ + temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx, *shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp ); /* Q31-temp0_exp */ + temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx + 1, *shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp ); /* Q31-temp1_exp */ + temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx + 2, *shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp ); /* Q31-temp2_exp */ + temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx + 3, *shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp ); /* Q31-temp3_exp */ exp = s_max( *memShbSpecXcorr_e, s_max( s_max( s_max( temp00_exp, temp11_exp ), s_max( temp0_exp, temp1_exp ) ), s_max( temp2_exp, temp3_exp ) ) ); @@ -291,8 +292,19 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( *specMapping_fx = L_deposit_h( specMapping16 ); move32(); + max_exp = s_max( sub( *memShbSpecMapping_e, norm_l( *memShbSpecMapping_fx ) ), *shb_synth_nonref_e ); + + *memShbSpecMapping_fx = L_shl( *memShbSpecMapping_fx, sub( *memShbSpecMapping_e, max_exp ) ); // max_exp + move32(); + *memShbSpecMapping_e = max_exp; + move16(); + + scale_sig32( shb_synth_nonref_fx, L_FRAME16k, sub( *shb_synth_nonref_e, max_exp ) ); // max_exp + *shb_synth_nonref_e = max_exp; + move16(); + /* IC-BWE spec mapping */ - deemph_fx_32( 0, shb_synth_nonref_fx, extract_h( *specMapping_fx ), L_FRAME16k, memShbSpecMapping_fx ); + deemph_fx_32( shb_synth_nonref_fx, specMapping16, L_FRAME16k, memShbSpecMapping_fx ); // shb_synth_nonref_e return idx; } @@ -429,7 +441,7 @@ static void icbwe_dft_stereo_param_ivas_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i : */ Encoder_State *st, /* i/o: */ Word32 *shb_synth_nonref_fx, /* i/o: Q31-shb_synth_nonref_e*/ - Word16 shb_synth_nonref_e /* i/o: */ + Word16 *shb_synth_nonref_e /* i/o: */ ) { Word16 slopeILD_fx; @@ -439,7 +451,7 @@ static void icbwe_dft_stereo_param_ivas_fx( Word32 *nrg_L_fx, *nrg_R_fx, *nrg_DMX_fx; Word32 sum_nrg_L_fx, sum_nrg_R_fx, sum_nrg_DMX_fx; const Word32 spec_table_fx[4] = { -1288490189, -858993459, -429496730, 0 }; // Q31 - const Word16 slope_table_fx16[4] = { -17788, -10577, -4822, 0 }; // Q13 + const Word16 slope_table_fx16[4] = { -278, -165, -75, 0 }; // Q7 BSTR_ENC_HANDLE hBstr = st->hBstr; normFac_fx = 1342177280; /* 1000 * (10/((14400+10400)/2 - (6400+10400)/2)) */ // Q29 @@ -505,6 +517,7 @@ static void icbwe_dft_stereo_param_ivas_fx( IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) ) { /* Spec Mapping Estimate */ + Word16 max_exp; Word16 tmp1, exp1; Word32 L_tmp, L_tmp1; L_tmp = Mpy_32_32( hStereoICBWE->mem_nrg_L_fx[1], hStereoICBWE->mem_nrg_R_fx[0] ); // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1] @@ -527,10 +540,20 @@ static void icbwe_dft_stereo_param_ivas_fx( } hStereoICBWE->prevSpecMapping_fx = spec_table_fx[spIndx]; // q31 - /* ic bwe spec mapping application */ - deemph_fx_32( 0, shb_synth_nonref_fx, extract_l( L_shr( hStereoICBWE->prevSpecMapping_fx, 16 ) ), L_FRAME16k, &hStereoICBWE->memShbSpecMapping_fx ); // shb_synth_nonref_e - hStereoICBWE->memShbSpecMapping_e = shb_synth_nonref_e; + + max_exp = s_max( *shb_synth_nonref_e, sub( hStereoICBWE->memShbSpecMapping_e, norm_l( hStereoICBWE->memShbSpecMapping_fx ) ) ); + + hStereoICBWE->memShbSpecMapping_fx = L_shl( hStereoICBWE->memShbSpecMapping_fx, sub( hStereoICBWE->memShbSpecMapping_e, max_exp ) ); // max_exp + move32(); + hStereoICBWE->memShbSpecMapping_e = max_exp; + move16(); + + scale_sig32( shb_synth_nonref_fx, L_FRAME16k, sub( *shb_synth_nonref_e, max_exp ) ); + *shb_synth_nonref_e = max_exp; move16(); + + /* ic bwe spec mapping application */ + deemph_fx_32( shb_synth_nonref_fx, extract_h( hStereoICBWE->prevSpecMapping_fx ), L_FRAME16k, &hStereoICBWE->memShbSpecMapping_fx ); // shb_synth_nonref_e } ELSE { @@ -572,7 +595,7 @@ static void icbwe_dft_stereo_param_ivas_fx( move32(); move16(); - gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */ + gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */ hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx ); /* Q31-exp */ hStereoICBWE->gDes_pastFrame_e = exp; @@ -800,7 +823,7 @@ void stereo_icBWE_enc_ivas_fx( move16(); } - icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, shb_synth_nonref_e ); + icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, &shb_synth_nonref_e ); } ELSE { @@ -809,11 +832,7 @@ void stereo_icBWE_enc_ivas_fx( Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e set32_fx( shb_frame_ref_fx, 0, L_LOOK_16k + L_FRAME16k ); -#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hStereoICBWE->mem_shb_speech_ref_fx, shb_frame_ref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#else - Copy_Scale_sig_16_32_DEPREC( hStereoICBWE->mem_shb_speech_ref_fx, shb_frame_ref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#endif hStereoICBWE->mem_shb_speech_ref_e = max_e; shb_frame_ref_e = max_e; move16(); @@ -826,12 +845,8 @@ void stereo_icBWE_enc_ivas_fx( set32_fx( shb_frame_nonref_fx, 0, L_LOOK_16k + L_FRAME16k ); max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e ); - Copy_Scale_sig( hStereoICBWE->mem_shb_speech_nonref_fx, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ) ); // mem_shb_speech_ref_e -#ifdef FIX_ISSUE_1237 + Copy_Scale_sig( hStereoICBWE->mem_shb_speech_nonref_fx, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ) ); // mem_shb_speech_ref_e Copy_Scale_sig_16_32_no_sat( hStereoICBWE->mem_shb_speech_nonref_fx, shb_frame_nonref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#else - Copy_Scale_sig_16_32_DEPREC( hStereoICBWE->mem_shb_speech_nonref_fx, shb_frame_nonref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#endif hStereoICBWE->mem_shb_speech_nonref_e = max_e; shb_frame_nonref_e = max_e; move16(); @@ -1028,14 +1043,7 @@ void stereo_icBWE_enc_ivas_fx( IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) ) { /* IC BWE spectral mapping */ - Word32 max_abs_val; - maximum_abs_32_fx( shb_synth_nonref_fx, L_FRAME16k, &max_abs_val ); - IF( max_abs_val > 0 ) - { - scale_sig32( shb_synth_nonref_fx, L_FRAME16k, -1 ); - shb_synth_nonref_e = sub( shb_synth_nonref_e, -1 ); - } - spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */ + spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_e ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */ } ELSE { @@ -1233,9 +1241,7 @@ void stereo_icBWE_preproc_fx( Word32 gD_fx; Word32 input_Fs; -#ifdef MSAN_FIX set16_fx( temp_inp_fx, 0, L_FRAME48k ); -#endif /* initialization */ hStereoTCA = hCPE->hStereoTCA; /* Stereo TCA encoder handle */ diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index b6857854222703856361681d216a5cddf98fe512..46134a27003ae2e970766643382ee84a84056feb 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -135,16 +135,15 @@ void stereo_mdct_core_enc_fx( { Word32 orig_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* MDCT output (L/R). */ Word32 *orig_spectrum_fx[CPE_CHANNELS][NB_DIV]; /* Pointers to MDCT output for a short block (L/R) */ - Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; - Word32 powerSpec_fx_tmp[CPE_CHANNELS][N_MAX]; /* This 32 bit buffer is created to preserve the precision for original separate Q calculation of powerSpec_fx buffer ( Related to 3gpp issue #1192 ) */ - Word32 *p_powerSpec_fx[CPE_CHANNELS]; - Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; + Word64 powerSpec64[CPE_CHANNELS][N_MAX]; + Word16 exp_powerSpec64[CPE_CHANNELS][NB_DIV]; Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */ Word32 *powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV]; Word32 quantized_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ Word32 *quantized_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV]; + Word16 exp_inv_spectrum[CPE_CHANNELS]; Word16 i, ch, nSubframes, L_subframeTCX; Word16 n, nAvailBits; Word16 tnsSize[CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */ @@ -153,8 +152,8 @@ void stereo_mdct_core_enc_fx( Word32 *p_mdst_spectrum_long_fx[CPE_CHANNELS]; Word32 mdst_spectrum_long_fx[CPE_CHANNELS][N_MAX]; Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV]; - Word16 q_powSpec[MCT_MAX_CHANNELS], q_powSpecMsInv[MCT_MAX_CHANNELS], q_spec, tmp_s; - Word16 tmp_q_powSpec[N_MAX], tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2]; + Word16 exp_powSpecMsInv[MCT_MAX_CHANNELS], q_spec, tmp_s; + Word16 tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2]; Word64 W_tmp; Encoder_State *st, **sts; STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; @@ -178,21 +177,16 @@ void stereo_mdct_core_enc_fx( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { -#ifdef MSAN_FIX set32_fx( mdst_spectrum_long_fx[ch], 0, N_MAX ); set32_fx( orig_spectrum_long_fx[ch], 0, N_MAX ); -#endif p_mdst_spectrum_long_fx[ch] = mdst_spectrum_long_fx[ch]; p_orig_spectrum_long_fx[ch] = orig_spectrum_long_fx[ch]; orig_spectrum_fx[ch][0] = orig_spectrum_long_fx[ch]; orig_spectrum_fx[ch][1] = orig_spectrum_long_fx[ch] + N_TCX10_MAX; - set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX ); + set16_fx( exp_powerSpec64[ch], 0, NB_DIV ); } set16_fx( tmp_q_powSpecInv, 63, N_MAX ); - set16_fx( tmp_q_powSpec, 63, N_MAX ); - set16_fx( q_powSpec, 31, MCT_MAX_CHANNELS ); - set16_fx( q_powSpecMsInv, 31, MCT_MAX_CHANNELS ); tmp_q_psi[0] = tmp_q_powSpecInv; tmp_q_psi[1] = &tmp_q_powSpecInv[N_TCX10_MAX]; @@ -252,7 +246,10 @@ void stereo_mdct_core_enc_fx( hCPE->hStereoMdct->stbParamsTCX20.nBandsStereoCore = hCPE->hStereoMdct->stbParamsTCX20.sfbCnt; move16(); } - + Word16 len = extract_l( Mpy_32_32( sts[0]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + Word16 q_com = s_min( s_min( add( sts[0]->q_inp, getScaleFactor16( sts[0]->input_fx, add( len, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ), add( sts[0]->q_old_inp, getScaleFactor16( sts[0]->old_input_signal_fx, len ) ) ), + s_min( add( sts[1]->q_inp, getScaleFactor16( sts[1]->input_fx, add( len, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ), add( sts[1]->q_old_inp, getScaleFactor16( sts[1]->old_input_signal_fx, len ) ) ) ); + q_com = sub( q_com, Q1 ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch]; @@ -263,22 +260,21 @@ void stereo_mdct_core_enc_fx( inv_spectrum_fx[ch][1] = quantized_spectrum_fx[ch][1]; mdst_spectrum_fx[ch][0] = mdst_spectrum_long_fx[ch]; mdst_spectrum_fx[ch][1] = mdst_spectrum_long_fx[ch] + N_TCX10_MAX; + set64_fx( powerSpec64[ch], 0, N_MAX ); set32_fx( powerSpecMsInv_long_fx[ch], 0, N_MAX ); set32_fx( quantized_spectrum_long_fx[ch], 0, N_MAX ); set32_fx( mdst_spectrum_long_fx[ch], 0, N_MAX ); - set32_fx( powerSpec_fx[ch], 0, N_MAX ); - set32_fx( powerSpec_fx_tmp[ch], 0, N_MAX ); set32_fx( powerSpecMsInv_long_fx[ch], 0, N_MAX ); sts[ch]->hTcxEnc->tns_ms_flag[0] = 0; move16(); sts[ch]->hTcxEnc->tns_ms_flag[1] = 0; move16(); - Scale_sig( sts[ch]->input_fx, add( extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( sts[ch]->q_inp ) ); /* Q0 */ - Scale_sig( sts[ch]->old_input_signal_fx, extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), negate( sts[ch]->q_old_inp ) ); /* Q0 */ - sts[ch]->q_old_inp = 0; + scale_sig( sts[ch]->input_fx, add( extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sub( q_com, sts[ch]->q_inp ) ); /* q_com */ + scale_sig( sts[ch]->old_input_signal_fx, extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), sub( q_com, sts[ch]->q_old_inp ) ); /* q_com */ + sts[ch]->q_old_inp = q_com; move16(); - sts[ch]->q_inp = 0; + sts[ch]->q_inp = q_com; move16(); } @@ -360,17 +356,38 @@ void stereo_mdct_core_enc_fx( } q_spec = sub( Q31, q_spec ); + /*find headroom to increase precision*/ + Word16 hdrm_min = MAX_16; + move16(); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - Word16 n_sb = NB_DIV; + length = sts[ch]->hTcxEnc->spectrum_length; move16(); - if ( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) { - n_sb = 1; - move16(); + length = shr( length, 1 ); + } + + hdrm_min = s_min( hdrm_min, L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[0], length ) ); + hdrm_min = s_min( hdrm_min, L_norm_arr( mdst_spectrum_fx[ch][0], length ) ); + + IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + hdrm_min = s_min( hdrm_min, L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[1], length ) ); + hdrm_min = s_min( hdrm_min, L_norm_arr( mdst_spectrum_fx[ch][1], length ) ); } - length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */ + } + q_spec = sub( add( hdrm_min, q_spec ), 1 ); /* 1 guard bit to avoid over-flows in stereo_coder_tcx_fx */ + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + length = sts[ch]->hTcxEnc->spectrum_length; + move16(); + IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + length = shr( length, 1 ); + } FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) { Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) ); /* q_spec */ @@ -380,12 +397,16 @@ void stereo_mdct_core_enc_fx( } } stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, q_spec ); + exp_inv_spectrum[0] = exp_inv_spectrum[1] = sub( Q31, q_spec ); + move16(); + move16(); } /*--------------------------------------------------------------* * Power spectrum calculation *---------------------------------------------------------------*/ - Word16 length; + Word16 length, exp, shift1, shift2, norm; + Word32 mdct, mdst; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -415,17 +436,13 @@ void stereo_mdct_core_enc_fx( IF( sts[ch]->hTcxEnc->tns_ms_flag[n] ) { + exp = add( s_max( mdst_spectrum_e[ch][n], sts[ch]->hTcxEnc->spectrum_e[n] ), 1 ); + shift1 = sub( mdst_spectrum_e[ch][n], exp ); + shift2 = sub( sts[ch]->hTcxEnc->spectrum_e[n], exp ); + /* power spectrum: MDCT^2 + MDST^2 */ FOR( i = 0; i < L_subframeTCX; i++ ) { - W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); /* 2*q_spec+1 */ - tmp_s = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ - powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ - tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 - move32(); - move16(); - W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */ tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ @@ -433,7 +450,14 @@ void stereo_mdct_core_enc_fx( tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 move32(); move16(); + + mdst = L_shl( mdst_spectrum_fx[ch][n][i], shift1 ); // exp: exp + mdct = L_shl( sts[ch]->hTcxEnc->spectrum_fx[n][i], shift2 ); // exp: exp + powerSpec64[ch][i + n * L_subframeTCX] = W_mac_32_32( W_mult_32_32( mdct, mdct ), mdst, mdst ); // exp: 2*exp + move64(); } + exp_powerSpec64[ch][n] = shl( exp, 1 ); + move16(); } ELSE { @@ -471,77 +495,51 @@ void stereo_mdct_core_enc_fx( } /* power spectrum: MDCT^2 + MDST^2 */ - W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][0], sts[ch]->hTcxEnc->spectrum_fx[n][0] ); /* 2*q_spec+1 */ - tmp_s = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ - powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ - tmp_q_powSpec[n * L_subframeTCX] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 - move32(); - move16(); + mdct = L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][0], 1 ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1 + powerSpec64[ch][n * L_subframeTCX] = W_mult_32_32( mdct, mdct ); // exp: 2(sts[ch]->hTcxEnc->spectrum_e[n]+1) + move64(); FOR( i = 1; i < L_subframeTCX - 1; i++ ) { - Word32 mdst_fx = L_sub( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], sts[ch]->hTcxEnc->spectrum_fx[n][i - 1] ); /* An MDST estimate q_spec*/ - - W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); /* 2*q_spec+1 */ - tmp_s = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ - powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ - tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 - move32(); - move16(); + mdct = L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1 + mdst = L_sub( L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i - 1], 1 ) ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1 + powerSpec64[ch][i + n * L_subframeTCX] = W_mac_32_32( W_mult_32_32( mdct, mdct ), mdst, mdst ); // exp: 2(sts[ch]->hTcxEnc->spectrum_e[n]+1) + move64(); } - W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] ); /* 2*q_spec+1 */ - tmp_s = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ - powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ - tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 - move32(); + mdct = L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], 1 ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1 + powerSpec64[ch][L_subframeTCX - 1 + n * L_subframeTCX] = W_mult_32_32( mdct, mdct ); // exp: 2(sts[ch]->hTcxEnc->spectrum_e[n]+1) + move64(); + + exp_powerSpec64[ch][n] = shl( add( sts[ch]->hTcxEnc->spectrum_e[n], 1 ), 1 ); move16(); } } /* Aligning the Q-factors */ { - q_powSpec[ch] = Q31; - q_powSpecMsInv[ch] = Q31; - move16(); + Word16 q_temp = Q31; move16(); - FOR( i = 0; i < N_MAX; i++ ) - { - IF( powerSpec_fx[ch][i] != 0 ) - { - q_powSpec[ch] = s_min( q_powSpec[ch], tmp_q_powSpec[i] ); - move16(); - exp_powerSpec[ch][i] = sub( Q31, tmp_q_powSpec[i] ); - move16(); - } - } FOR( n = 0; n < nSubframes; n++ ) { FOR( i = 0; i < L_subframeTCX; i++ ) { - IF( powerSpecMsInv_fx[ch][n][i] != 0 ) + if ( powerSpecMsInv_fx[ch][n][i] != 0 ) { - q_powSpecMsInv[ch] = s_min( q_powSpecMsInv[ch], tmp_q_psi[n][i] ); - move16(); + q_temp = s_min( q_temp, tmp_q_psi[n][i] ); } } } - FOR( n = 0; n < nSubframes; n++ ) { FOR( i = 0; i < L_subframeTCX; i++ ) { - powerSpecMsInv_fx[ch][n][i] = L_shr_sat( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpecMsInv[ch] ) ); - /* Here precision is preserved for powerSpec_fx buffer by storing the fixed Q copy of same buffer in powerSpec_fx_tmp buffer */ - /* powerSpec_fx implementation has separate Q for each index, powerSpec_fx_tmp has all indices in same Q beyond this point */ - powerSpec_fx_tmp[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i + ( n * L_subframeTCX )], q_powSpec[ch] ) ); /* q_powSpec */ - move32(); + powerSpecMsInv_fx[ch][n][i] = L_shr_sat( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_temp ) ); move32(); } } + exp_powSpecMsInv[ch] = sub( Q31, q_temp ); + move16(); } } @@ -574,8 +572,9 @@ void stereo_mdct_core_enc_fx( * and quantization (0: tonal, 1: noise-like). * * Detect low pass if present. * *-----------------------------------------------------------*/ - ComputeSpectrumNoiseMeasure_fx( powerSpec_fx_tmp[ch], L_subframeTCX, i_mult( st->hTcxEnc->nmStartLine, idiv1616( L_subframeTCX, st->hTcxEnc->L_frameTCX ) ), - NE_32( imult3216( st->last_sr_core, st->L_frame ), imult3216( st->sr_core, st->L_frame_past ) ) || NE_16( st->last_core, TCX_20_CORE ), st->hTcxEnc->memQuantZeros, L_subframeTCX ); + ComputeSpectrumNoiseMeasure_ivas_fx( powerSpec64[ch], L_subframeTCX, i_mult( st->hTcxEnc->nmStartLine, idiv1616( L_subframeTCX, st->hTcxEnc->L_frameTCX ) ), + NE_32( imult3216( st->last_sr_core, st->L_frame ), imult3216( st->sr_core, st->L_frame_past ) ) || NE_16( st->last_core, TCX_20_CORE ), + st->hTcxEnc->memQuantZeros, L_subframeTCX ); } st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling Q14*/ @@ -608,53 +607,98 @@ void stereo_mdct_core_enc_fx( IF( ( NE_16( hStereoMdct->mdct_stereo_mode[n], hStereoMdct->IGFStereoMode[n] ) || EQ_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) ) && !hStereoMdct->isSBAStereoMode ) { IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; - p_powerSpec_fx[0] = powerSpec_fx_tmp[0]; - p_powerSpec_fx[1] = powerSpec_fx_tmp[1]; - hIGFEnc[0] = sts[0]->hIGFEnc; - hIGFEnc[1] = sts[1]->hIGFEnc; - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + Word32 powerSpec_fx[CPE_CHANNELS][N_MAX], *p_powerSpec_fx[CPE_CHANNELS]; + Word16 exp_powSpec[CPE_CHANNELS]; + p_powerSpec_fx[0] = powerSpec_fx[0]; + p_powerSpec_fx[1] = powerSpec_fx[1]; { - q_spec = sub( Q31, sts[ch]->hTcxEnc->spectrum_e[n] ); - Word16 q_comm = s_min( sub( Q31, sts[ch]->hTcxEnc->spectrum_e[n] ), s_min( q_powSpec[ch], q_powSpecMsInv[ch] ) ); - Word16 n_sb = NB_DIV; - move16(); - if ( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - n_sb = 1; + Word16 n1, nsub = 1; + length = sts[ch]->hTcxEnc->L_frameTCX; move16(); - } - length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */ - IF( NE_16( q_spec, q_comm ) ) - { - Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_comm, q_spec ) ); /* q_powSpec */ - Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_comm, q_spec ) ); /* q_powSpec */ - sts[ch]->hTcxEnc->spectrum_e[n] = sub( Q31, q_comm ); - move16(); - } - IF( NE_16( q_powSpec[ch], q_comm ) ) - { - Scale_sig32( &p_powerSpec_fx[ch][0], L_subframeTCX, sub( q_comm, q_powSpec[ch] ) ); /* q_spec */ - q_powSpec[ch] = q_comm; move16(); - } - IF( NE_16( q_powSpecMsInv[ch], q_comm ) ) - { - Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_comm, q_powSpecMsInv[ch] ) ); /* q_spec */ - q_powSpecMsInv[ch] = q_comm; + IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); + nsub = NB_DIV; + move16(); + } + IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) + { + length = add( length, shr( length, 2 ) ); + } + exp = sub( exp_powerSpec64[ch][0], W_norm_arr( powerSpec64[ch], length ) ); + IF( EQ_16( nsub, 2 ) ) + { + exp = s_max( exp, sub( exp_powerSpec64[ch][1], W_norm_arr( powerSpec64[ch] + length, length ) ) ); + } + FOR( n1 = 0; n1 < nsub; n1++ ) + { + shift1 = sub( sub( exp_powerSpec64[ch][n1], exp ), 32 ); + FOR( i = 0; i < length; i++ ) + { + /* This doesn't result in saturation */ + powerSpec_fx[ch][i + n1 * length] = W_shl_sat_l( powerSpec64[ch][i + n1 * length], shift1 ); // exp: exp + move32(); + } + } + set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); + exp_powSpec[ch] = exp; // exp: exp move16(); } } + + hIGFEnc[0] = sts[0]->hIGFEnc; + hIGFEnc[1] = sts[1]->hIGFEnc; hIGFEnc[0]->spec_be_igf_e = p_orig_spectrum_e[0]; - move16(); hIGFEnc[1]->spec_be_igf_e = p_orig_spectrum_e[1]; move16(); - ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, - orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ), - p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); + move16(); + + ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ), + p_powerSpec_fx, exp_powSpec, powerSpecMsInv_fx, exp_powSpecMsInv, inv_spectrum_fx, exp_inv_spectrum, + n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); } ELSE { + Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; // each value has a different exponent + Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; + { + /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + Word16 n1, nsub; + nsub = 1; + length = sts[ch]->hTcxEnc->L_frameTCX; + move16(); + move16(); + IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); + nsub = NB_DIV; + move16(); + } + IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) + { + length = add( length, shr( length, 2 ) ); + } + FOR( n1 = 0; n1 < nsub; n1++ ) + { + FOR( i = 0; i < length; i++ ) + { + norm = W_norm( powerSpec64[ch][i + n1 * length] ); + powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], norm ) ); // exp = exp_powerSpec64[ch][n1]-norm + exp_powerSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], norm ); + move32(); + move16(); + } + } + set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); + set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX + L_MDCT_OVLP_MAX, length ) ); + } + } FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -674,17 +718,49 @@ void stereo_mdct_core_enc_fx( q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ -#ifndef MSAN_FIX - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#else ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#endif } } } } ELSE { + Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; // each value has a different exponent + Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; + { + /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + Word16 n1, nsub; + nsub = 1; + length = sts[ch]->hTcxEnc->L_frameTCX; + move16(); + move16(); + IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); + nsub = NB_DIV; + move16(); + } + IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) + { + length = add( length, shr( length, 2 ) ); + } + FOR( n1 = 0; n1 < nsub; n1++ ) + { + FOR( i = 0; i < length; i++ ) + { + norm = W_norm( powerSpec64[ch][i + n1 * length] ); + powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], norm ) ); // exp = exp_powerSpec64[ch][n1]-norm + exp_powerSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], norm ); + move32(); + move16(); + } + } + set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); + set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX + L_MDCT_OVLP_MAX, length ) ); + } + } FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -719,11 +795,7 @@ void stereo_mdct_core_enc_fx( Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ -#ifndef MSAN_FIX - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#else ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#endif } } } @@ -754,7 +826,6 @@ void stereo_mdct_core_enc_fx( * Split available bits between channels *---------------------------------------------------------------*/ - Word16 q_com; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { Word16 n_sb = NB_DIV; diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index 851df60d532327c819ce1f4d60abca6127ce0de8..6c3588cabc6d7a93997e0937dfd86940f859dee8 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -166,12 +166,10 @@ static void IGF_MsStereoDecision_fx( Word16 pc_target_e, pc_src_e; Word16 tmp1, tmp1_e, tmp2, tmp2_e; -#ifdef MSAN_FIX pc_target_e = 0; pc_src_e = 0; move16(); move16(); -#endif // MSAN_FIX Word16 coh_src = calcCoh_fx( &specL_fx[strt_cpy], &specR_fx[strt_cpy], q_spec, width, &cc_src_fx, &cc_src_e, &pc_src_fx, &pc_src_e ); Word16 coh_target = calcCoh_fx( &specL_fx[hGrid->swb_offset[sfb]], &specR_fx[hGrid->swb_offset[sfb]], q_spec, width, &cc_target_fx, &cc_target_e, &pc_target_fx, &pc_target_e ); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index a61b2b0106170638a85e848080f6176e5ce661d5..9a1198e20608799d30d2c37da62da198d0eb75f0 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -836,52 +836,67 @@ void convertToMS_fx( /*! r: SQ gain */ static Word32 SQ_gain_estimate_stereo_fx( // e_res - Word32 xL_fx[], /* i : L vector to quantize Q31-e_xL*/ - Word16 e_xL, - Word32 xR_fx[], /* i : R vector to quantize Q31-e_xR*/ - Word16 e_xR, + const Word32 xL_fx[], /* i : L vector to quantize Q31-e_xL*/ + const Word16 e_xL, + const Word32 xR_fx[], /* i : R vector to quantize Q31-e_xR*/ + const Word16 e_xR, const Word16 nbitsSQ, /* i : number of bits targeted Q0*/ const Word16 lg, /* i : vector size (2048 max) Q0*/ Word16 *e_res ) { - Word16 i, q, iter, e_ener, e_tmp; + Word16 i, q, iter, e_ener, e_xL_2, e_xR_2, s; Word32 ener_fx, tmp_32, target_fx, fac_fx, offset_fx; - Word32 en_fx[N_MAX / 2]; // Q(26) + Word32 en_fx[N_MAX / 2]; // Q25 Word16 lg2, lg_4, lg2_4; + Word64 W_tmp, _0_01; lg_4 = shr( lg, 2 ); /* Q0 */ lg2_4 = shl( lg_4, 1 ); /* Q0 */ lg2 = shl( lg2_4, 2 ); /* Q0 */ i = 0; move16(); + e_xL_2 = shl( e_xL, 1 ); + e_xR_2 = shl( e_xR, 1 ); + _0_01 = W_shr( 21474836 /* 0.01 in Q31 */, sub( e_xL_2, 32 ) ); // 0.01 in 2*(Q of specL/R) + 1 - set32_fx( en_fx, 21474836 /* 0.01 in Q31 */, idiv1616( N_MAX, 2 ) ); + set32_fx( en_fx, 335544 /* 0.01 in Q25 */, ( N_MAX / 2 ) ); /* energy of quadruples with 9dB offset */ /* ignore that we may take no all lines into account, max. 3 lines at the upper end of the spectrum can be missed (if lg is not a multiple of 4, happens also in SQGain()*/ FOR( q = 0; q < lg_4; q++ ) { - ener_fx = BASOP_Util_Add_Mant32Exp( 21474836 /*0.01 in Q15*/, 0, Mpy_32_32( xL_fx[i], xL_fx[i] ), e_xL * 2, &e_ener ); /* Q31-e_ener */ - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 1], xL_fx[i + 1] ), e_xL * 2, &e_ener ); /* Q31-e_ener */ - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 2], xL_fx[i + 2] ), e_xL * 2, &e_ener ); /* Q31-e_ener */ - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 3], xL_fx[i + 3] ), e_xL * 2, &e_ener ); /* Q31-e_ener */ - en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */ + W_tmp = W_mac_32_32( _0_01, xL_fx[i], xL_fx[i] ); // 2 * e_xL + W_tmp = W_mac_32_32( W_tmp, xL_fx[i + 1], xL_fx[i + 1] ); // 2 * e_xL + W_tmp = W_mac_32_32( W_tmp, xL_fx[i + 2], xL_fx[i + 2] ); // 2 * e_xL + W_tmp = W_mac_32_32( W_tmp, xL_fx[i + 3], xL_fx[i + 3] ); // 2 * e_xL + + s = W_norm( W_tmp ); + ener_fx = W_extract_h( W_shl( W_tmp, s ) ); + e_ener = sub( e_xL_2, s ); + + en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */ move32(); - en_fx[q] = Mpy_32_16_1( L_add( e_ener * ONE_IN_Q25, en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) + en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); i = add( i, 4 ); } i = 0; + move16(); FOR( ; q < lg2_4; q++ ) { - ener_fx = BASOP_Util_Add_Mant32Exp( 21474836 /*0.01 Q15*/, 0, Mpy_32_32( xR_fx[i], xR_fx[i] ), e_xR * 2, &e_ener ); /* Q31-e_ener */ - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 1], xR_fx[i + 1] ), e_xR * 2, &e_ener ); /* Q31-e_ener */ - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 2], xR_fx[i + 2] ), e_xR * 2, &e_ener ); /* Q31-e_ener */ - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 3], xR_fx[i + 3] ), e_xR * 2, &e_ener ); /* Q31-e_ener */ - en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */ + W_tmp = W_mac_32_32( _0_01, xR_fx[i], xR_fx[i] ); // 2 * e_xR + W_tmp = W_mac_32_32( W_tmp, xR_fx[i + 1], xR_fx[i + 1] ); // 2 * e_xR + W_tmp = W_mac_32_32( W_tmp, xR_fx[i + 2], xR_fx[i + 2] ); // 2 * e_xR + W_tmp = W_mac_32_32( W_tmp, xR_fx[i + 3], xR_fx[i + 3] ); // 2 * e_xR + + s = W_norm( W_tmp ); + ener_fx = W_extract_h( W_shl( W_tmp, s ) ); + e_ener = sub( e_xR_2, s ); + + en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */ move32(); - en_fx[q] = Mpy_32_16_1( L_add( e_ener * ONE_IN_Q25, en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) + en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); i = add( i, 4 ); } @@ -898,24 +913,20 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res { fac_fx = L_shr( fac_fx, 1 ); /* Q25 */ offset_fx = L_sub( offset_fx, fac_fx ); /* Q25 */ - ener_fx = 0; - move32(); - e_ener = 0; - move16(); + W_tmp = 0; + move64(); FOR( i = 0; i < lg2_4; i++ ) { tmp_32 = L_sub( en_fx[i], offset_fx ); /* Q25 */ - e_tmp = 6; - move16(); /* avoid SV with 1 bin of amp < 0.5f */ IF( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) { - ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, tmp_32, e_tmp, &e_ener ); /* Q31-e_ener */ + W_tmp = W_add( W_tmp, W_deposit32_l( tmp_32 ) ); /* Q25 */ /* if ener is above target -> break and increase offset */ - IF( L_shl_sat( ener_fx, sub( e_ener, Q13 ) ) > target_fx ) + IF( GT_64( W_tmp, W_shl( W_deposit32_l( target_fx ), 7 ) ) ) { offset_fx = L_add( offset_fx, fac_fx ); /* Q25 */ BREAK; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 0a526561ae7317a3a06d15ea472636f2f3ad12fd..5f1208ba794687db7eb81e76deb2b7cd32935510 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -239,16 +239,12 @@ ivas_error stereo_memory_enc_fx( test(); IF( hCPE->hStereoTCA != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { -#ifdef FIX_1132_STACK_CORRUPTION Word16 tmp = extract_h( L_abs( hCPE->hStereoDft->hItd->itd_fx[1] ) ); if ( hCPE->hStereoDft->hItd->itd_fx[1] < 0 ) { tmp = negate( tmp ); } set16_fx( hCPE->hStereoTCA->prevCorrLagStats, tmp, 3 ); -#else - set16_fx( hCPE->hStereoTCA->prevCorrLagStats, extract_h( hCPE->hStereoDft->hItd->itd_fx[1] ), 3 ); -#endif IF( hCPE->hStereoDft->hItd->itd_fx[1] >= 0 ) { hCPE->hStereoTCA->prevRefChanIndx = L_CH_INDX; @@ -448,10 +444,8 @@ ivas_error stereo_memory_enc_fx( } fd_bwe_enc_init_fx( st->hBWE_FD ); -#ifdef MSAN_FIX st->Q_old_wtda = 0; move16(); -#endif } /* allocate stereo CNG structure */ @@ -679,10 +673,8 @@ void stereo_switching_enc_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */ -#ifdef FIX_ISSUE_1327 hCPE->q_input_mem[n] = sts[n]->q_inp; move16(); -#endif } } diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 44c08efa8a4fc05b01735b8127d84623b0ef3711..6ffd05c0c488dcfb4e56c7a582c7f79c21ed4628 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -71,18 +71,13 @@ #define RATIO_MAX 1.5f /* Maximum correlation ratio */ -#define RATIO_MAX_FX_Q30 ( 1610612736 ) /* 1.5f in Q30 */ /* Maximum correlation ratio */ -#ifdef FIX_1301_CORRECT_TD_CNST -#define RATIO_MAX_FX_Q24 ( 25165824 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ -#define RATIO_MAX_FX_Q23 ( 12582912 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ -#else -#define RATIO_MAX_FX_Q24 ( 2516582 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ -#define RATIO_MAX_FX_Q23 ( 1258291 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ -#endif -#define LIMIT_ADAP_FAC_FX_Q16 ( 9830 ) /* 0.15f in Q16 */ -#define MIN_ADAP_FAC_FX_Q16 ( 6554 ) /*0.1f in Q16*/ -#define M_ADAP_FX_Q31 ( 1932735 ) /* 0.0009f in Q31 */ -#define B_ADAP_FX_Q16 ( 10486 ) /* 0.16f in Q16 */ +#define RATIO_MAX_FX_Q30 ( 1610612736 ) /* 1.5f in Q30 */ /* Maximum correlation ratio */ +#define RATIO_MAX_FX_Q24 ( 25165824 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ +#define RATIO_MAX_FX_Q23 ( 12582912 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ +#define LIMIT_ADAP_FAC_FX_Q16 ( 9830 ) /* 0.15f in Q16 */ +#define MIN_ADAP_FAC_FX_Q16 ( 6554 ) /*0.1f in Q16*/ +#define M_ADAP_FX_Q31 ( 1932735 ) /* 0.0009f in Q31 */ +#define B_ADAP_FX_Q16 ( 10486 ) /* 0.16f in Q16 */ #define PC_LIMIT 64 #define RATIO_PG_HR 0.94f @@ -260,11 +255,7 @@ Word16 stereo_tdm_ener_analysis_fx( rms_thd_fx = L_shr( rms_thd_fx, 2 ); /*Q16*/ /*rms_thd_fx *= 0.25f*/ test(); test(); -#ifdef FIX_1301_CORRECT_TD_CNST IF( LE_32( hStereoTD->tdm_lt_rms_L_fx, 4915200 /* 75 in Q16*/ ) || LE_32( hStereoTD->tdm_lt_rms_R_fx, 4915200 /* 75 in Q16*/ ) /*|| sts[0]->last_coder_type == TRANSITION */ ) -#else - IF( LE_32( hStereoTD->tdm_lt_rms_L_fx, 4915200 /* 75 in Q16*/ ) || LE_32( hStereoTD->tdm_lt_rms_R_fx, 75 /* 75 in Q16*/ ) /*|| sts[0]->last_coder_type == TRANSITION */ ) -#endif { rms_thd_fx = L_shr( rms_thd_fx, 5 ); /* Q16*/ /*rms_thd_fx *= 0.03125f*/ } @@ -338,10 +329,8 @@ Word16 stereo_tdm_ener_analysis_fx( move16(); } -#ifdef FIX_1301_CORRECT_TD_CNST rms_L_fx = L_shl( rms_L_fx, sub( Q16, q_rms_L ) ); /* All the following energy comparison are done in Q16 */ rms_R_fx = L_shl( rms_R_fx, sub( Q16, q_rms_R ) ); -#endif test(); IF( EQ_16( hStereoTD->prev_fr_LRTD_TD_dec, 1 ) && side_can_change == 0 ) { @@ -440,11 +429,7 @@ Word16 stereo_tdm_ener_analysis_fx( ELSE { /*ratio_L = ( 1.0f - cosf( EVS_PI * ratio_L / 2.0f ) ) / 2.0f;*/ -#ifdef FIX_1301_CORRECT_TD_CNST ratio_L_fx = L_deposit_h( sub_sat( ONE_IN_Q14, getCosWord16( extract_l( Mpy_32_32( 1647099 /* EVS_PI/2 in Q20 */, ratio_L_fx ) ) ) ) ); // Q31 (Q14 + Q1(division by 2.0f) + Q16) -#else - ratio_L_fx = L_deposit_h( sub( ONE_IN_Q14, getCosWord16( extract_l( Mpy_32_32( 1647099 /* EVS_PI/2 in Q20 */, ratio_L_fx ) ) ) ) ); // Q31 (Q14 + Q1(division by 2.0f) + Q16) -#endif } test(); @@ -650,22 +635,14 @@ Word16 stereo_tdm_ener_analysis_fx( move16(); } -#ifdef FIX_ISSUE_1125 ratio_L_fx = tdm_ratio_tabl_fx_Q30[idx]; // Q30 -#else - ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 -#endif move32(); test(); IF( EQ_16( hStereoTD->tdm_SM_modi_flag, 1 ) && hStereoTD->tdm_LRTD_flag == 0 ) { idx = shr( add( hStereoTD->tdm_last_ratio_idx, add( LRTD_STEREO_MID_IS_PRIM, 1 ) ), 1 ); -#ifdef FIX_ISSUE_1125 ratio_L_fx = tdm_ratio_tabl_fx_Q30[idx]; // Q30 -#else - ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 -#endif move32(); } @@ -756,10 +733,8 @@ Word16 stereo_tdm_ener_analysis_fx( hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx; /* 31 - ratio_L_e */ move32(); -#ifdef FIX_ISSUE_1125 hCPE->hStereoClassif->ratio_L_e = 1; move16(); -#endif return idx; } @@ -1073,11 +1048,7 @@ static void NOOP_decision_fx( } ELSE { -#ifdef FIX_1301_CORRECT_TD_CNST if ( LT_32( sts[0]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) ) -#else - if ( LT_32( sts[0]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) ) -#endif { tdm_NOOP_switch_flag = 1; move16(); diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 3780688276320dd2c4ac9d81bb6e849389e9fa6f..8f1d2d9c9c46d088fd8d6375b55d48e2028fd660 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -336,10 +336,8 @@ ivas_error stereo_set_tdm_fx( } fd_bwe_enc_init_fx( st->hBWE_FD ); -#ifdef MSAN_FIX st->Q_old_wtda = 0; move16(); -#endif } } diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index eabfe87b48124b8e97d483242005d0ceada58950..fd84d2f214607c54aa281af61db11af3acfc41d6 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -205,7 +205,7 @@ void stereo_tcx_core_enc( /*HM*/ Word16 indexBuffer[2 * ( ( N_MAX / 2 ) + 1 )]; - Word16 s, input_frame; + Word16 s; CONTEXT_HM_CONFIG hm_cfg[2]; @@ -377,13 +377,6 @@ void stereo_tcx_core_enc( Q_new = 0; move16(); - input_frame = idiv1616U( extract_l( L_shr( st->input_Fs, 1 ) ), FRAMES_PER_SEC / 2 ); - Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); - Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); - st->q_old_inp = 0; - move16(); - st->q_inp = 0; - move16(); core_signal_analysis_high_bitrate_ivas_fx( p_new_samples, T_op, lsp_new_fx, lsp_mid_fx, st, tnsSize, tnsBits, param_core, <pBits, NULL, st->L_frame, hTcxEnc->L_frameTCX, last_element_mode, vad_hover_flag, NULL, NULL, &Q_new, NULL ); @@ -562,9 +555,9 @@ void stereo_tcx_core_enc( } Scale_sig( st->synth, st->L_frame, s ); /* st->Q_syn + s */ Scale_sig( st->hLPDmem->syn, M + 1, s ); /* st->Q_syn + s */ + st->hLPDmem->q_lpd_syn = add( st->hLPDmem->q_lpd_syn, s ); Q_new = add( Q_new, s ); move16(); - move16(); coder_tcx_post_ivas_fx( st, st->hLPDmem, st->hTcxCfg, st->synth, A_q_fx, Aw_fx, st->wspeech_enc, Q_new ); @@ -688,19 +681,7 @@ void stereo_tcx_core_enc( { set16_fx( pitch_buf_fx, L_SUBFR * ONE_IN_Q6, NB_SUBFR16k ); /* Q6 */ } - /* Memory scaling to keep everything in common q */ - Word16 curr_q_syn = sub( shl( Q_new, 1 ), 1 ); - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), curr_q_syn ) ); /* s_min( curr_q_syn, st->hLPDmem->q_mem_syn ) */ - Scale_sig( st->hLPDmem->mem_syn, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), curr_q_syn ) ); /* s_min( curr_q_syn, st->hLPDmem->q_mem_syn ) */ - Scale_sig( st->hLPDmem->mem_syn2, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), curr_q_syn ) ); /* s_min( curr_q_syn, st->hLPDmem->q_mem_syn ) */ - st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( s_min( Q_new, st->hLPDmem->q_mem_syn ), Q_new ) ); /* s_min( Q_new, st->hLPDmem->q_mem_syn ) */ - move16(); - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), st->hLPDmem->q_mem_syn ) ); /* s_min( curr_q_syn, st->hLPDmem->q_mem_syn ) */ - Scale_sig( st->hLPDmem->mem_syn3, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), st->hLPDmem->q_mem_syn ) ); /* s_min( curr_q_syn, st->hLPDmem->q_mem_syn ) */ - st->hLPDmem->q_mem_syn = s_min( curr_q_syn, st->hLPDmem->q_mem_syn ); - move16(); - st->hLPDmem->q_lpd_syn = Q_new; - move16(); + IF( st->hTdCngEnc != NULL ) { FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) @@ -789,7 +770,6 @@ Word16 ivas_acelp_tcx20_switching_fx( L_frame = L_FRAME; move16(); } -#ifdef MSAN_FIX set16_fx( window_fx, 0, L_LOOK_16k ); set16_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); FOR( i = 0; i < L_LOOK_16k; i++ ) @@ -799,7 +779,6 @@ Word16 ivas_acelp_tcx20_switching_fx( window_p_fx[i].v.im = 0; move16(); } -#endif L_frame_tmp = L_frame; move16(); @@ -854,7 +833,6 @@ Word16 ivas_acelp_tcx20_switching_fx( overlap = st->hTcxCfg->tcx_mdct_window_delay; move16(); -#ifdef MSAN_FIX FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) { window_fx[st->hTcxCfg->tcx_mdct_window_length - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15 @@ -862,15 +840,6 @@ Word16 ivas_acelp_tcx20_switching_fx( window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15 move16(); } -#else - FOR( i = 0; i < L_LOOK_16k / 2; i++ ) - { - window_fx[L_LOOK_16k / 2 - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15 - move16(); - window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15 - move16(); - } -#endif } ELSE { @@ -1047,12 +1016,8 @@ Word16 ivas_acelp_tcx20_switching_fx( IF( LE_32( offset, 0xAA153 ) ) /* 0xAA153 -> 32.f * log2(10)/10 */ { -#ifdef FIX_USAN_ISSUES offset = (Word32) 0xFFD57AB5; /* 0xFFD57AB5 -> -128.f * log2(10)/10; */ move32(); -#else - offset = L_add( 0xFFD57AB5, 0 ); /* 0xFFD57AB5 -> -128.f * log2(10)/10; */ -#endif } offset_tcx = offset; move32(); @@ -1155,11 +1120,7 @@ Word16 ivas_acelp_tcx20_switching_fx( { *pt_ener_sfr = -668739840; /* 0xFFEC1185 -> log2(1e-6) in 6Q25 */ move32(); -#ifdef FIX_USAN_ISSUES tmp32 = (Word32) 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ -#else - tmp32 = 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ -#endif move32(); } ELSE diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index c959ef758f7f2b8e07fc3e98e8e4e5a8fa1d5188..77ddb35aaf38b39ea89084727e9e325ef7dccb92 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -157,6 +157,7 @@ void tdm_low_rate_enc( { E_UTIL_synthesis( 0, p_Aq, &exc_wo_nf_fx[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1, M ); /* Q_new */ p_Aq += ( M + 1 ); + scale_sig( hLPDmem->mem_syn, M, sub( hLPDmem->q_mem_syn, Q_new ) ); // Q_new -> hLPDmem->q_mem_syn } /*--------------------------------------------------------------------------------------* @@ -221,13 +222,9 @@ void encod_gen_2sbfr( LPD_state_HANDLE hLPDmem = st->hLPDmem; -#ifdef FIX_1320_LOWRATE_ACELP Word16 gcode16; Word32 Lgcode, Ltmp; -#endif -#ifdef MSAN_FIX set16_fx( cn, 0, 2 * L_SUBFR ); /* Target vector in residual domain */ -#endif /*------------------------------------------------------------------* * Initializations @@ -268,11 +265,7 @@ void encod_gen_2sbfr( Copy( &res[i_subfr], &exc[i_subfr], 2 * L_SUBFR ); // Q_new -#ifndef FIX_1320_LOWRATE_ACELP - find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); -#else find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); -#endif q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2, 2 * L_SUBFR, sub( 11, q_h1 ) ); @@ -298,21 +291,13 @@ void encod_gen_2sbfr( * Gain clipping test to avoid unstable synthesis on frame erasure *-----------------------------------------------------------------*/ -#ifndef FIX_1320_LOWRATE_ACELP - clip_gain = gp_clip_fx( st->element_mode, st->core_brate, st->voicing_fx, i_subfr, coder_type, xn, st->clip_var_fx, Q_new ); // Q0 -#else clip_gain = gp_clip_fx( st->element_mode, st->core_brate, st->voicing_fx, i_subfr, coder_type, xn, st->clip_var_fx, sub( Q_new, 1 ) ); // Q0 -#endif /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ -#ifndef FIX_1320_LOWRATE_ACELP - lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); -#else lp_filt_exc_enc_ivas_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); -#endif /* update long-term pitch gain for speech/music classifier */ st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14 move16(); @@ -345,30 +330,22 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); -#ifndef FIX_1320_LOWRATE_ACELP - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); -#else Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); /*Q0*/ hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ -#endif move16(); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ -#ifndef FIX_1320_LOWRATE_ACELP - hLPDmem->mem_w0 = sub( sub( xn[2 * L_SUBFR - 1], mult_r( gain_pit, y1[2 * L_SUBFR - 1] ) ), mult_r( extract_h( gain_code ), y2[2 * L_SUBFR - 1] ) ); -#else - Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ - Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ + Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_msu( Ltmp, y1[2 * L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ -#endif move16(); /*-----------------------------------------------------------------* @@ -376,15 +353,6 @@ void encod_gen_2sbfr( * Save the non-enhanced excitation for FEC_exc *-----------------------------------------------------------------*/ -#ifndef FIX_1320_LOWRATE_ACELP - FOR( i = 0; i < 2 * L_SUBFR; i++ ) - { - exc2[i + i_subfr] = mult( gain_pit, exc[i + i_subfr] ); - move16(); - exc[i + i_subfr] = add( exc2[i + i_subfr], mult( extract_h( gain_code ), code[i] ) ); - move16(); - } -#else FOR( i = 0; i < 2 * L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ @@ -397,7 +365,6 @@ void encod_gen_2sbfr( move16(); move16(); } -#endif /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ @@ -411,11 +378,7 @@ void encod_gen_2sbfr( * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ -#ifndef FIX_1320_LOWRATE_ACELP - E_UTIL_synthesis( 0, p_Aq, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1, M ); -#else Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); -#endif p_Aw += 2 * ( M + 1 ); p_Aq += 2 * ( M + 1 ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 3ff4774e60a14f494228de229aafdb265c425633..79b799c3887536503b820965373674f5d62ae5f9 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -70,7 +70,7 @@ struct IVAS_ENC * Local functions *---------------------------------------------------------------------*/ -static ivas_error configureEncoder_fx( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); +// static ivas_error configureEncoder_fx( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); static ivas_error setBandwidth_fx( IVAS_ENC_HANDLE hIvasEnc, const IVAS_ENC_BANDWIDTH maxBandwidth ); static ivas_error setChannelAwareConfig_fx( IVAS_ENC_HANDLE hIvasEnc, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); static ivas_error sanitizeBandwidth_fx( const IVAS_ENC_HANDLE hIvasEnc ); @@ -609,6 +609,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( return error; } +#ifndef HARM_ENC_INIT ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const Word32 inputFs, /* i : input sampling frequency */ @@ -649,11 +650,12 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( hIvasEnc->maxBandwidthUser = max_bwidth_user; - error = configureEncoder_fx( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); + error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); return error; } +#endif /*---------------------------------------------------------------------* * IVAS_ENC_ConfigureForSBAObjects() * @@ -1188,7 +1190,7 @@ static ivas_error configureEncoder( * Finalize initialization *-----------------------------------------------------------------*/ - IF( ( error = ivas_init_encoder( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_init_encoder_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1211,6 +1213,7 @@ static ivas_error configureEncoder( return error; } +#ifndef HARM_ENC_INIT static ivas_error configureEncoder_fx( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, @@ -1543,6 +1546,7 @@ static ivas_error configureEncoder_fx( return error; } +#endif /*---------------------------------------------------------------------* * IVAS_ENC_GetDelay() * @@ -1818,6 +1822,16 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( /* set pointers to the new buffers of indices in each element */ FOR( n = 0; n < st_ivas->nSCE; n++ ) { +#ifdef HARM_PUSH_BIT + st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ind_list = st_ivas->ind_list; + st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; + + if ( st_ivas->hSCE[n]->hMetaData != NULL ) + { + st_ivas->hSCE[n]->hMetaData->ind_list = st_ivas->ind_list_metadata; + st_ivas->hSCE[n]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata; + } +#else test(); IF( !( hIvasEnc->hCoreCoder == NULL && EQ_32( hEncoderConfig->ivas_format, MONO_FORMAT ) ) ) { @@ -1833,6 +1847,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( st_ivas->hSCE[n]->hMetaData->ind_list = st_ivas->ind_list_metadata; st_ivas->hSCE[n]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata; } +#endif } FOR( n = 0; n < st_ivas->nCPE; n++ ) @@ -1897,6 +1912,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } /* write indices into bitstream buffer */ +#ifndef HARM_PUSH_BIT IF( hEncoderConfig->element_mode_init == EVS_MONO ) { test(); @@ -1910,6 +1926,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } } ELSE +#endif { write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits ); } diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 6761dfb8296d21226261d62f774f892ba973f889..8fe425d740baaa1f32abe09edb9ca45d3b1c7a9e 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -647,11 +647,11 @@ static void lsfq_CNG_fx( Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); /* write the VQ index to the bitstream */ - push_indice_fx( hBstr, IND_ISF_0_0, idx_cv, 4 ); + push_indice( hBstr, IND_ISF_0_0, idx_cv, 4 ); /* write the LVQ index to the bitstream */ - push_indice_fx( hBstr, IND_ISF_0_1, idx_lvq[0], LEN_INDICE ); - push_indice_fx( hBstr, IND_ISF_0_1, idx_lvq[1], LSF_BITS_CNG - 4 - LEN_INDICE ); + push_indice( hBstr, IND_ISF_0_1, idx_lvq[0], LEN_INDICE ); + push_indice( hBstr, IND_ISF_0_1, idx_lvq[1], LSF_BITS_CNG - 4 - LEN_INDICE ); return; } @@ -733,7 +733,7 @@ static void lsfq_CNG_ivas_fx( /* MSVQ_ROM to be updated */ mslvq_cng_ivas_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts ); - index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq, 0 ); + index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 ); Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); /* write the VQ index to the bitstream */ @@ -1117,13 +1117,13 @@ void lsf_end_enc_fx( IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) ) { /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/ - push_indice_fx( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 ); + push_indice( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 ); } /* write predictor selection bit */ IF( EQ_16( predmode, 2 ) ) { - push_indice_fx( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); + push_indice( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); } test(); @@ -1134,7 +1134,7 @@ void lsf_end_enc_fx( Bit_alloc1 = &BC_TCVQ_BIT_ALLOC_40B[1]; FOR( i = 0; i < ( M / 2 ) + 3; i++ ) { - push_indice_fx( hBstr, IND_LSF, TCQIdx[i], Bit_alloc1[i] ); + push_indice( hBstr, IND_LSF, TCQIdx[i], Bit_alloc1[i] ); } } ELSE @@ -1175,7 +1175,7 @@ void lsf_end_enc_fx( move16(); cumleft -= num_bits; move16(); - push_indice_fx( hBstr, IND_LSF, indice[i], num_bits ); + push_indice( hBstr, IND_LSF, indice[i], num_bits ); } WHILE( cumleft > 0 ) @@ -1195,7 +1195,7 @@ void lsf_end_enc_fx( } cumleft = sub( cumleft, num_bits ); - push_indice_fx( hBstr, IND_LSF, indice[i], num_bits ); + push_indice( hBstr, IND_LSF, indice[i], num_bits ); i = add( i, 1 ); } } @@ -3636,7 +3636,7 @@ static void lsf_mid_enc_fx( /* convert LSFs back to LSPs */ lsf2lsp_fx( qlsf, lsp, M, int_fs ); - push_indice_fx( hBstr, IND_MID_FRAME_LSF_INDEX, idx, nb_bits ); + push_indice( hBstr, IND_MID_FRAME_LSF_INDEX, idx, nb_bits ); return; } diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index aa2255c68b1dbb7687dfb4be495a015286717a76..8f6a21d038271fa7643120e170965978c88fbeec 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -834,7 +834,7 @@ Word16 enc_lsf_tcxlpc_fx( move16(); FOR( i = 0; i < TCXLPC_NUMSTAGES; ++i ) { - push_next_indice_fx( hBstr, **indices, lsf_numbits[i] ); + push_next_indice( hBstr, **indices, lsf_numbits[i] ); ++*indices; } @@ -843,7 +843,7 @@ Word16 enc_lsf_tcxlpc_fx( NumBits = add( NumBits, TCXLPC_IND_NUMBITS ); FOR( i = 0; i < TCXLPC_IND_NUMSTAGES; ++i ) { - push_next_indice_fx( hBstr, **indices, lsf_ind_numbits[i] ); + push_next_indice( hBstr, **indices, lsf_ind_numbits[i] ); ++*indices; } } @@ -909,7 +909,7 @@ Word16 lsf_msvq_ma_encprm_fx( FOR( i = 0; i < no_indices; i++ ) { - push_next_indice_fx( hBstr, *param_lpc, bits_param_lpc[i] ); + push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); param_lpc++; nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); } @@ -919,7 +919,7 @@ Word16 lsf_msvq_ma_encprm_fx( IF( ( core == ACELP_CORE ) && acelp_midLpc ) { - push_next_indice_fx( hBstr, *param_lpc, bits_midlpc ); + push_next_indice( hBstr, *param_lpc, bits_midlpc ); nbits_lpc = add( nbits_lpc, bits_midlpc ); } } @@ -981,7 +981,7 @@ Word16 lsf_bctcvq_encprm_fx( FOR( i = 0; i < no_indices; i++ ) { - push_next_indice_fx( hBstr, *param_lpc, bits_param_lpc[i] ); + push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); param_lpc++; nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); } diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index af5a82b69edc9c96987d221c032b1aa30450ca50..8f8dd4537e60c9085f7237e3bee200ad9c7b7d3b 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -244,14 +244,14 @@ Word32 mslvq_cng_ivas_fx( /* for CNG there is only one bitrate but several lattice quantizer structures, depending on the previous VQ stage */ - mode_glb = add( START_CNG, idx_cv ); + mode_glb = add( START_CNG_IVAS, idx_cv ); move16(); p_sigma = sigma_MSLVQ_fx[mode]; // x2.56 move16(); p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 move16(); - p_scales = scales_fx[mode_glb]; // Q11 + p_scales = scales_ivas_fx[mode_glb]; // Q11 move16(); no_scales[0] = 0; diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index a7588283a503b6da73f49adf95eccb3ac0473ace..39119117598387b0be7081d46dd47b4c72c5a87a 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -698,9 +698,9 @@ void nelp_encoder_fx( } ELSE { - push_indice_fx( hBstr, IND_IG1, iG1_fx, 5 ); - push_indice_fx( hBstr, IND_IG2A, iG2_fx[0], 6 ); - push_indice_fx( hBstr, IND_IG2B, iG2_fx[1], 6 ); + push_indice( hBstr, IND_IG1, iG1_fx, 5 ); + push_indice( hBstr, IND_IG2A, iG2_fx[0], 6 ); + push_indice( hBstr, IND_IG2B, iG2_fx[1], 6 ); } test(); @@ -1019,7 +1019,7 @@ void nelp_encoder_fx( } ELSE { - push_indice_fx( hBstr, IND_NELP_FID, fid, 2 ); + push_indice( hBstr, IND_NELP_FID, fid, 2 ); } } diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 0851e4c1745ea0f780cac567fafdf0f63564bcd9..c8f698da907bbefd41bbee045fe960fe0ab9a892 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -740,14 +740,17 @@ void noise_est_down_ivas_fx( const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) q_fr_bands */ const Word16 q_fr_bands, /* i : Q of fr_bands */ Word32 bckr[], /* i/o: per band background noise energy estimate q_fr_bands */ - Word32 tmpN[], /* o : temporary noise update q_fr_bands */ - Word32 enr[], /* o : averaged energy over both subframes */ - const Word16 min_band, /* i : minimum critical band */ - const Word16 max_band, /* i : maximum critical band */ - Word16 *totalNoise, /* o : noise estimate over all critical bands */ - Word16 Etot, /* i : Energy of current frame */ - Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ - Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */ + Word16 *q_bckr, + Word32 tmpN[], /* o : temporary noise update q_fr_bands */ + Word16 *q_tmpN, + Word32 enr[], /* o : averaged energy over both subframes */ + Word16 *q_enr, + const Word16 min_band, /* i : minimum critical band */ + const Word16 max_band, /* i : maximum critical band */ + Word16 *totalNoise, /* o : noise estimate over all critical bands */ + Word16 Etot, /* i : Energy of current frame */ + Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ + Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */ ) { @@ -755,13 +758,17 @@ void noise_est_down_ivas_fx( const Word32 *pt1, *pt2; Word16 i; Word16 e_Noise, f_Noise; - Word32 e_min; Word32 totalNoise_temp; Word32 L_Etot, L_Etot_last, L_Etot_v_h2, L_Etot_v; Word64 sum; Word16 q_sum; + Word32 enr32[NB_BANDS], bckr32[NB_BANDS], tmpN32[NB_BANDS]; + Word16 enr_q[NB_BANDS], bckr_q[NB_BANDS], tmpN_q[NB_BANDS]; + Word16 shift, shift1, shift2, shift3; + Word64 tmpN64, tmp, enr64; - e_min = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands + Copy32( bckr, bckr32, NB_BANDS ); + set16_fx( bckr_q, *q_bckr, NB_BANDS ); L_Etot = L_shl( Etot, 16 ); /*Q24 for later AR1 computations*/ L_Etot_last = L_shl( *Etot_last, 16 ); @@ -778,7 +785,7 @@ void noise_est_down_ivas_fx( { sum = W_mac_32_16( sum, bckr[i], 1 ); // q_fr_bands+1 } - q_sum = add( q_fr_bands, 1 ); + q_sum = add( *q_bckr, 1 ); IF( sum == 0 ) { sum = W_mult0_32_32( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ); // Q31 @@ -808,8 +815,12 @@ void noise_est_down_ivas_fx( FOR( i = 0; i < NB_BANDS; i++ ) { /* enr[i] = 0.5f * ( *pt1++ + *pt2++ ); */ - enr[i] = W_extract_h( W_mac_32_32( W_mult_32_32( *pt1, ONE_IN_Q30 ), *pt2, ONE_IN_Q30 ) ); // q_fr_bands+30+1-32+1 = q_fr_bands + enr64 = W_mac_32_32( W_mult_32_32( *pt1, ONE_IN_Q29 ), *pt2, ONE_IN_Q29 ); // q_fr_bands + 1 + Q29 + 1 (0.5 handle here) + shift = W_norm( enr64 ); + enr32[i] = W_extract_h( W_shl( enr64, shift ) ); move32(); + enr_q[i] = sub( add( q_fr_bands, shift ), 1 ); + move16(); pt1++; pt2++; } @@ -817,20 +828,66 @@ void noise_est_down_ivas_fx( /*-----------------------------------------------------------------* * Background noise energy update *-----------------------------------------------------------------*/ - FOR( i = 0; i < NB_BANDS; i++ ) { /* tmpN[i] = (1-ALPHA) * bckr[i] + ALPHA * enr[i]; */ /* handle div by zero in find_tilt_fx */ - tmpN[i] = L_max( Madd_32_16( Mpy_32_16_1( bckr[i], ALPHAM1_FX ), enr[i], ALPHA_FX ), e_min ); // q_fr_bands - move32(); - /* if( tmpN[i] < bckr[i] ) { bckr[i] = tmpN[i]; }*/ - /* Defend to increase noise estimate: keep as it is or decrease */ - bckr[i] = L_max( L_min( bckr[i], tmpN[i] ), e_min ); // q_fr_bands + tmpN64 = W_mult_32_16( bckr32[i], ALPHAM1_FX ); + tmp = W_mult_32_16( enr32[i], ALPHA_FX ); + + shift = s_min( bckr_q[i], enr_q[i] ); + tmpN64 = W_add( W_shl( tmpN64, sub( shift, bckr_q[i] ) ), W_shl( tmp, sub( shift, enr_q[i] ) ) ); // shift + q16 + shift1 = W_norm( tmpN64 ); + tmpN32[i] = W_extract_h( W_shl( tmpN64, shift1 ) ); // shift + q16 + shift1 - 32 move32(); + tmpN_q[i] = sub( add( add( Q16, shift ), shift1 ), 32 ); + move16(); + + IF( GT_32( E_MIN_FXQ31, L_shl_sat( tmpN32[i], sub( 31, tmpN_q[i] ) ) ) ) + { + tmpN32[i] = E_MIN_FXQ31; + tmpN_q[i] = 31; + move32(); + move16(); + } + + IF( GT_32( bckr32[i], L_shl_sat( tmpN32[i], sub( bckr_q[i], tmpN_q[i] ) ) ) ) + { + bckr32[i] = tmpN32[i]; /* Defend to increase noise estimate: keep as it is or decrease */ + bckr_q[i] = tmpN_q[i]; + move32(); + move16(); + } } + /* Scaling to common Q*/ + shift1 = bckr_q[0], shift2 = enr_q[0], shift3 = tmpN_q[0]; + move16(); + move16(); + move16(); + + FOR( i = 1; i < NB_BANDS; i++ ) + { + shift1 = s_min( shift1, bckr_q[i] ); + shift2 = s_min( shift2, enr_q[i] ); + shift3 = s_min( shift3, tmpN_q[i] ); + } + FOR( i = 0; i < NB_BANDS; i++ ) + { + bckr[i] = L_shl( bckr32[i], sub( shift1, bckr_q[i] ) ); + enr[i] = L_shl( enr32[i], sub( shift2, enr_q[i] ) ); + tmpN[i] = L_shl( tmpN32[i], sub( shift3, tmpN_q[i] ) ); + move32(); + move32(); + move32(); + } + *q_bckr = shift1; + *q_enr = shift2; + *q_tmpN = shift3; + move16(); + move16(); + move16(); /*------------------------------------------------------------------* * Energy variation update *------------------------------------------------------------------*/ @@ -923,9 +980,7 @@ void noise_est_fx( NOISE_EST_HANDLE hNoiseEst; SP_MUS_CLAS_HANDLE hSpMusClas; hSpMusClas = st_fx->hSpMusClas; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( ncharX ); -#endif /* Check if LR-VAD */ { diff --git a/lib_enc/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c index aa4763aa63e49e848b61f4c05ecaa63ceeb20dd0..dffab490016b224c5abeea742c81d24cf7d79e0b 100644 --- a/lib_enc/peak_vq_enc_fx.c +++ b/lib_enc/peak_vq_enc_fx.c @@ -559,13 +559,13 @@ Word16 peak_vq_enc_fx( move32(); nf_gains[i] = L_shr( acc, 1 + 2 ); /* nf_gains in Q12. dicn_fx is in Q14. Need extra shift +2. */ move32(); - push_indice_fx( hBstr, IND_HVQ_NF_GAIN, indx, 5 ); + push_indice( hBstr, IND_HVQ_NF_GAIN, indx, 5 ); bits = add( bits, 5 ); } /* Signal number of peaks */ i = sub( max_peaks, vq_peaks ); - push_indice_fx( hBstr, IND_NUM_PEAKS, i, 5 ); + push_indice( hBstr, IND_NUM_PEAKS, i, 5 ); bits = add( bits, 5 ); /* Identify position of first peak and arrange peak gains by position */ @@ -677,8 +677,8 @@ Word16 peak_vq_enc_fx( move16(); } - push_indice_fx( hBstr, IND_FLAGN, FlagN, 1 ); - push_indice_fx( hBstr, IND_PG_IDX, pgain_difidx[0], GAIN0_BITS ); + push_indice( hBstr, IND_FLAGN, FlagN, 1 ); + push_indice( hBstr, IND_PG_IDX, pgain_difidx[0], GAIN0_BITS ); IF( FlagN ) { @@ -692,7 +692,7 @@ Word16 peak_vq_enc_fx( r = pgain_huffsizn[j]; move16(); - push_indice_fx( hBstr, IND_PG_IDX, m, r ); + push_indice( hBstr, IND_PG_IDX, m, r ); } } ELSE @@ -700,7 +700,7 @@ Word16 peak_vq_enc_fx( pPgainDifIdx = &pgain_difidx[1]; FOR( i = 0; i < vqPeaksMinus1; i++ ) { - push_indice_fx( hBstr, IND_PG_IDX, ( *pPgainDifIdx++ ), GAINI_BITS ); + push_indice( hBstr, IND_PG_IDX, ( *pPgainDifIdx++ ), GAINI_BITS ); } } @@ -727,13 +727,13 @@ Word16 peak_vq_enc_fx( num_overlap_bins = sub( 5, sub( vq_peak_idx[i + 1], vq_peak_idx[i] ) ); indx = sub( vq_peak_idx[i], 2 ); quant_peaks_fx( hBstr, &coefs[indx], &coefs_out[indx], &peak_gains[i], &vq_cb_idx, num_overlap_bins, core_brate, vq_peaks ); - push_indice_fx( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 ); + push_indice( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 ); bits = add( bits, 9 ); } indx = sub( vq_peak_idx[i], 2 ); quant_peaks_fx( hBstr, &coefs[indx], &coefs_out[indx], &peak_gains[i], &vq_cb_idx, 0, core_brate, vq_peaks ); - push_indice_fx( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 ); + push_indice( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 ); bits = add( bits, 9 ); /* Quantize peak positions and sign with HVQ */ @@ -826,7 +826,7 @@ Word16 peak_vq_enc_fx( move16(); } - push_indice_fx( hBstr, IND_HVQ_PVQ_GAIN, pvq_norm[k], HVQ_PVQ_GAIN_BITS ); + push_indice( hBstr, IND_HVQ_PVQ_GAIN, pvq_norm[k], HVQ_PVQ_GAIN_BITS ); pvq_bits = add( pvq_bits, HVQ_PVQ_GAIN_BITS ); pvq_norm[k] = add( pvq_norm[k], 8 ); @@ -1148,7 +1148,7 @@ static void quant_peaks_fx( { *vq_idx = w_vquant_fx( x, Qx, weights, xq, hvq_peak_cb_fx, cbSize, 0 ); move16(); - push_indice_fx( hBstr, IND_HVQ_PEAKS, 0, 1 ); + push_indice( hBstr, IND_HVQ_PEAKS, 0, 1 ); } ELSE IF( EQ_16( cb_class, 1 ) ) { @@ -1157,7 +1157,7 @@ static void quant_peaks_fx( move16(); *vq_idx = add( *vq_idx, sub( HVQ_CB_SIZE / 2, search_overlap ) ); move16(); - push_indice_fx( hBstr, IND_HVQ_PEAKS, 0, 1 ); + push_indice( hBstr, IND_HVQ_PEAKS, 0, 1 ); } ELSE IF( EQ_16( cb_class, 2 ) ) { @@ -1166,13 +1166,13 @@ static void quant_peaks_fx( move16(); *vq_idx = add( *vq_idx, sub( HVQ_CB_SIZE / 2, search_overlap ) ); move16(); - push_indice_fx( hBstr, IND_HVQ_PEAKS, 1, 1 ); + push_indice( hBstr, IND_HVQ_PEAKS, 1, 1 ); } ELSE { *vq_idx = w_vquant_fx( x, Qx, weights, xq, hvq_peak_cb_fx, cbSize, 1 ); move16(); - push_indice_fx( hBstr, IND_HVQ_PEAKS, 1, 1 ); + push_indice( hBstr, IND_HVQ_PEAKS, 1, 1 ); } FOR( i = 0; i < 4; i++ ) @@ -1458,23 +1458,23 @@ static Word16 hvq_code_pos_fx( test(); IF( GT_16( delta_bits, sparse_bits ) || delta_bits < 0 ) { - push_indice_fx( hBstr, IND_POS_IDX, HVQ_CP_SPARSE, 1 ); + push_indice( hBstr, IND_POS_IDX, HVQ_CP_SPARSE, 1 ); FOR( i = 0; i < sparse_bits; i++ ) { - push_indice_fx( hBstr, IND_POS_IDX, sparse_result[i], 1 ); + push_indice( hBstr, IND_POS_IDX, sparse_result[i], 1 ); } bits = add( add( bits, sparse_bits ), 1 ); } ELSE { - push_indice_fx( hBstr, IND_POS_IDX, HVQ_CP_DELTA, 1 ); + push_indice( hBstr, IND_POS_IDX, HVQ_CP_DELTA, 1 ); FOR( i = 0; i < num_peaks; i++ ) { j = delta[i]; move16(); - push_indice_fx( hBstr, IND_POS_IDX, hvq_cp_huff_val[j], hvq_cp_huff_len[j] ); + push_indice( hBstr, IND_POS_IDX, hvq_cp_huff_val[j], hvq_cp_huff_len[j] ); } bits = add( add( bits, delta_bits ), 1 ); } @@ -1489,7 +1489,7 @@ static Word16 hvq_code_pos_fx( tmp = 0; move16(); } - push_indice_fx( hBstr, IND_POS_IDX, tmp, 1 ); + push_indice( hBstr, IND_POS_IDX, tmp, 1 ); } bits = add( bits, num_peaks ); diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index bcf7d33bb2431fb8cfb1709656b8080e40c4150a..8eea1b3d52b398655e3a8b03fc5a76262f006ed9 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -80,9 +80,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc Word16 pit_flag, delta, mult_Top, nBits; Word16 L_sufr_sft; Word16 T_op[2]; /* values for two half-frames */ -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) tdm_Pitch_reuse_flag; -#endif L_sufr_sft = 6; move16(); @@ -1789,7 +1787,7 @@ void pit_Q_enc_fx( } { - push_indice_fx( hBstr, IND_PITCH, pitch_index, nBits ); + push_indice( hBstr, IND_PITCH, pitch_index, nBits ); } return; @@ -1921,7 +1919,7 @@ void pit16k_Q_enc_fx( } } - push_indice_fx( hBstr, IND_PITCH, pitch_index, nBits ); + push_indice( hBstr, IND_PITCH, pitch_index, nBits ); } ELSE IF( EQ_16( nBits, 9 ) ) /* absolute encoding with 9 bits */ { @@ -1951,14 +1949,14 @@ void pit16k_Q_enc_fx( } } - push_indice_fx( hBstr, IND_PITCH, pitch_index, 9 ); + push_indice( hBstr, IND_PITCH, pitch_index, 9 ); } ELSE /* nBits == 6 */ /* relative encoding with 6 bits */ { /*pitch_index = (T0 - *T0_min) * 4 + T0_frac;*/ pitch_index = add( shl( sub( T0, *T0_min ), 2 ), T0_frac ); - push_indice_fx( hBstr, IND_PITCH, pitch_index, nBits ); + push_indice( hBstr, IND_PITCH, pitch_index, nBits ); } limit_T0_fx( L_FRAME16k, 8, L_SUBFR, limit_flag, T0, T0_frac, T0_min, T0_max ); diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index 9afb27065559b4746745352c09b11dace1f3ed88..d6dc8b6d68adcec9c2466e1069b658ce85791c7e 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -171,9 +171,9 @@ ivas_error ppp_quarter_encoder_fx( CURRCW_Q_FX->upper_cut_off_freq_of_interest_fx = (Word16) find_remd( Ltempn, 20971, &Ltempd ); move16(); - push_indice_fx( hBstr, IND_AMP0, AMP_IDX_fx[0], 6 ); - push_indice_fx( hBstr, IND_AMP1, AMP_IDX_fx[1], 6 ); - push_indice_fx( hBstr, IND_POWER, POWER_IDX_FX, 6 ); + push_indice( hBstr, IND_AMP0, AMP_IDX_fx[0], 6 ); + push_indice( hBstr, IND_AMP1, AMP_IDX_fx[1], 6 ); + push_indice( hBstr, IND_POWER, POWER_IDX_FX, 6 ); /*Phase copying is done through copy_phase instead of car2pol and pol2car */ copy_phase_fx( TARGETCW_FX, *CURRCW_Q_FX, TARGETCW_FX ); @@ -199,7 +199,7 @@ ivas_error ppp_quarter_encoder_fx( /*DTFS_phaseShift( CURRCW_Q,(float)(PI2*tmp/CURRCW_Q->lag) ); */ Q2phaseShift_fx( CURRCW_Q_FX, tmp_fx, CURRCW_Q_FX->lag_fx, S_fx, C_fx ); - push_indice_fx( hBstr, IND_GLOBAL_ALIGNMENT, shr( add( tmp_fx, 12 ), 2 ), 3 ); + push_indice( hBstr, IND_GLOBAL_ALIGNMENT, shr( add( tmp_fx, 12 ), 2 ), 3 ); free( PREVDTFS_FX ); return error; @@ -830,7 +830,7 @@ static void LPCPowSpect_fx( Lacc = L_add( Lacc, L_shr( L_mult( dh, dh ), 1 ) ); /* Lacc=Re^2+Im^2, Q22 */ exp = norm_l( Lacc ); - tmp = round_fx( L_shl( Lacc, exp ) ); + tmp = round_fx_sat( L_shl( Lacc, exp ) ); exp = sub( sub( 30, exp ), 22 ); /* tmp may potentially become negative, when Lacc is a very large value */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 6844945c02ec3ae13ff255a68e215ba0ef0cfa5d..cbb2cf421564b73d0e51c62baef7b4988667fe3e 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -298,7 +298,7 @@ void pre_proc_fx( move16(); } - bw_detect_fx( st, signal_in, NULL, enerBuffer, sf_energySum, MONO_FORMAT, 0 ); + bw_detect_fx( st, signal_in, NULL, enerBuffer, sf_energySum, MONO_FORMAT, 0, 0 ); /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation @@ -1104,11 +1104,7 @@ void pre_proc_fx( test(); test(); test(); -#ifndef CR_2109_to_2112_cd0_ce0 - IF( ( ( ( st->tcxonly == 0 ) || !( st->core_brate != FRAME_NO_DATA || NE_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->codec_mode, MODE2 ) ) || ( EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->codec_mode, MODE1 ) ) ) -#else IF( ( ( ( st->tcxonly == 0 ) || !( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->codec_mode, MODE2 ) ) || ( EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->codec_mode, MODE1 ) ) ) -#endif { /* update signal buffers */ Copy( new_inp_resamp16k, st->buf_speech_enc + L_FRAME16k, L_FRAME16k ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 042b5af903a5232182b25de39971113d21f37e61..d6532b207ae1558aa79c20ed75f88e56466df7d5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -138,13 +138,13 @@ void AVQ_encmux_ivas_fx( void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ - const Word16 signal_in[], /* i : i signal */ - Word16 *spectrum, /* i : MDCT spectrum */ - const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ - const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 mct_on /* i : flag MCT mode */ -); + const Word16 signal_in[], /* i : input signal */ + Word16 *spectrum, /* i : MDCT spectrum Q_spec */ + const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ + const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 mct_on, /* i : flag MCT mode */ + const Word16 Q_spec ); void core_switching_post_enc_fx( /*done */ Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -177,14 +177,12 @@ void dtx_fx( ); void dtx_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ -#ifdef NONBE_1211_DTX_BR_SWITCHING + Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ -#endif - const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ - const Word16 vad, /* i : vad flag for DTX Q0*/ - const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word16 vad, /* i : vad flag for DTX Q0*/ + const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ + Word16 Q_speech /* i : Q factor for speech */ ); Word16 dtx_hangover_addition_fx( @@ -357,14 +355,17 @@ void noise_est_down_ivas_fx( const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) */ const Word16 q_fr_bands, /* i : Q of fr_bands */ Word32 bckr[], /* i/o: per band background noise energy estimate */ - Word32 tmpN[], /* o : temporary noise update */ - Word32 enr[], /* o : averaged energy over both subframes */ - const Word16 min_band, /* i : minimum critical band */ - const Word16 max_band, /* i : maximum critical band */ - Word16 *totalNoise, /* o : noise estimate over all critical bands */ - Word16 Etot, /* i : Energy of current frame */ - Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ - Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */ + Word16 *q_bckr, + Word32 tmpN[], /* o : temporary noise update */ + Word16 *q_tmpN, + Word32 enr[], /* o : averaged energy over both subframes */ + Word16 *q_enr, + const Word16 min_band, /* i : minimum critical band */ + const Word16 max_band, /* i : maximum critical band */ + Word16 *totalNoise, /* o : noise estimate over all critical bands */ + Word16 Etot, /* i : Energy of current frame */ + Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ + Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */ ); void noise_est_fx( @@ -1234,10 +1235,8 @@ void AVQ_cod_lpc_fx( ); void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ -#ifdef MSAN_FIX - Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ -#endif + Encoder_State *st, /* i : Encoder state */ + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ Word32 *pMDCTSpectrum, /* i : MDCT spectrum */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ Word16 *q_spectrum, /* i/o: Q of spectrum */ @@ -1282,7 +1281,8 @@ void AnalyzePowerSpectrum_ivas_fx( Word32 const mdctSpectrum[], /* i : MDCT spectrum */ Word16 mdctSpectrum_e, Word16 const signal[], /* i : windowed signal corresponding to mdctSpectrum */ - Word32 powerSpec[], /* o : Power spectrum. Can point to signal */ + const Word16 q_signal, + Word32 powerSpec[], /* o : Power spectrum. Can point to signal */ Word16 powerSpec_e[] ); void AdaptLowFreqEmph_fx( Word32 x[], @@ -1498,6 +1498,14 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, Word8 *noiseFlags, Word16 lowpassLine ); +void ComputeSpectrumNoiseMeasure_ivas_fx( Word64 *powerSpec, /* Qx */ + Word16 L_frame, /* Q0 */ + Word16 startLine, /* Q0 */ + Word8 resetMemory, /* Q0 */ + Word8 *noiseFlags, /* Q0 */ + Word16 lowpassLine /* Q0 */ +); + void lpc_quantization_fx( Encoder_State *st, const Word16 lsp[], /* Q15 */ @@ -1553,9 +1561,7 @@ void Mode2_pit_encode_fx( Word16 pit_res_max ); void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); -#ifdef FIX_ISSUE_1165 void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); -#endif void E_ACELP_4t_fx( Word16 dn[], /* Qdn */ @@ -2326,6 +2332,21 @@ void find_targets_ivas_fx( Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/ ); +void find_targets_ivas_new_fx( + const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/ + const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/ + const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/ + const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/ + Word16 tilt_fac, /* i : tilt factor Q15*/ + Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/ + Word16 *cn, /* o : target vector in residual domain Q_new*/ + Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/ +); + void E_ACELP_adaptive_codebook( Word16 *exc, /* i : pointer to the excitation frame Q_new */ Word16 T0, /* i : integer pitch lag Q0 */ @@ -3073,10 +3094,8 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | Word16 last_core_acelp /**< in: Q0 | indictaor if last frame was acelp coded */ ); -void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ -#ifdef MSAN_FIX - Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ -#endif +void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ Word16 e_mdct, /* i : exponent of pMDCTspectrum */ diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index 214522126120348426c0f9a7d5bc2569f584a903..e2d5fb264df53fc69c0fed15ffac3d9a28f98984 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -553,10 +553,10 @@ Word16 pvq_core_enc_ivas_fx( ivas_fine_gain_pred_fx( sfm_start, sfm_end, sfmsize, ord, npulses, maxpulse, R, nb_sfm, coefs_quant, pulse_vector, fg_pred, core ); - fine_gain_quant_ivas_fx( hBstr, ord, nb_sfm, gain_bits_array, fg_pred, gopt ); + fine_gain_quant_fx( hBstr, ord, nb_sfm, gain_bits_array, fg_pred, gopt ); apply_gain_fx( ord, sfm_start, sfm_end, nb_sfm, fg_pred, coefs_quant ); - *Q_coefs = 11; + *Q_coefs = 12; move16(); return add( pvq_bits, gain_bits_tot ); } diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c index 13e0a3cf7e196cb86b31882c04a719a52bd8d1f0..288612e43c16582526989a2cc89db455fa19aed6 100644 --- a/lib_enc/qlpc_avq_fx.c +++ b/lib_enc/qlpc_avq_fx.c @@ -143,12 +143,12 @@ static Word16 unary_code( FOR( ; ind > 0; ind-- ) { - push_next_indice_fx( hBstr, 1, 1 ); + push_next_indice( hBstr, 1, 1 ); nb_bits = add( nb_bits, 1 ); // Q0 } /* Stop bit */ - push_next_indice_fx( hBstr, 0, 1 ); + push_next_indice( hBstr, 0, 1 ); return ( nb_bits ); } @@ -195,7 +195,7 @@ static Word16 unpack4bits( IF( nbits == 0 ) { - push_next_indice_fx( hBstr, 0, 0 ); + push_next_indice( hBstr, 0, 0 ); i = 1; move16(); } @@ -206,10 +206,10 @@ static Word16 unpack4bits( FOR( ; nbits > 4; nbits -= 4 ) { - push_next_indice_fx( hBstr, prm[i], 4 ); + push_next_indice( hBstr, prm[i], 4 ); i = add( i, 1 ); } - push_next_indice_fx( hBstr, prm[i], nbits ); + push_next_indice( hBstr, prm[i], nbits ); i = add( i, 1 ); } @@ -330,7 +330,7 @@ Word16 encode_lpc_avq_fx( { nb = 1; move16(); - push_next_indice_fx( hBstr, q_type, nb ); + push_next_indice( hBstr, q_type, nb ); } nb_bits = add( nb_bits, nb ); // Q0 @@ -342,7 +342,7 @@ Word16 encode_lpc_avq_fx( IF( ( ( q_type == 0 ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) || ( ( q_type == 0 ) && ( GE_16( st1, 0 ) ) && EQ_16( element_mode, IVAS_CPE_MDCT ) ) ) { /* Absolute quantizer with 1st stage stochastic codebook */ - push_next_indice_fx( hBstr, st1, bits_for_abs_quant ); + push_next_indice( hBstr, st1, bits_for_abs_quant ); nb_bits = add( nb_bits, bits_for_abs_quant ); // Q0 } @@ -350,7 +350,7 @@ Word16 encode_lpc_avq_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && EQ_16( stereo_mode, 3 ) && st1 < 0 ) { - push_next_indice_fx( hBstr, add( st1, 2 ), 1 ); + push_next_indice( hBstr, add( st1, 2 ), 1 ); nb_bits = add( nb_bits, 1 ); // Q0 } @@ -368,7 +368,7 @@ Word16 encode_lpc_avq_fx( move16(); i = 3; } - push_next_indice_fx( hBstr, i, 2 ); + push_next_indice( hBstr, i, 2 ); i = sub( qn2, 2 ); @@ -377,7 +377,7 @@ Word16 encode_lpc_avq_fx( move16(); i = 3; } - push_next_indice_fx( hBstr, i, 2 ); + push_next_indice( hBstr, i, 2 ); /* Unary code for abs and rel LPC0/LPC2 */ /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */ diff --git a/lib_enc/range_enc_fx.c b/lib_enc/range_enc_fx.c index 689b313d8f2da140d0419f59704d676dfa48621b..767b2ecb5a98bc692e6a0bbcecf7e9ba3213e7b9 100644 --- a/lib_enc/range_enc_fx.c +++ b/lib_enc/range_enc_fx.c @@ -423,14 +423,14 @@ void rc_enc_bits_fx( IF( GT_16( bits, 16 ) ) { - push_indice_fx( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_lshr( value, 16 ) ), sub( bits, 16 ) ); + push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_lshr( value, 16 ) ), sub( bits, 16 ) ); hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0 - push_indice_fx( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_and( value, 0x0000ffff ) ), 16 ); + push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_and( value, 0x0000ffff ) ), 16 ); hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0 } ELSE { - push_indice_fx( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( value ), bits ); + push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( value ), bits ); hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0 } } @@ -516,7 +516,7 @@ static void rc_enc_write_fx( Word16 bits /* i : Number of bits Q0*/ ) { - push_indice_fx( hBstr, IND_RC_START, byte, bits ); + push_indice( hBstr, IND_RC_START, byte, bits ); return; } diff --git a/lib_enc/spec_flatness_fx.c b/lib_enc/spec_flatness_fx.c index c2451886dac977208e677dc5ca833459b53afa5e..d7bd9a6e9f2da301d4b1ffbb3c19e4c3b1248e9a 100644 --- a/lib_enc/spec_flatness_fx.c +++ b/lib_enc/spec_flatness_fx.c @@ -221,11 +221,7 @@ void spec_flatness_fx( SFM_Qtmp = sub( SFM_Qtmp, SPEC_AMP_Q ); SFM_Qtmp = sub( SFM_Qtmp, SFM_Q ); -#ifdef FIX_ISSUE_1209 sSFM[1] = add_sat( mult( sSFM[1], 0x6ccc ), shr( mult( SFM, 0x1333 ), SFM_Qtmp ) ); -#else - sSFM[1] = add( mult( sSFM[1], 0x6ccc ), shr( mult( SFM, 0x1333 ), SFM_Qtmp ) ); -#endif move16(); /*sSFM3*/ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index e04f5172b54a7022360d2afada7514b3e9e49624..3f6449a0c833664e90dec64c1e959ea729483a92 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -856,16 +856,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { /*mx = PS_norm[i] > st->past_PS[i] ? PS_norm[i] : st->past_PS[i];*/ - IF( GT_32( PS_norm[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] ) ) - { - mx = PS_norm[i]; - move16(); /*Q25 */ - } - ELSE - { - mx = hSpMusClas->past_PS_fx[i - LOWEST_FBIN]; - move16(); /*Q25 */ - } + mx = L_max( PS_norm[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] ); /*Q25 */ /*ps_sta += mx / (dPS[i] + 1e-5f);*/ IF( !dPS[i] ) @@ -890,20 +881,12 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis tmp = div_s( tmp2, tmp1 ); /*Q(15+exp3) */ L_tmp = L_shl( tmp, sub( 1, exp3 ) ); /*Q16 */ -#ifdef FIX_ISSUE_1151 - ps_sta = L_add_sat( ps_sta, L_tmp ); /*Q16 */ -#else - ps_sta = L_add( ps_sta, L_tmp ); /*Q16 */ -#endif + ps_sta = L_add_sat( ps_sta, L_tmp ); /*Q16 */ } } /**pFV++ = (float)log(ps_sta + 1e-5f);*/ -#ifdef FIX_ISSUE_1151 ps_sta = L_add_sat( ps_sta, 336 ); -#else - ps_sta = L_add( ps_sta, 336 ); -#endif e_tmp = norm_l( ps_sta ); f_tmp = Log2_norm_lc( L_shl( ps_sta, e_tmp ) ); e_tmp = sub( 30 - 16, e_tmp ); @@ -1617,17 +1600,9 @@ Word16 ivas_smc_gmm_fx( Word16 flag_odv; Word32 lps_fx, lpm_fx, lpn_fx; Word32 ps_fx[N_SMC_MIXTURES], pm_fx[N_SMC_MIXTURES], pn_fx[N_SMC_MIXTURES]; -#ifndef DOT_PROD_CHOLESKY_64BIT - Word32 lprob_fx; - Word16 lprob_exp = 0; -#else Word64 wprob_fx; -#endif Word32 fvm_fx[N_PCA_COEF]; -#ifndef DOT_PROD_CHOLESKY_64BIT - Word16 fvm_exp = 0; -#endif - Word32 sum_PS_fx, ps_diff_fx, ps_sta_fx; + Word32 sum_PS_fx, ps_diff_fx; Word32 dlp_fx, wrelE_fx, wdrop_fx, wght_fx; Word32 wrise_fx; Word16 dlp_mean2var_fx; @@ -2005,27 +1980,21 @@ Word16 ivas_smc_gmm_fx( move32(); /* [14] ps_sta (spectral stationarity) */ - ps_sta_fx = 0; + Word32 ps_sta_fx = 0; move32(); Word16 ps_sta_exp = 0; move16(); + Word32 avoid_divide_by_zero; + avoid_divide_by_zero = L_shr( 21475, sub( 31, Qfact_PS_past ) ); // 21475 = 1e-5 in Q31 + FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { - IF( GT_32( PS_norm_fx[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] ) ) - { - temp32 = BASOP_Util_Divide3232_Scale_cadence( PS_norm_fx[i], ( L_add( dPS_fx[i], L_shr( 21475, sub( 31, Qfact_PS_past ) ) ) ), &temp_exp ); // 31-temp_exp - move32(); - ps_sta_fx = BASOP_Util_Add_Mant32Exp( temp32, temp_exp, ps_sta_fx, ps_sta_exp, &ps_sta_exp ); - move32(); - } - ELSE - { - // ps_sta += hSpMusClas->past_PS[i - LOWEST_FBIN] / ( dPS[i] + 1e-5f ); - temp32 = BASOP_Util_Divide3232_Scale_cadence( hSpMusClas->past_PS_fx[i - LOWEST_FBIN], ( L_add( dPS_fx[i], L_shr( 21475, sub( 31, Qfact_PS_past ) ) ) ), &temp_exp ); // 31-temp_exp - ps_sta_fx = BASOP_Util_Add_Mant32Exp( temp32, temp_exp, ps_sta_fx, ps_sta_exp, &ps_sta_exp ); - } + Word32 tmp_max; + tmp_max = L_max( PS_norm_fx[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] ); + + temp32 = BASOP_Util_Divide3232_Scale_cadence( tmp_max, L_add( dPS_fx[i], avoid_divide_by_zero ), &temp_exp ); // 31-temp_exp + ps_sta_fx = BASOP_Util_Add_Mant32Exp( temp32, temp_exp, ps_sta_fx, ps_sta_exp, &ps_sta_exp ); } - // temp32_log = L_add( BASOP_Util_Log2( L_add( ps_sta_fx, L_shr( 21475, ps_sta_exp ) ) ), L_shl( ps_sta_exp, Q25 ) ); temp32_log = L_add( BASOP_Util_Log2( L_add_sat( ps_sta_fx, L_shr( 21475, ps_sta_exp ) ) ), L_shl( ps_sta_exp, Q25 ) ); temp32_log = Mpy_32_32( temp32_log, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/ *pFV_fx++ = L_shr( temp32_log, Q5 ); // logf( ps_sta + 1e-5f ); @@ -2213,38 +2182,16 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); -#ifndef DOT_PROD_CHOLESKY_64BIT - fvm_exp = sub( 31, Qfact_FV ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 -#else wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 -#endif move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); -#ifndef DOT_PROD_CHOLESKY_64BIT - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 -#else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 -#endif + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); -#ifndef DOT_PROD_CHOLESKY_64BIT - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 -#else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 -#endif + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } @@ -2258,21 +2205,12 @@ Word16 ivas_smc_gmm_fx( *high_lpn_flag = 1; move32(); } -#ifndef FIX_1297_OVERFLOW - hSpMusClas->lpm_fx = extract_l( L_shr( lpm_fx, 11 ) ); // Q7 - move16(); - hSpMusClas->lps_fx = extract_l( L_shr( lps_fx, 11 ) ); // Q7 - move16(); - hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 11 ) ); // Q7 - move16(); -#else - hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 + hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 move16(); hSpMusClas->lps_fx = extract_h( L_shl_sat( lps_fx, 16 - 11 ) ); // Q7 move16(); hSpMusClas->lpn_fx = extract_h( L_shl_sat( lpn_fx, 16 - 11 ) ); // Q7 move16(); -#endif /* determine HQ Generic speech class */ IF( st->hHQ_core != NULL ) { @@ -2995,11 +2933,11 @@ void ivas_smc_mode_selection_fx( ton = tonal_det_fx( S_map, st->vad_flag, hSpMusClas->tod_S_map_lt_fx, &hSpMusClas->tod_thr_lt_fx, &hSpMusClas->tod_weight_fx, &hSpMusClas->tod_S_mass_prev_fx, &hSpMusClas->tod_S_mass_lt_fx ); // Q22 /* calculate spectral peak-to-average ratio */ - Word16 shift = sub( add( Q_new, Q_SCALE - 2 ), st->hSpMusClas->Q_tod_lt_Bin_E ); + Word16 shift = sub( st->q_Bin_E, st->hSpMusClas->Q_tod_lt_Bin_E ); FOR( i = 0; i < TOD_NSPEC; i++ ) { // st->hSpMusClas->tod_lt_Bin_E[i] = P2A_FACT * st->hSpMusClas->tod_lt_Bin_E[i] + ( 1 - P2A_FACT ) * st->Bin_E[i]; - st->hSpMusClas->tod_lt_Bin_E_fx[i] = Madd_32_16( L_shl( Mpy_32_16_1( st->hSpMusClas->tod_lt_Bin_E_fx[i], P2A_FACT_FX_Q15 ), shift ), st->Bin_E_fx[i], ( 32767 - P2A_FACT_FX_Q15 ) ); // Q = Q_new + Q_SCALE - 2 + st->hSpMusClas->tod_lt_Bin_E_fx[i] = Madd_32_16( L_shl( Mpy_32_16_1( st->hSpMusClas->tod_lt_Bin_E_fx[i], P2A_FACT_FX_Q15 ), shift ), st->Bin_E_fx[i], ( 32767 - P2A_FACT_FX_Q15 ) ); // Q = st->q_Bin_E + Q_SCALE - 2 move32(); } st->hSpMusClas->Q_tod_lt_Bin_E = add( st->hSpMusClas->Q_tod_lt_Bin_E, shift ); @@ -3016,11 +2954,11 @@ void ivas_smc_mode_selection_fx( IF( LE_32( element_brate, IVAS_16k4 ) ) { - thr_sp2a = L_shl( THR_P2A_HIGH_FX, add( Q_new, Q_SCALE - 2 ) ); // Q = Q_new + Q_SCALE - 2 + thr_sp2a = L_shl( THR_P2A_HIGH_FX, st->q_Bin_E ); // Q = st->q_Bin_E } ELSE { - thr_sp2a = L_shl( THR_P2A_FX, add( Q_new, Q_SCALE - 2 ) ); // Q = Q_new + Q_SCALE - 2 + thr_sp2a = L_shl( THR_P2A_FX, st->q_Bin_E ); // Q = st->q_Bin_E } /* initial 3-way selection of coding modes (ACELP/GSC/TCX) */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 7ca996af53c7db6dd4a011f7a13181b070cd564f..c6176709b2f4733d215c207e15f0a3b502358d4b 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -92,9 +92,10 @@ typedef struct bitstream_enc_data_structure void *st_ivas; /* IVAS encoder structure */ // Word16 nb_bits_tot_fx; /* total number of bits already written */ // Indice *ind_list_fx; /* list of indices */ +#ifndef HARM_PUSH_BIT Word16 next_ind_fx; /* pointer to the next empty slot in the list of indices */ Word16 last_ind_fx; /* last written indice */ - +#endif } BSTR_ENC_DATA, *BSTR_ENC_HANDLE; /*----------------------------------------------------------------------------------* @@ -701,9 +702,6 @@ typedef struct sp_mus_clas_structure typedef struct lpd_state_structure { -#ifndef MSAN_FIX - Word16 nbits; /* number of bits used by ACELP or TCX */ -#endif /* signal memory */ Word16 syn[1 + M]; /* Synthesis memory (non-pe) */ @@ -1012,9 +1010,7 @@ typedef struct td_bwe_enc_structure typedef struct fd_bwe_enc_structure { Word16 new_input_hp_fx[NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS )]; // Q_new_input_hp -#ifdef FIX_ISSUE_1230 Word16 Q_new_input_hp; -#endif Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS )]; // q0 Word16 old_input_wb_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )]; /* Q(-1) */ Word16 old_input_lp_fx[NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS )]; // st->hBWE_FD->prev_Q_input_lp @@ -1215,6 +1211,7 @@ typedef struct tcx_enc_structure Word32 spectrum_long_fx[N_MAX]; /* MDCT output for a long block. Points to spectrum */ Word16 spectrum_long_e; /* MDCT output for a long block. Points to spectrum */ Word16 q_spectrum_long_fx; + Word16 spectrum_length; /* corresponds to L_frameTCX, used for scaling of MDCT/MDST buffers */ } TCX_ENC_DATA, *TCX_ENC_HANDLE; typedef struct TransientDetection diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 0a20db8edddf25e93b17485f43ff53037422e996..1445559a19b6d347f2d611d30167244ad4d0969f 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -94,7 +94,7 @@ void stat_noise_uv_enc_fx( noisiness = s_max( noisiness, 0 ); noisiness = s_min( noisiness, 31 ); - push_indice_fx( st_fx->hBstr, IND_NOISINESS, noisiness, 5 ); + push_indice( st_fx->hBstr, IND_NOISINESS, noisiness, 5 ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index e0d84645895236cce9f93b1eaa9062c56a794ec2..1ebef740457eef7370a81d919388c7d080210f3f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -186,7 +186,7 @@ void wb_bwe_enc_fx( Q_synth = sub( add( sub( new_input_fx_exp, 16 ), scl ), 1 ); mode = WB_BWE_encoding_fx( coder_type, yorig_fx, WB_fenv_fx, st_fx, Q_synth, Q_synth ); - push_indice_fx( st_fx->hBstr, IND_WB_CLASS, sub( mode, 2 ), 1 ); + push_indice( st_fx->hBstr, IND_WB_CLASS, sub( mode, 2 ), 1 ); } hBWE_FD->prev_mode = mode; @@ -307,9 +307,7 @@ void swb_bwe_enc_ivas_fx( move32(); #endif Word16 fb_band_begin; -#ifdef FIX_ISSUE_1230 Word16 q_new_input_hp; -#endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -385,7 +383,6 @@ void swb_bwe_enc_ivas_fx( Copy( old_input_16k_fx + L_INP_MEM + L_FRAME16k - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); } -#ifdef FIX_ISSUE_1230 q_new_input_hp = s_min( Q_shb_speech, hBWE_FD->Q_new_input_hp ); IF( LT_16( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ) { @@ -400,10 +397,6 @@ void swb_bwe_enc_ivas_fx( hBWE_FD->Q_new_input_hp = Q_shb_speech; move16(); -#else - Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); - Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); -#endif Copy( shb_speech_fx + L_FRAME16k - Sample_Delay_HP, hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); new_input_fx = old_input_fx + Sample_Delay_SWB_BWE; Copy( hBWE_FD->old_input_fx, old_input_fx, Sample_Delay_SWB_BWE ); @@ -513,11 +506,7 @@ void swb_bwe_enc_ivas_fx( { Q_shb = sub( Q_synth_hf, 4 ); } -#ifdef FIX_ISSUE_1230 Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, q_new_input_hp ) ); -#else - Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, Q_shb_speech ) ); -#endif /* FB BWE encoding */ IF( EQ_16( st_fx->extl, FB_BWE ) ) @@ -831,7 +820,7 @@ void swb_bwe_enc_fx( /* write FB BWE frame gain to the bitstream */ IF( EQ_16( st_fx->extl, FB_BWE ) ) { - push_indice_fx( st_fx->hBstr, IND_FB_SLOPE, idxGain, NUM_BITS_FB_FRAMEGAIN ); + push_indice( st_fx->hBstr, IND_FB_SLOPE, idxGain, NUM_BITS_FB_FRAMEGAIN ); } return; @@ -2487,7 +2476,7 @@ Word16 WB_BWE_encoding_fx( /* o : classification of wb index = WB_BWE_fenv_q_fx( WB_fenv_fx, F_2_5_fx, 32, 2 ); - push_indice_fx( st_fx->hBstr, IND_WB_FENV, index, 5 ); + push_indice( st_fx->hBstr, IND_WB_FENV, index, 5 ); return ( mode ); } @@ -2676,7 +2665,7 @@ static Word16 SWB_BWE_encoding_fx( { mode = IsTransient; move16(); - push_indice_fx( hBstr, IND_SWB_CLASS, mode, 2 ); + push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); /* Energy for the different bands and global energies */ global_gain_fx = L_deposit_l( 0 ); @@ -2935,13 +2924,13 @@ static Word16 SWB_BWE_encoding_fx( index = shr( add( SWB_tenv_tmp_fx[n_band], 1024 ), 11 ); } - push_indice_fx( hBstr, IND_SWB_TENV, index, 4 ); + push_indice( hBstr, IND_SWB_TENV, index, 4 ); } MSVQ_Interpol_Tran_fx( SWB_fenv_fx, indice ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[0], 7 ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[1], 6 ); + push_indice( hBstr, IND_SWB_FENV, indice[0], 7 ); + push_indice( hBstr, IND_SWB_FENV, indice[1], 6 ); } ELSE { @@ -2966,7 +2955,7 @@ static Word16 SWB_BWE_encoding_fx( global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ mode = FD_BWE_class_fx( yos_fx, global_gain_fx, tilt_nb_fx, Q_synth, Q_shb, st_fx ); - push_indice_fx( hBstr, IND_SWB_CLASS, mode, 2 ); + push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx, st_offset, energy_factor_fx, Q_synth_lf ); @@ -3001,11 +2990,11 @@ static Word16 SWB_BWE_encoding_fx( /* Energy VQ */ msvq_interpol_fx( SWB_fenv_fx, w_env_fx, indice ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[0], 5 ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[1], 7 ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[2], 6 ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[3], 5 ); - push_indice_fx( hBstr, IND_SWB_FENV, indice[4], 6 ); + push_indice( hBstr, IND_SWB_FENV, indice[0], 5 ); + push_indice( hBstr, IND_SWB_FENV, indice[1], 7 ); + push_indice( hBstr, IND_SWB_FENV, indice[2], 6 ); + push_indice( hBstr, IND_SWB_FENV, indice[3], 5 ); + push_indice( hBstr, IND_SWB_FENV, indice[4], 6 ); } hBWE_FD->prev_mode = mode; move16(); @@ -3229,11 +3218,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); expd = norm_l( WB_tenv_syn_fx ); -#ifdef FIX_ISSUE_1156 den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); -#else - den = round_fx( L_shl( WB_tenv_syn_fx, expd ) ); -#endif expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); @@ -3954,7 +3939,7 @@ void hq_generic_encoding_fx( IF( EQ_16( hHQ_core->hq_generic_speech_class, 1 ) ) { - push_indice_fx( hBstr, IND_HQ_SWB_EXC_SP_CLAS, 1, 1 ); + push_indice( hBstr, IND_HQ_SWB_EXC_SP_CLAS, 1, 1 ); *hq_generic_exc_clas = HQ_GENERIC_SP_EXC; move16(); } @@ -3962,8 +3947,8 @@ void hq_generic_encoding_fx( { *hq_generic_exc_clas = decision_hq_generic_class_fx_32( coefs_fx, hq_generic_offset ); move16(); - push_indice_fx( hBstr, IND_HQ_SWB_EXC_SP_CLAS, 0, 1 ); - push_indice_fx( hBstr, IND_HQ_SWB_EXC_CLAS, *hq_generic_exc_clas, 1 ); + push_indice( hBstr, IND_HQ_SWB_EXC_SP_CLAS, 0, 1 ); + push_indice( hBstr, IND_HQ_SWB_EXC_CLAS, *hq_generic_exc_clas, 1 ); } FOR( n_band = 0; n_band < nenv; n_band++ ) @@ -4084,23 +4069,23 @@ void hq_generic_encoding_fx( move16(); } - push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[0], 5 ); - push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[1], 7 ); - push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[2], 6 ); - push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[3], 5 ); + push_indice( hBstr, IND_SWB_FENV_HQ, indice[0], 5 ); + push_indice( hBstr, IND_SWB_FENV_HQ, indice[1], 7 ); + push_indice( hBstr, IND_SWB_FENV_HQ, indice[2], 6 ); + push_indice( hBstr, IND_SWB_FENV_HQ, indice[3], 5 ); IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) ) { - push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[4], 6 ); + push_indice( hBstr, IND_SWB_FENV_HQ, indice[4], 6 ); } ELSE { - push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[4], 5 ); + push_indice( hBstr, IND_SWB_FENV_HQ, indice[4], 5 ); } IF( EQ_16( st_fx->bwidth, FB ) ) { - push_indice_fx( hBstr, IND_FB_FENV_HQ, indice[5], 5 ); + push_indice( hBstr, IND_FB_FENV_HQ, indice[5], 5 ); } FOR( n_band = 0; n_band < nenv; n_band++ ) @@ -4145,17 +4130,11 @@ void fd_bwe_enc_init_fx( ) { set16_fx( hBWE_FD->new_input_hp_fx, 0, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ) ); -#ifdef FIX_ISSUE_1230 hBWE_FD->Q_new_input_hp = 0; move16(); -#endif set16_fx( hBWE_FD->old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) ); set16_fx( hBWE_FD->old_input_wb_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ) ); -#ifndef MSAN_FIX - set16_fx( hBWE_FD->old_input_lp_fx, 0, NS2SA( 16000, ACELP_LOOK_NS + DELAY_SWB_TBE_16k_NS ) ); -#else set16_fx( hBWE_FD->old_input_lp_fx, 0, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ) ); -#endif set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); hBWE_FD->prev_mode = NORMAL; move16(); diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index fd4a9f1259669e751e5164a7814c623739939c11..8b5a173533d53746f84d83b62e6844e0a290ae22 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -189,7 +189,7 @@ void swb_bwe_enc_hr_fx( st_fx->EnergyLT_fx_exp = exp1; move16(); - push_indice_fx( hBstr, IND_HR_IS_TRANSIENT, is_transient, 1 ); + push_indice( hBstr, IND_HR_IS_TRANSIENT, is_transient, 1 ); /*---------------------------------------------------------------------* * OLA and MDCT @@ -309,7 +309,7 @@ void swb_bwe_enc_hr_fx( ind1 = gain_quant_fx( &L_gain_fx, &gain1_fx, LG10_MIN_GLOB_GAIN_BWE_HR_Q14, LG10_MAX_GLOB_GAIN_BWE_HR_Q13, NBITS_GLOB_GAIN_BWE_HR, &exp1 ); - push_indice_fx( hBstr, IND_HR_GAIN, ind1, NBITS_GLOB_GAIN_BWE_HR ); + push_indice( hBstr, IND_HR_GAIN, ind1, NBITS_GLOB_GAIN_BWE_HR ); nBits = sub( nBits, NBITS_GLOB_GAIN_BWE_HR ); /* normalization with global gain */ @@ -353,7 +353,7 @@ void swb_bwe_enc_hr_fx( { ind1 = en_band_quant_fx( en_band_fx, swb_hr_env_code3_fx, NUM_ENVLOPE_CODE_HR_TR ); - push_indice_fx( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR_TR ); + push_indice( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR_TR ); nBits = sub( nBits, NBITS_ENVELOPE_BWE_HR_TR ); ind2 = ind1; move16(); @@ -369,7 +369,7 @@ void swb_bwe_enc_hr_fx( ind1 = en_band_quant_fx( en_band_fx, swb_hr_env_code3_fx + ( NUM_ENVLOPE_CODE_HR_TR2 * 2 ), NUM_ENVLOPE_CODE_HR_TR2 ); } - push_indice_fx( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR_TR - 1 ); + push_indice( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR_TR - 1 ); nBits = sub( nBits, NBITS_ENVELOPE_BWE_HR_TR - 1 ); } @@ -439,7 +439,7 @@ void swb_bwe_enc_hr_fx( L_en_noncoded_fx = L_deposit_h( en_band_fx[N_BANDS_TRANS_BWE_HR - 1] ); /* to Put in Q16+9 */ } - push_indice_fx( hBstr, IND_HR_HF_GAIN, ind1, NBITS_HF_GAIN_BWE_HR ); + push_indice( hBstr, IND_HR_HF_GAIN, ind1, NBITS_HF_GAIN_BWE_HR ); nBits = sub( nBits, NBITS_HF_GAIN_BWE_HR ); } ELSE @@ -507,7 +507,7 @@ void swb_bwe_enc_hr_fx( L_gain_fx = L_shr( L_tmp, sub( 31 - 16, exp2 ) ); /* 31: 'L_tmp' is already in Q31 */ ind1 = gain_quant_fx( &L_gain_fx, &gain1_fx, LG10_MIN_GLOB_GAIN_BWE_HR_Q14, LG10_MAX_GLOB_GAIN_BWE_HR_Q13, NBITS_GLOB_GAIN_BWE_HR, &exp1 ); - push_indice_fx( hBstr, IND_HR_GAIN, ind1, NBITS_GLOB_GAIN_BWE_HR ); + push_indice( hBstr, IND_HR_GAIN, ind1, NBITS_GLOB_GAIN_BWE_HR ); nBits = sub( nBits, NBITS_GLOB_GAIN_BWE_HR ); /* normalization with global gain */ @@ -547,8 +547,8 @@ void swb_bwe_enc_hr_fx( ind1 = en_band_quant_fx( en_band_fx, swb_hr_env_code1_fx, NUM_ENVLOPE_CODE_HR1 ); ind2 = en_band_quant_fx( en_band_fx + 2, swb_hr_env_code2_fx, NUM_ENVLOPE_CODE_HR2 ); - push_indice_fx( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR1 ); - push_indice_fx( hBstr, IND_HR_ENVELOPE, ind2, NBITS_ENVELOPE_BWE_HR2 ); + push_indice( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR1 ); + push_indice( hBstr, IND_HR_ENVELOPE, ind2, NBITS_ENVELOPE_BWE_HR2 ); nBits = sub( nBits, NBITS_ENVELOPE_BWE_HR1 + NBITS_ENVELOPE_BWE_HR2 ); @@ -673,7 +673,7 @@ void swb_bwe_enc_hr_fx( L_en_noncoded_fx = L_mult0( min_env_fx, 16384 ); } - push_indice_fx( hBstr, IND_HR_HF_GAIN, ind1, NBITS_HF_GAIN_BWE_HR ); + push_indice( hBstr, IND_HR_HF_GAIN, ind1, NBITS_HF_GAIN_BWE_HR ); nBits = sub( nBits, NBITS_HF_GAIN_BWE_HR ); } ELSE @@ -758,7 +758,7 @@ void swb_bwe_enc_hr_fx( /* Put in Q16 */ L_gain_fx = L_shr( L_temp, sub( 31 - 16, temp2 ) ); /* 31: 'L_temp' is already in Q31 */ ind1 = gain_quant_fx( &L_gain_fx, &gain2_fx, LG10_MIN_GLOB_GAIN_BWE_HR_Q14, LG10_MAX_GLOB_GAIN_BWE_HR_Q13, NBITS_GLOB_GAIN_BWE_HR, &exp2 ); - push_indice_fx( hBstr, IND_HR_GAIN, ind1, NBITS_GLOB_GAIN_BWE_HR ); + push_indice( hBstr, IND_HR_GAIN, ind1, NBITS_GLOB_GAIN_BWE_HR ); nBits = sub( nBits, NBITS_GLOB_GAIN_BWE_HR ); /* normalize with global gain */ @@ -784,7 +784,7 @@ void swb_bwe_enc_hr_fx( WHILE( nBits > 0 ) { i = s_min( nBits, 16 ); - push_indice_fx( hBstr, IND_UNUSED, 0, i ); + push_indice( hBstr, IND_UNUSED, 0, i ); nBits = sub( nBits, i ); } return; diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 1a397c514951163ef7f4a99dd9c5143283e0a601..938cdd971357f75642f58b731ebc3513729939cd 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -806,7 +806,7 @@ static void gethar_noisegn_fx( } } - push_indice_fx( hBstr, IND_NOISEG, imin_fx, 2 ); + push_indice( hBstr, IND_NOISEG, imin_fx, 2 ); /*g=(float) pow (10.0f,gain_table[imin]);*/ L_temp = L_mult( gain_table_SWB_BWE_fx[imin_fx], 27213 ); /* Q14+Q13+1=Q28 log(10)/log(2)=3.3219 27213.23(Q13) */ @@ -909,7 +909,7 @@ static void EncodeSWBSubbands_fx( /* Write the indices into the bitstream */ FOR( k = 0; k < nBands_search_fx; k++ ) { - push_indice_fx( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] ); + push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] ); } IF( flag_dis == 0 ) @@ -974,7 +974,7 @@ static void EncodeSWBSubbands_fx( } ELSE { - push_indice_fx( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] ); + push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] ); } } diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index b73b0f992cc83d72151d977510880ec6e87e893c..ba165cba418cb68d6b0680bad403d394d7b64462 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1263,11 +1263,11 @@ void swb_pre_proc_ivas_fx( thr = icbwe_thr_TDM_fx; regV = icbwe_regressionValuesTDM_fx; -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, st->cldfbSynTd ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, st->cldfbSynTd ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); *Q_shb_spch = 0; move16(); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index ba8ee5aa8741d9cd5a64d4d2ecccc3113ca32ef7..316a5b5494e613ab5cf8ed39e651ca6c57ff478e 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -21,7 +21,6 @@ #define ENVSHBRES_ACORR_MIN 40 /* minimum lag for calculating autocorrelation function on SHB residual TD envelope */ #define ENVSHBRES_ACORR_MAX 80 /* maximum lag for calculating autocorrelation function on SHB residual TD envelope */ - /*-----------------------------------------------------------------* * Local functions *-----------------------------------------------------------------*/ @@ -551,7 +550,7 @@ void InitSWBencBuffer_ivas_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - hBWE_TD->prev_lsp_shb_fx[i] = lsp_shb_prev_tbl_fx[i]; + hBWE_TD->prev_lsp_shb_fx[i] = lsp_shb_prev_tbl_swb_tbe_enc_fx[i]; move16(); } @@ -867,7 +866,7 @@ void wb_tbe_enc_fx( } ELSE { - push_indice_fx( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_LBR_WB_LSF ); + push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_LBR_WB_LSF ); } Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i * LPC_SHB_ORDER_LBR_WB, lsp_wb, LPC_SHB_ORDER_LBR_WB ); @@ -929,7 +928,7 @@ void wb_tbe_enc_fx( } ELSE { - push_indice_fx( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF ); + push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF ); } Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB ); @@ -1163,7 +1162,7 @@ void wb_tbe_enc_fx( } ELSE { - push_indice_fx( st_fx->hBstr, IND_UV_FLAG, uv_flag, 1 ); + push_indice( st_fx->hBstr, IND_UV_FLAG, uv_flag, 1 ); /* Quantization of the subframe gain parameter */ QuantizeSHBsubgains_fx( st_fx, GainShape, st_fx->extl ); @@ -1392,11 +1391,7 @@ void wb_tbe_enc_ivas_fx( move32(); } -#ifdef FIX_ISSUE_1165 lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, st_fx->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); -#else - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, st_fx->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); -#endif FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { @@ -2487,7 +2482,7 @@ void swb_tbe_enc_fx( } ELSE { - push_indice_fx( st_fx->hBstr, IND_SHB_VF, vf_ind_fx, NUM_BITS_SHB_VF ); + push_indice( st_fx->hBstr, IND_SHB_VF, vf_ind_fx, NUM_BITS_SHB_VF ); } } @@ -3109,14 +3104,7 @@ void swb_tbe_enc_ivas_fx( } } - /* stab_check = a2lsp( lsf_shb, lpc_shb, LPC_SHB_ORDER ); - stab_check missing */ - /* LPC to LSP conversion */ - /* LPC: Q12, LSP: Q15 */ - E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); - - /* LSP to LSF conversion */ - /* LSP: Q15, LSF: Q15 */ - E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER ); + /* stab_check = a2lsp( lsf_shb, lpc_shb, LPC_SHB_ORDER ); */ test(); test(); @@ -3124,8 +3112,8 @@ void swb_tbe_enc_ivas_fx( { FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - // hBWE_TD->prev_lsp_shb_fx[i] = i / 20.0f; - hBWE_TD->prev_lsp_shb_fx[i] = lsp_shb_prev_tbl_fx[i]; + // hBWE_TD->prev_lsp_shb_fx[i] = i / 20.0f; // This value in float enc is lsf. + hBWE_TD->prev_lsp_shb_fx[i] = lsp_shb_prev_tbl_swb_tbe_enc_fx[i]; // lsf converted to lsp as fixed enc stores lsp. move16(); } } @@ -3135,6 +3123,14 @@ void swb_tbe_enc_ivas_fx( // mvr2r( hBWE_TD->prev_lsp_shb, lsf_shb, LPC_SHB_ORDER ); // } + /* LPC to LSP conversion */ + /* LPC: Q12, LSP: Q15 */ + E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); + + /* LSP to LSF conversion */ + /* LSP: Q15, LSF: Q15 */ + E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER ); + Copy( lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); Copy( lsf_shb_fx, lsf_shb_orig_fx, LPC_SHB_ORDER ); @@ -3839,8 +3835,8 @@ void swb_tbe_enc_ivas_fx( tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); - Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } @@ -5334,7 +5330,7 @@ static void QuantizeSHBsubgains_fx( idxSubGain = closest_centroid_lc_fx( subgains + NUM_SHB_SUBFR / 4, HBCB_SubGain5bit_fx, 1 << NUM_BITS_SHB_SUBGAINS ); Copy( HBCB_SubGain5bit_fx + idxSubGain * NUM_SHB_SUBFR / 4, subgains, NUM_SHB_SUBFR / 4 ); - push_indice_fx( hBstr, IND_SHB_SUBGAIN, idxSubGain, NUM_BITS_SHB_SUBGAINS ); + push_indice( hBstr, IND_SHB_SUBGAIN, idxSubGain, NUM_BITS_SHB_SUBGAINS ); FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -5405,7 +5401,7 @@ static void QuantizeSHBsubgains_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( hBstr, IND_SHB_SUBGAIN, idxSubGain, NUM_BITS_SHB_SUBGAINS ); + push_indice( hBstr, IND_SHB_SUBGAIN, idxSubGain, NUM_BITS_SHB_SUBGAINS ); } } @@ -5600,7 +5596,7 @@ static void Quant_shb_ener_sf_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( st_fx->hBstr, IND_SHB_ENER_SF, idxSubEner_fx, NUM_BITS_SHB_ENER_SF ); + push_indice( st_fx->hBstr, IND_SHB_ENER_SF, idxSubEner_fx, NUM_BITS_SHB_ENER_SF ); } return; } @@ -5687,7 +5683,7 @@ static void Quant_shb_res_gshape_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( st_fx->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); + push_indice( st_fx->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); } } } @@ -5791,7 +5787,7 @@ static void QuantizeSHBframegain_fx( 1 << NUM_BITS_SHB_FrameGain, &idxFrameGain, &Q_GainFrame, SHBCB_FrameGain64_fx ); - push_indice_fx( st_fx->hBstr, IND_SHB_FRAMEGAIN, idxFrameGain, NUM_BITS_SHB_FrameGain ); + push_indice( st_fx->hBstr, IND_SHB_FRAMEGAIN, idxFrameGain, NUM_BITS_SHB_FrameGain ); *rf_gainFrame_ind = idxFrameGain; move16(); /* Q18 */ } @@ -5856,7 +5852,7 @@ static void QuantizeSHBframegain_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( st_fx->hBstr, IND_SHB_FRAMEGAIN, idxFrameGain, NUM_BITS_SHB_FRAMEGAIN ); + push_indice( st_fx->hBstr, IND_SHB_FRAMEGAIN, idxFrameGain, NUM_BITS_SHB_FRAMEGAIN ); } *rf_gainFrame_ind = idxFrameGain; move16(); @@ -7180,7 +7176,7 @@ static void Quant_BWE_LSF_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( hBstr, IND_SHB_LSF, lsf_idx[i], lsf_q_num_bits[i] ); + push_indice( hBstr, IND_SHB_LSF, lsf_idx[i], lsf_q_num_bits[i] ); } } @@ -7190,7 +7186,7 @@ static void Quant_BWE_LSF_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( hBstr, IND_SHB_MIRROR, m_idx, MIRROR_POINT_BITS ); + push_indice( hBstr, IND_SHB_MIRROR, m_idx, MIRROR_POINT_BITS ); } grid_idx = Find_LSF_grid_fx( lsf, lsf_q, m ); @@ -7198,7 +7194,7 @@ static void Quant_BWE_LSF_fx( hBWE_TD->grid_idx = grid_idx; IF( NE_16( st_fx->codec_mode, MODE2 ) ) { - push_indice_fx( hBstr, IND_SHB_GRID, grid_idx, NUM_LSF_GRID_BITS ); + push_indice( hBstr, IND_SHB_GRID, grid_idx, NUM_LSF_GRID_BITS ); } FOR( i = 0; i < LPC_SHB_ORDER; i++ ) @@ -7411,7 +7407,7 @@ void fb_tbe_enc_fx( } ELSE { - push_indice_fx( st->hBstr, IND_FB_SLOPE, idxGain, 4 ); + push_indice( st->hBstr, IND_FB_SLOPE, idxGain, 4 ); } return; @@ -7583,10 +7579,10 @@ void tbe_write_bitstream_fx( IF( ( st_fx->rf_mode || EQ_32( st_fx->total_brate, ACELP_9k60 ) ) && ( EQ_16( st_fx->bwidth, WB ) ) ) { /* WB LSF */ - push_next_indice_fx( hBstr, hBWE_TD->lsf_WB, NUM_BITS_LBR_WB_LSF ); + push_next_indice( hBstr, hBWE_TD->lsf_WB, NUM_BITS_LBR_WB_LSF ); /* WB frame */ - push_next_indice_fx( hBstr, hBWE_TD->gFrame_WB, NUM_BITS_SHB_FrameGain_LBR_WB ); + push_next_indice( hBstr, hBWE_TD->gFrame_WB, NUM_BITS_SHB_FrameGain_LBR_WB ); } ELSE IF( ( GE_32( st_fx->total_brate, ACELP_9k60 ) ) && ( LE_32( st_fx->total_brate, ACELP_32k ) ) && ( ( EQ_16( st_fx->bwidth, SWB ) ) || ( EQ_16( st_fx->bwidth, FB ) ) ) ) @@ -7596,53 +7592,53 @@ void tbe_write_bitstream_fx( test(); IF( ( EQ_16( st_fx->rf_mode, 1 ) ) || EQ_32( st_fx->total_brate, ACELP_9k60 ) ) { - push_next_indice_fx( hBstr, hBWE_TD->lsf_idx[0], 8 ); + push_next_indice( hBstr, hBWE_TD->lsf_idx[0], 8 ); } ELSE { FOR( i = 0; i < NUM_Q_LSF; i++ ) { - push_next_indice_fx( hBstr, hBWE_TD->lsf_idx[i], lsf_q_num_bits[i] ); + push_next_indice( hBstr, hBWE_TD->lsf_idx[i], lsf_q_num_bits[i] ); } /* LSF mirror points */ - push_next_indice_fx( hBstr, hBWE_TD->m_idx, MIRROR_POINT_BITS ); + push_next_indice( hBstr, hBWE_TD->m_idx, MIRROR_POINT_BITS ); /* LSF grid points */ - push_next_indice_fx( hBstr, hBWE_TD->grid_idx, NUM_LSF_GRID_BITS ); + push_next_indice( hBstr, hBWE_TD->grid_idx, NUM_LSF_GRID_BITS ); } /* Gain shape */ - push_next_indice_fx( hBstr, hBWE_TD->idxSubGains, NUM_BITS_SHB_SUBGAINS ); + push_next_indice( hBstr, hBWE_TD->idxSubGains, NUM_BITS_SHB_SUBGAINS ); /* frame gain */ - push_next_indice_fx( hBstr, hBWE_TD->idxFrameGain, NUM_BITS_SHB_FRAMEGAIN ); + push_next_indice( hBstr, hBWE_TD->idxFrameGain, NUM_BITS_SHB_FRAMEGAIN ); IF( GE_32( st_fx->total_brate, ACELP_24k40 ) ) { /* sub frame energy*/ - push_next_indice_fx( hBstr, hBWE_TD->idx_shb_fr_gain, NUM_BITS_SHB_ENER_SF ); + push_next_indice( hBstr, hBWE_TD->idx_shb_fr_gain, NUM_BITS_SHB_ENER_SF ); /* gain shapes residual */ FOR( i = 0; i < NB_SUBFR16k; i++ ) { - push_next_indice_fx( hBstr, hBWE_TD->idx_res_gs[i], NUM_BITS_SHB_RES_GS ); + push_next_indice( hBstr, hBWE_TD->idx_res_gs[i], NUM_BITS_SHB_RES_GS ); } /* voicing factor */ - push_next_indice_fx( hBstr, hBWE_TD->idx_mixFac, NUM_BITS_SHB_VF ); + push_next_indice( hBstr, hBWE_TD->idx_mixFac, NUM_BITS_SHB_VF ); } IF( EQ_16( st_fx->tec_tfa, 1 ) ) { - push_next_indice_fx( hBstr, st_fx->tec_flag, BITS_TEC ); - push_next_indice_fx( hBstr, st_fx->tfa_flag, BITS_TFA ); + push_next_indice( hBstr, st_fx->tec_flag, BITS_TEC ); + push_next_indice( hBstr, st_fx->tfa_flag, BITS_TFA ); } } IF( EQ_16( st_fx->bwidth, FB ) ) { - push_next_indice_fx( hBstr, hBWE_TD->idxGain, 4 ); + push_next_indice( hBstr, hBWE_TD->idxGain, 4 ); } } diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index 82088be5088b04dcb55b92c2b5fb48aee23dd3e9..d5841094fffca30c897bf4c791ad55ad703ffd56 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -449,11 +449,11 @@ ivas_error tcq_core_LR_enc_fx( j = sub( bit_budget, shl( nb_bytes, 3 ) ); FOR( i = 0; i < nb_bytes; i++ ) { - push_indice_fx( hBstr, IND_HQ2_SUBBAND_TCQ, pbs_fx->buf[i], 8 ); + push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, pbs_fx->buf[i], 8 ); } IF( j > 0 ) { - push_indice_fx( hBstr, IND_HQ2_SUBBAND_TCQ, shr( pbs_fx->buf[nb_bytes], ( 8 - j ) ), j ); + push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, shr( pbs_fx->buf[nb_bytes], ( 8 - j ) ), j ); } /* Clear decoding buffer */ set32_fx( coefs_quant_fx, 0, sfm_end[BANDS - 1] + 1 ); diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 19afa82437d68511599f10d0d4a0a796ed7f0a50..84f83a3119ec01dd953676844b2cf9c70dc19ef7 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -536,11 +536,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra BASOP_SATURATE_WARNING_ON_EVS /* Quantize gain */ -#ifdef FIX_ISSUE_1150 g = shr( sub_o( g, 0x1000, &Overflow ), 13 ); -#else - g = shr( sub( g, 0x1000 ), 13 ); -#endif g = s_max( g, -1 ); *gain_index = g; @@ -935,9 +931,9 @@ void tcx_ltp_encode_ivas_fx( { hTcxEnc->tcxltp_pitch_int_past = L_frame; move16(); - hTcxEnc->tcxltp_pitch_int_past = 0; + hTcxEnc->tcxltp_pitch_fr_past = 0; move16(); - hTcxEnc->tcxltp_pitch_int_past = 0; + hTcxEnc->tcxltp_gain_past = 0; move16(); } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index ce7f0e6a6e446c94e058f7d9f2336cda1d28a8a7..2abe538e445a952f02ea71d5d0f20dbe69988d01 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -172,6 +172,117 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, } } +void ComputeSpectrumNoiseMeasure_ivas_fx( Word64 *powerSpec, /* Qx */ + Word16 L_frame, /* Q0 */ + Word16 startLine, /* Q0 */ + Word8 resetMemory, /* Q0 */ + Word8 *noiseFlags, /* Q0 */ + Word16 lowpassLine /* Q0 */ +) +{ + Word16 i, lastTone, j, exp; + Word32 c; + Word64 s, temp; + + IF( resetMemory != 0 ) + { + FOR( i = 0; i < lowpassLine; i++ ) + { + noiseFlags[i] = 0; + move16(); + } + } + + FOR( i = lowpassLine; i < L_frame; i++ ) + { + noiseFlags[i] = 1; + move16(); + } + + test(); + IF( powerSpec != NULL && LT_16( add( startLine, 6 ), L_frame ) ) + { + lastTone = 0; + move16(); + + /* noise-measure flags for spectrum filling and quantization (0: tonal, 1: noise-like) */ + i = sub( startLine, 1 ); + /* s = powerSpec[i - 7] + powerSpec[i - 6] + powerSpec[i - 5] + + powerSpec[i - 4] + powerSpec[i - 3] + powerSpec[i - 2] + + powerSpec[i - 1] + powerSpec[i] + powerSpec[i + 1] + + powerSpec[i + 2] + powerSpec[i + 3] + powerSpec[i + 4] + + powerSpec[i + 5] + powerSpec[i + 6] + powerSpec[i + 7]; */ + + s = powerSpec[i - 7]; // Qx + move64(); + FOR( j = -6; j < 8; j++ ) + { + s = W_add( s, powerSpec[i + j] ); // Qx + } + + FOR( i = i + 1; i < lowpassLine - 7; i++ ) + { + /* c = powerSpec[i - 1] + powerSpec[i] + powerSpec[i + 1]; */ + temp = W_add( W_add( powerSpec[i - 1], powerSpec[i] ), powerSpec[i + 1] ); + exp = W_norm( temp ); + c = W_extract_h( W_shl( temp, exp ) ); // Qx+exp-32 + + /* s += powerSpec[i + 7] - powerSpec[i - 8]; */ + s = W_sub( s, powerSpec[i - 8] ); // Qx + s = W_add( s, powerSpec[i + 7] ); // Qx + + /* ( 1.75f - 0.5f * noiseFlags[i] ) * c */ + temp = W_mult_32_32( c, L_msu0( 28672 /* 1.75 in Q14*/, 8192 /* 0.5 in Q14 */, noiseFlags[i] ) ); // Qx+exp-32+14+1 = Qx+exp-17 + + IF( GE_64( W_shl( s, sub( exp, Q17 ) ), temp ) /* s >= ( 1.75f - 0.5f * noiseFlags[i] ) * c */ ) // Qx+exp-17 + { + noiseFlags[i] = 1; + move16(); + } + ELSE + { + noiseFlags[i] = 0; + lastTone = i; + move16(); + move16(); + } + } + + /* lower L_frame*startRatio lines are tonal (0), upper 7 lines are processed separately */ + FOR( ; i < lowpassLine - 1; i++ ) + { + /* c = powerSpec[i - 1] + powerSpec[i] + powerSpec[i + 1]; */ + temp = W_add( W_add( powerSpec[i - 1], powerSpec[i] ), powerSpec[i + 1] ); + exp = W_norm( temp ); + c = W_extract_h( W_shl( temp, exp ) ); // Qx+exp-32 + + /* ( 1.75f - 0.5f * noiseFlags[i] ) * c */ + temp = W_mult_32_32( c, L_msu0( 28672 /* 1.75 in Q14*/, 8192 /* 0.5 in Q14 */, noiseFlags[i] ) ); // Qx+exp-32+14+1 = Qx+exp-17 + + IF( GE_64( W_shl( s, sub( exp, Q17 ) ), temp ) /* s >= ( 1.75f - 0.5f * noiseFlags[i] ) * c */ ) // Qx+exp-17 + { + noiseFlags[i] = 1; + move16(); + } + ELSE + { + noiseFlags[i] = 0; + lastTone = i; + move16(); + move16(); + } + } + noiseFlags[i] = 1; /* uppermost line is defined as noise-like (1) */ + move16(); + + if ( lastTone > 0 ) /* spread uppermost tonal line one line upward */ + { + noiseFlags[lastTone + 1] = 0; + move16(); + } + } +} + static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word16 L_frame, Word8 rectWin, Word16 *pLpFac, Word16 lowpassLine ) { Word16 i, tmp; @@ -330,7 +441,8 @@ void AnalyzePowerSpectrum_ivas_fx( Word32 const mdctSpectrum[], /* input: MDCT spectrum */ Word16 mdctSpectrum_e, Word16 const signal[], /* input: windowed signal corresponding to mdctSpectrum */ - Word32 powerSpec[], /* output: Power spectrum. Can point to signal */ + const Word16 q_signal, + Word32 powerSpec[], /* output: Power spectrum. Can point to signal */ Word16 powerSpec_e[] ) { Word16 i, iStart, iEnd, lowpassLine; @@ -342,8 +454,7 @@ void AnalyzePowerSpectrum_ivas_fx( lowpassLine = L_frameTCX; move16(); - Word16 temp_powerSpec_e = 16; - move16(); + Word16 temp_powerSpec_e = sub( 16, q_signal ); TCX_MDST( signal, powerSpec, &temp_powerSpec_e, left_overlap, sub( L_frameTCX, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); shift = L_norm_arr( powerSpec, N_MAX + L_MDCT_OVLP_MAX ); @@ -2799,12 +2910,14 @@ void tcx_encoder_memory_update_ivas_fx( Copy( xn_buf, synth, L_frame_glob ); Copy( synth + sub( L_frame_glob, M + 1 ), LPDmem->syn, M + 1 ); + LPDmem->q_lpd_syn = Q_new; + move16(); IF( st->tcxonly == 0 ) { /* Update weighted synthesis */ Residu3_fx( Ai + imult1616( sub( st->nb_subfr, 1 ), ( M + 1 ) ), synth + sub( L_frame_glob, 1 ), &tmp, 1, 0 ); - LPDmem->mem_w0 = sub_sat( wsig[sub( L_frame_glob, 1 )], tmp ); + LPDmem->mem_w0 = sub_sat( wsig[L_frame_glob - 1], tmp ); move16(); } @@ -2817,6 +2930,11 @@ void tcx_encoder_memory_update_ivas_fx( Copy( synth + sub( L_frame_glob, M ), LPDmem->mem_syn, M ); Copy( synth + sub( L_frame_glob, M ), LPDmem->mem_syn2, M ); Copy( synth + sub( L_frame_glob, L_SYN_MEM ), LPDmem->mem_syn_r, L_SYN_MEM ); + + /* Aligning the Q-factor of the remaining synthesis memory buffers */ + Scale_sig( LPDmem->mem_syn1_fx, M, sub( Q_new, LPDmem->q_mem_syn ) ); + Scale_sig( LPDmem->mem_syn3, M, sub( Q_new, LPDmem->q_mem_syn ) ); + LPDmem->q_mem_syn = Q_new; // resultant q of synth after E_UTIL_f_preemph2 move16(); @@ -3643,7 +3761,7 @@ Word16 tcx_res_Q_spec_ivas_fx( return bits; } - +#if 1 // TV void ProcessIGF_fx( IGF_ENC_INSTANCE_HANDLE const hInstance, /**< in: instance handle of IGF Encoder */ Encoder_State *st, /**< in: Encoder state */ @@ -3660,8 +3778,13 @@ void ProcessIGF_fx( Word16 igfGridIdx; Word16 isIndepFlag; Word16 bsBits; - Word16 bsStart; +#ifndef HARM_PUSH_BIT + Word16 bsStart, pBsStart; +#else + Word16 pBsStart; +#endif BSTR_ENC_HANDLE hBstr = st->hBstr; + IGF_ENC_INSTANCE_HANDLE hIGFEnc = st->hIGFEnc; isIndepFlag = 1; @@ -3714,6 +3837,8 @@ void ProcessIGF_fx( Word16 Q_A; Word16 predictionGain = 0; Word16 *flatteningTrigger = &( st->hIGFEnc->flatteningTrigger ); + + move32(); move16(); move16(); @@ -3734,8 +3859,9 @@ void ProcessIGF_fx( } } +#ifndef HARM_PUSH_BIT bsStart = hBstr->next_ind_fx; - +#endif move16(); hInstance->infoTotalBitsPerFrameWritten = 0; move16(); @@ -3743,6 +3869,7 @@ void ProcessIGF_fx( { IGFEncWriteBitstream_fx( hInstance, NULL, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); } +#ifndef HARM_PUSH_BIT ELSE { IGFEncWriteBitstream_fx( hInstance, st->hBstr, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); @@ -3753,8 +3880,20 @@ void ProcessIGF_fx( { IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot, hBstr->ind_list ); } -} +#else + ELSE + { + pBsStart = hBstr->nb_ind_tot; + move16(); + + IGFEncWriteBitstream_ivas_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); + bsBits = sub( hBstr->nb_ind_tot, pBsStart ); + IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); + } +#endif +} +#endif void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) { Word16 i, length, att; @@ -3784,10 +3923,8 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) * *---------------------------------------------------------------------*/ void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ -#ifdef MSAN_FIX - Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ -#endif + Encoder_State *st, /* i : Encoder state */ + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ Word32 *pMDCTSpectrum, /* i : MDCT spectrum (*q_spectrum) */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ Word16 *q_spectrum, /* i/o: Q of spectrum */ @@ -3834,11 +3971,7 @@ void ProcessIGF_ivas_fx( IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, *q_spectrum ) ); -#ifndef MSAN_FIX - IGFEncApplyMono_ivas_fx( st, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); -#else IGFEncApplyMono_ivas_fx( st, powerSpec_len, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); -#endif curr_order = 0; move16(); @@ -3876,7 +4009,7 @@ void ProcessIGF_ivas_fx( IGFEncWriteBitstream_ivas_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); bsBits = sub( hBstr->nb_ind_tot, pBsStart ); - IGFEncConcatenateBitstream( hIGFEnc, bsBits, hBstr ); + IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); } return; @@ -3896,8 +4029,11 @@ void ProcessStereoIGF_fx( Word16 q_pITFMDCTSpectrum_1, Word16 q_pITFMDCTSpectrum_2, Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ const Word16 frameno, /* i : flag indicating index of current subfr. */ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ const Word32 element_brate, /* i : element bitrate */ @@ -3941,7 +4077,8 @@ void ProcessStereoIGF_fx( IGFSaveSpectrumForITF_ivas_fx( hIGFEnc[1], igfGridIdx, pITFMDCTSpectrum_fx[1][frameno], sub( Q31, q_pITFMDCTSpectrum_2 ) ); - IGFEncApplyStereo_fx( hStereoMdct, ms_mask, hIGFEnc, igfGridIdx, sts, pPowerSpectrum_fx, pPowerSpectrumMsInv_fx, inv_spectrum_fx, frameno, sp_aud_decision0, element_brate, mct_on ); + IGFEncApplyStereo_fx( hStereoMdct, ms_mask, hIGFEnc, igfGridIdx, sts, pPowerSpectrum_fx, exp_pPowerSpectrum_fx, pPowerSpectrumMsInv_fx, exp_pPowerSpectrumMsInv_fx, + inv_spectrum_fx, exp_inv_spectrum_fx, frameno, sp_aud_decision0, element_brate, mct_on ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -3980,7 +4117,7 @@ void ProcessStereoIGF_fx( IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], hBstr, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); bsBits = sub( hBstr->nb_ind_tot, pBsStart ); - IGFEncConcatenateBitstream( hIGFEnc[ch], bsBits, hBstr ); + IGFEncConcatenateBitstream_ivas_fx( hIGFEnc[ch], bsBits, hBstr ); } } return; diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index cf6e5dd6417827061efc67503270a95395ab65a2..05b35813a5bb1efb1a2507cc5e2f7daa65a565cf 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -229,11 +229,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, assert( n < (Word16) ( sizeof( tmpbuf ) / sizeof( Word16 ) ) ); FOR( i = 0; i < n; i++ ) { -#ifdef FIX_ISSUE_1147 tmpbuf[i] = round_fx_sat( L_shl( pSpectrum[iStartLine + i], shift ) ); -#else - tmpbuf[i] = round_fx( L_shl( pSpectrum[iStartLine + i], shift ) ); -#endif move16(); } diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 44bd8cc3c27dd144a8dac786fd0ee211a3259405..60d661db444fe5413372f79525dec4dfc24e032d 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -678,18 +678,13 @@ void RunTransientDetection_ivas_fx( IF( GT_16( sub( q_input, pSubblockEnergies->q_firState ), shift ) ) { Scale_sig( input_fx, length, add( sub( pSubblockEnergies->q_firState, q_input ), shift ) ); // q_firState + shift -#ifdef FIX_ISSUE_1186 - q_input = add( pSubblockEnergies->q_firState, shift ); // q_firState + shift -#endif - pSubblockEnergies->firState1 = shl( pSubblockEnergies->firState1, shift ); // q_firState + shift + q_input = add( pSubblockEnergies->q_firState, shift ); // q_firState + shift + pSubblockEnergies->firState1 = shl( pSubblockEnergies->firState1, shift ); // q_firState + shift move16(); pSubblockEnergies->firState2 = shl( pSubblockEnergies->firState2, shift ); // q_firState + shift move16(); pSubblockEnergies->q_firState = add( pSubblockEnergies->q_firState, shift ); // q_firState + shift move16(); -#ifndef FIX_ISSUE_1186 - q_input = add( pSubblockEnergies->q_firState, shift ); // q_firState + shift -#endif } ELSE { @@ -715,11 +710,7 @@ void RunTransientDetection_ivas_fx( } /* Update subblock energies. */ -#ifdef MSAN_FIX Scale_sig( filteredInput_fx, length, sub( 0, q_input ) ); // q0 -#else - Scale_sig( filteredInput_fx, L_FRAME_MAX, 8 ); -#endif UpdateSubblockEnergies_ivas_fx( filteredInput_fx, length, pSubblockEnergies ); /* Run transient detectors. */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 9911d766ae7790b70d3e26b7a5cbe1b37b0d5063..6718552c50c293060c7af36aa7625249778aeb3b 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -213,11 +213,7 @@ void transition_enc_fx( { /* this is called only to compute unused bits */ config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#ifdef NONBE_FIX_GSC_BSTR L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, -#else - L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, -#endif st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } @@ -329,11 +325,7 @@ void transition_enc_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#ifdef NONBE_FIX_GSC_BSTR st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, -#else - st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, -#endif unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } /*-----------------------------------------------------------------* @@ -397,7 +389,7 @@ void transition_enc_fx( /* 7bit ENCODER */ /* index = (*T0-pit_start)*2 + *T0_frac/2;*/ index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -446,7 +438,7 @@ void transition_enc_fx( limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max for delta search */ index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -510,7 +502,7 @@ void transition_enc_fx( *T0_frac = 0; move16(); } - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -534,7 +526,7 @@ void transition_enc_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); move16(); index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -615,7 +607,7 @@ void transition_enc_fx( IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { - push_indice_fx( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); + push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } } @@ -776,7 +768,7 @@ void transition_enc_fx( /*index = (*T0)*2 + ((*T0_frac)>>1) - (PIT16k_FR2_TC0_2SUBFR*2) + ((PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4);*/ index = add( sub( add( shl( *T0, 1 ), shr( *T0_frac, 1 ) ), ( PIT16k_FR2_TC0_2SUBFR * 2 ) ), ( PIT16k_FR2_TC0_2SUBFR - PIT16k_MIN ) * 4 ); } - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); } ELSE IF( EQ_16( nBits, 6 ) ) { @@ -785,7 +777,7 @@ void transition_enc_fx( move16(); index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); } IF( EQ_16( nBits, 6 ) ) { @@ -811,8 +803,8 @@ void transition_enc_fx( *Jopt_flag = 0; move16(); - set16_fx( &exc_fx[i_subfr], 0, L_SUBFR + 1 ); /* set excitation for current subrame to 0 */ - push_indice_fx( hBstr, IND_LP_FILT_SELECT, 0, 1 ); /* this bit is actually not needed */ + set16_fx( &exc_fx[i_subfr], 0, L_SUBFR + 1 ); /* set excitation for current subrame to 0 */ + push_indice( hBstr, IND_LP_FILT_SELECT, 0, 1 ); /* this bit is actually not needed */ Copy( xn_fx, xn2_fx, L_SUBFR ); /* target vector for codebook search */ set16_fx( y1_fx, 0, L_SUBFR ); /* set filtered adaptive excitation to 0 */ @@ -847,7 +839,7 @@ void transition_enc_fx( IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { - push_indice_fx( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); + push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } *Jopt_flag = 1; @@ -1042,11 +1034,7 @@ void transition_enc_ivas_fx( { /* this is called only to compute unused bits */ config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#ifdef NONBE_FIX_GSC_BSTR L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, -#else - L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, -#endif st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } @@ -1158,11 +1146,7 @@ void transition_enc_ivas_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#ifdef NONBE_FIX_GSC_BSTR st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, -#else - st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, -#endif unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } /*-----------------------------------------------------------------* @@ -1902,7 +1886,7 @@ static void tc_enc_fx( /* write pitch index */ IF( ( GE_16( *T0, L_SUBFR ) ) && ( NE_16( *tc_subfr, 3 * L_SUBFR ) ) ) { - push_indice_fx( hBstr, IND_PITCH, 0, nBits ); + push_indice( hBstr, IND_PITCH, 0, nBits ); } ELSE IF( EQ_16( *tc_subfr, 3 * L_SUBFR ) ) { @@ -1914,7 +1898,7 @@ static void tc_enc_fx( { index = abs_pit_enc_fx( 2, 0, *T0, *T0_frac ); } - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); limit_T0_fx( L_FRAME, 8, 0, 0, *T0, 0, T0_min, T0_max ); } @@ -1923,12 +1907,12 @@ static void tc_enc_fx( IF( EQ_16( nBits, 6 ) ) { index = delta_pit_enc_fx( 2, *T0, *T0_frac, PIT_MIN - 1 ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); } ELSE { index = delta_pit_enc_fx( 0, *T0, *T0_frac, PIT_MIN - 1 ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); } } } @@ -1942,13 +1926,13 @@ static void tc_enc_fx( ELSE IF( EQ_16( nBits, 6 ) ) { index = add( shl( sub( *T0, PIT16k_MIN ), 1 ), shr( *T0_frac, 1 ) ); - push_indice_fx( hBstr, IND_PITCH, index, nBits ); + push_indice( hBstr, IND_PITCH, index, nBits ); } } - push_indice_fx( hBstr, IND_TC_IMP_SHAPE, imp_shape, 3 ); - push_indice_fx( hBstr, IND_TC_IMP_POS, imp_pos, 6 ); - push_indice_fx( hBstr, IND_TC_IMP_SIGN, pitch_sign_fx, 1 ); - push_indice_fx( hBstr, IND_TC_IMP_GAIN, pitch_index, 3 ); + push_indice( hBstr, IND_TC_IMP_SHAPE, imp_shape, 3 ); + push_indice( hBstr, IND_TC_IMP_POS, imp_pos, 6 ); + push_indice( hBstr, IND_TC_IMP_SIGN, pitch_sign_fx, 1 ); + push_indice( hBstr, IND_TC_IMP_GAIN, pitch_index, 3 ); *position = add( imp_pos, i_subfr ); move16(); diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index b0dba61de4752b160164a6ad70f5612adcc6a100..8081b29097d39ced20004f5a95a6403c7e39e297 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -1156,7 +1156,7 @@ ivas_error ppp_voiced_encoder_fx( { Q_delta_lag = add( delta_lag_E, 11 ); /* to make it positive always */ - push_indice_fx( hBstr, IND_DELTALAG, Q_delta_lag, 5 ); + push_indice( hBstr, IND_DELTALAG, Q_delta_lag, 5 ); } WIsyn_fx( *dtfs_temp_fx, CURRP_Q_E_FX, lpc2_fx, &( hSC_VBR->ph_offset_E_fx ), out_fx, L_FRAME, 0, S_fx, C_fx, diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 92f5b8deaa55a165c0b4d8cec07bdb474a89f767..306b47d711df41e90977a2f288e069701d988dc6 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -2023,10 +2023,10 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( Q_cldfb = add( scaleFactor, Q_in ); #endif Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 #else - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 #endif Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); Q_out[ch_idx] = sub( Q_cldfb, 1 ); @@ -2091,10 +2091,10 @@ void isar_rend_CldfbSplitPostRendProcess( } Q_cldfb = scaleFactor + Q_cldfb_in; Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 #else - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 #endif Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); Q_out[ch_idx] = sub( Q_cldfb, 1 ); diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index c4c551bc082239bc2995e456b9f01347ce69eb0e..82c01004e7a93cfd5679e0ca51a8d51931db873e 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1624,18 +1624,20 @@ static ivas_error renderSplitBinauralWithPostRot( } Q_cldfb = scaleFactor + Q_cldfb_final[sf_idx]; Scale_sig32( hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( tmpCrendBuffer_fx[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, + 0, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 #else cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( tmpCrendBuffer_fx[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, + 0, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 #endif Scale_sig32( hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index ae7c28b0f121ba3085d9a49d0fe1bf01a6942327..fa3462fdc7a0f2ac8cb5003383f5938b244603ea 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -520,10 +520,10 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 #else - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 #endif Q_out[ch] = sub( Q_cldfb, 1 ); move16(); @@ -581,10 +581,10 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 #else - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 #endif Q_out[ch] = sub( Q_cldfb, 1 ); move16(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 08d70218c7ca8fa06e7e27e686e09b7ce7144bbb..32bcb732e538ffec57d83efb36a1a19a8b5fa9d0 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -72,11 +72,9 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define INV_TAN30_FX 28377 // Q14 #define EPSILON_MANT 1180591621 /* 1e-12 = 0.5497558*(2^-39) in Q70 */ #define EPSILON_EXP ( -39 ) -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC -#define ONE_DIV_EPSILON_MANT 1953125000 /* 1e+12 = 0.9094947*(2^40) */ -#define ONE_DIV_EPSILON_EXP ( 40 ) -#endif -#define ADAPT_HTPROTO_ROT_LIM_1 0.8f +#define ONE_DIV_EPSILON_MANT 1953125000 /* 1e+12 = 0.9094947*(2^40) */ +#define ONE_DIV_EPSILON_EXP ( 40 ) +#define ADAPT_HTPROTO_ROT_LIM_1 0.8f #define MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ @@ -151,10 +149,8 @@ static void matrixTransp2Mul_fx( Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx Word32 Ascale, Word32 Bscale, -#endif Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); @@ -909,12 +905,9 @@ static void ivas_dirac_dec_binaural_internal_fx( IF( hDiracDecBin->useTdDecorr ) { -#ifdef FIX_ISSUE_1185 Word32 tmp_arr[60]; -#endif FOR( ch = BINAURAL_CHANNELS; ch < ( 2 * BINAURAL_CHANNELS ); ch++ ) { -#ifdef FIX_ISSUE_1185 q_cldfb[ch][slot] = sub( q_input, 1 ); move16(); @@ -932,15 +925,6 @@ static void ivas_dirac_dec_binaural_internal_fx( scale_sig32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, sub( st_ivas->cldfbAnaDec[ch]->p_filter_length, st_ivas->cldfbAnaDec[ch]->no_channels ), sub( q_input, st_ivas->cldfbAnaDec[ch]->Q_cldfb_state ) ); st_ivas->cldfbAnaDec[ch]->Q_cldfb_state = q_input; move16(); -#else - q_cldfb[ch][slot] = q_input; - move16(); - cldfbAnalysis_ts_fx_fixed_q( - &( st_ivas->hTcBuffer->tc_fx[ch][nBins * slot + offsetSamples] ), - Cldfb_RealBuffer_in_fx[ch][slot], - Cldfb_ImagBuffer_in_fx[ch][slot], - nBins, st_ivas->cldfbAnaDec[ch], &q_cldfb[ch][slot] ); -#endif /*FIX_ISSUE_1185*/ test(); test(); @@ -982,10 +966,8 @@ static void ivas_dirac_dec_binaural_internal_fx( { scale_sig32( Cldfb_RealBuffer_in_fx[cha][slot], 60, sub( q_inp, q_cldfb[cha][slot] ) ); // Q6 scale_sig32( Cldfb_ImagBuffer_in_fx[cha][slot], 60, sub( q_inp, q_cldfb[cha][slot] ) ); // Q6 -#ifdef FIX_ISSUE_1185 q_cldfb[cha][slot] = 6; move16(); -#endif } } @@ -2998,10 +2980,8 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( matrixMul_fx( Mre_fx, Mim_fx, &q_M, CxRe_fx, CxIm_fx, &q_Cx, tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); matrixTransp2Mul_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx 1 /*int Ascale*/, 0 /*int Bscale*/, -#endif resultMtxRe_fx, resultMtxIm_fx, &q_res ); /* When below the frequency limit where decorrelation is applied, we inject the decorrelated @@ -3167,13 +3147,12 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( tmp1 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), missingOutputEne_fx, sub( 31, q_missingOutputEne ), &exp1 ); { - Word16 exp_temp; - tmp2 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), EPSILON_MANT, EPSILON_EXP, &exp_temp ); - tmp2 = BASOP_Util_Divide3232_Scale_cadence( tmp1, tmp2, &exp ); - exp2 = add( exp, sub( exp1, exp_temp ) ); + tmp2 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), EPSILON_MANT, EPSILON_EXP, &exp2 ); + tmp2 = ISqrt32( tmp2, &exp2 ); + gain_fx = Mpy_32_32( tmp2, Sqrt32( tmp1, &exp1 ) ); + q_gain = sub( 31, add( exp2, exp1 ) ); } - gain_fx = Sqrt32( tmp2, &exp2 ); - q_gain = sub( 31, exp2 ); + // 1073741824 = 4 in Q28 IF( LT_16( q_gain, Q28 ) ) @@ -3689,20 +3668,20 @@ static void ivas_dirac_dec_binaural_process_output_fx( if ( recompute == 1 ) { /* Inverse filter bank */ -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, 0, cldfbSynDec[chA] ); +#else cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, cldfbSynDec[chA] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); } #else -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, 0, cldfbSynDec[chA] ); +#else cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, cldfbSynDec[chA] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); #endif /* SPLIT_REND_WITH_HEAD_ROT */ @@ -4357,7 +4336,8 @@ static void eig2x2_fx( /* Numeric case, when input is practically zeros */ // IF( D_fx[0] < EPSILON_FX ) - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( D_fx[0], *q_D, EPSILON_MANT, EPSILON_EXP ), -1 ) ) + + IF( LT_32( L_shl_sat( D_fx[0], sub( sub( 31, *q_D ), EPSILON_EXP ) ), EPSILON_MANT ) ) { Ure_fx[0][0] = ONE_IN_Q31; move32(); @@ -4576,16 +4556,17 @@ static void eig2x2_fx( move16(); } } - - IF( q_U_1 != 0 ) + if ( q_U_1 != 0 ) { *q_U = q_U_1; + move16(); } - ELSE + + if ( q_U_1 == 0 ) { *q_U = q_U_2; + move16(); } - move16(); return; } @@ -4640,11 +4621,6 @@ static void matrixMul_fx( Word16 chA, chB; Word16 min_q_shift1, min_q_shift2; Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); -#ifndef FIX_1113_OPT_DIRAC_BIN_REND -#ifndef IVAS_ENH64_CADENCE_CHANGES - Word32 tmp1, tmp2; -#endif -#endif min_q_shift1 = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); min_q_shift2 = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 ); @@ -4673,7 +4649,6 @@ static void matrixMul_fx( outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], W_extract_h( W_mac_32_32( W_mult_32_32( Are_fx[chA][0], Bim_fx[0][chB] ), Are_fx[chA][1], Bim_fx[1][chB] ) ) ); move32(); #else -#ifdef FIX_1113_OPT_DIRAC_BIN_REND outRe_fx[chA][chB] = Msub_32_32( Msub_32_32( Madd_32_32( Mpy_32_32( Are_fx[chA][0], Bre_fx[0][chB] ), Are_fx[chA][1], Bre_fx[1][chB] ), Aim_fx[chA][0], Bim_fx[0][chB] ), @@ -4684,106 +4659,6 @@ static void matrixMul_fx( Are_fx[chA][0], Bim_fx[0][chB] ), Are_fx[chA][1], Bim_fx[1][chB] ); move32(); -#else - test(); - test(); - test(); - IF( ( Are_fx[chA][0] >= 0 && Bre_fx[0][chB] >= 0 ) || ( Are_fx[chA][0] < 0 && Bre_fx[0][chB] < 0 ) ) - { - tmp1 = Mpy_32_32( Are_fx[chA][0], Bre_fx[0][chB] ); - } - ELSE - { - tmp1 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][0] ), L_abs( Bre_fx[0][chB] ) ) ); - } - test(); - test(); - test(); - IF( ( Are_fx[chA][1] >= 0 && Bre_fx[1][chB] >= 0 ) || ( Are_fx[chA][1] < 0 && Bre_fx[1][chB] < 0 ) ) - { - tmp2 = Mpy_32_32( Are_fx[chA][1], Bre_fx[1][chB] ); - } - ELSE - { - tmp2 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][1] ), L_abs( Bre_fx[1][chB] ) ) ); - } - outRe_fx[chA][chB] = L_add( tmp1, tmp2 ); - move32(); - - test(); - test(); - test(); - IF( ( Aim_fx[chA][0] >= 0 && Bim_fx[0][chB] >= 0 ) || ( Aim_fx[chA][0] < 0 && Bim_fx[0][chB] < 0 ) ) - { - tmp1 = Mpy_32_32( Aim_fx[chA][0], Bim_fx[0][chB] ); - } - ELSE - { - tmp1 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][0] ), L_abs( Bim_fx[0][chB] ) ) ); - } - test(); - test(); - test(); - IF( ( Aim_fx[chA][1] >= 0 && Bim_fx[1][chB] >= 0 ) || ( Aim_fx[chA][1] < 0 && Bim_fx[1][chB] < 0 ) ) - { - tmp2 = Mpy_32_32( Aim_fx[chA][1], Bim_fx[1][chB] ); - } - ELSE - { - tmp2 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][1] ), L_abs( Bim_fx[1][chB] ) ) ); - } - outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], L_add( tmp1, tmp2 ) ); - move32(); - test(); - test(); - test(); - IF( ( Aim_fx[chA][0] >= 0 && Bre_fx[0][chB] >= 0 ) || ( Aim_fx[chA][0] < 0 && Bre_fx[0][chB] < 0 ) ) - { - tmp1 = Mpy_32_32( Aim_fx[chA][0], Bre_fx[0][chB] ); - } - ELSE - { - tmp1 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][0] ), L_abs( Bre_fx[0][chB] ) ) ); - } - test(); - test(); - test(); - IF( ( Aim_fx[chA][1] >= 0 && Bre_fx[1][chB] >= 0 ) || ( Aim_fx[chA][1] < 0 && Bre_fx[1][chB] < 0 ) ) - { - tmp2 = Mpy_32_32( Aim_fx[chA][1], Bre_fx[1][chB] ); - } - ELSE - { - tmp2 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][1] ), L_abs( Bre_fx[1][chB] ) ) ); - } - outIm_fx[chA][chB] = L_add( tmp1, tmp2 ); - move32(); - - test(); - test(); - test(); - IF( ( Are_fx[chA][0] >= 0 && Bim_fx[0][chB] >= 0 ) || ( Are_fx[chA][0] < 0 && Bim_fx[0][chB] < 0 ) ) - { - tmp1 = Mpy_32_32( Are_fx[chA][0], Bim_fx[0][chB] ); - } - ELSE - { - tmp1 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][0] ), L_abs( Bim_fx[0][chB] ) ) ); - } - test(); - test(); - test(); - IF( ( Are_fx[chA][1] >= 0 && Bim_fx[1][chB] >= 0 ) || ( Are_fx[chA][1] < 0 && Bim_fx[1][chB] < 0 ) ) - { - tmp2 = Mpy_32_32( Are_fx[chA][1], Bim_fx[1][chB] ); - } - ELSE - { - tmp2 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][1] ), L_abs( Bim_fx[1][chB] ) ) ); - } - outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); - move32(); -#endif #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ } } @@ -4812,15 +4687,11 @@ static void matrixTransp1Mul_fx( { Word16 chA, chB; Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); -#ifndef FIX_1113_OPT_DIRAC_BIN_REND - Word32 tmp1, tmp2; -#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { -#ifdef FIX_1113_OPT_DIRAC_BIN_REND outRe_fx[chA][chB] = Madd_32_32( Madd_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ), Aim_fx[0][chA], Bim_fx[0][chB] ), @@ -4831,74 +4702,6 @@ static void matrixTransp1Mul_fx( Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); move32(); -#else - test(); - test(); - test(); - IF( ( ( ( Are_fx[0][chA] >= 0 ) && ( Bre_fx[0][chB] >= 0 ) ) || ( ( Are_fx[0][chA] < 0 ) && ( Bre_fx[0][chB] < 0 ) ) ) ) - tmp1 = Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( Are_fx[0][chA] ), L_abs( Bre_fx[0][chB] ) ) ); - test(); - test(); - test(); - IF( ( ( ( Are_fx[1][chA] >= 0 ) && ( Bre_fx[1][chB] >= 0 ) ) || ( ( Are_fx[1][chA] < 0 ) && ( Bre_fx[1][chB] < 0 ) ) ) ) - tmp2 = Mpy_32_32( Are_fx[1][chA], Bre_fx[1][chB] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Are_fx[1][chA] ), L_abs( Bre_fx[1][chB] ) ) ); - outRe_fx[chA][chB] = L_add( tmp1, tmp2 ); - move32(); - test(); - test(); - test(); - IF( ( ( ( L_negate( Aim_fx[0][chA] ) >= 0 ) && ( Bim_fx[0][chB] >= 0 ) ) || ( ( L_negate( Aim_fx[0][chA] ) < 0 ) && ( Bim_fx[0][chB] < 0 ) ) ) ) - tmp1 = Mpy_32_32( -Aim_fx[0][chA], Bim_fx[0][chB] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( -Aim_fx[0][chA] ), L_abs( Bim_fx[0][chB] ) ) ); - test(); - test(); - test(); - IF( ( ( ( Aim_fx[1][chA] >= 0 ) && ( Bim_fx[1][chB] >= 0 ) ) || ( ( Aim_fx[1][chA] < 0 ) && ( Bim_fx[1][chB] < 0 ) ) ) ) - tmp2 = Mpy_32_32( Aim_fx[1][chA], Bim_fx[1][chB] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Aim_fx[1][chA] ), L_abs( Bim_fx[1][chB] ) ) ); - outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], L_sub( tmp1, tmp2 ) ); - move32(); - - test(); - test(); - test(); - IF( ( ( ( L_negate( Aim_fx[0][chA] ) >= 0 ) && ( Bre_fx[0][chB] >= 0 ) ) || ( ( L_negate( Aim_fx[0][chA] ) < 0 ) && ( Bre_fx[0][chB] < 0 ) ) ) ) - tmp1 = Mpy_32_32( -Aim_fx[0][chA], Bre_fx[0][chB] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( -Aim_fx[0][chA] ), L_abs( Bre_fx[0][chB] ) ) ); - test(); - test(); - test(); - IF( ( ( ( Aim_fx[1][chA] >= 0 ) && ( Bre_fx[1][chB] >= 0 ) ) || ( ( Aim_fx[1][chA] < 0 ) && ( Bre_fx[1][chB] < 0 ) ) ) ) - tmp2 = Mpy_32_32( Aim_fx[1][chA], Bre_fx[1][chB] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Aim_fx[1][chA] ), L_abs( Bre_fx[1][chB] ) ) ); - outIm_fx[chA][chB] = L_sub( tmp1, tmp2 ); - move32(); - - test(); - test(); - test(); - IF( ( ( ( Are_fx[0][chA] >= 0 ) && ( Bim_fx[0][chB] >= 0 ) ) || ( ( Are_fx[0][chA] < 0 ) && ( Bim_fx[0][chB] < 0 ) ) ) ) - tmp1 = Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( Are_fx[0][chA] ), L_abs( Bim_fx[0][chB] ) ) ); - test(); - test(); - test(); - IF( ( ( ( Are_fx[1][chA] >= 0 ) && ( Bim_fx[1][chB] >= 0 ) ) || ( ( Are_fx[1][chA] < 0 ) && ( Bim_fx[1][chB] < 0 ) ) ) ) - tmp2 = Mpy_32_32( Are_fx[1][chA], Bim_fx[1][chB] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Are_fx[1][chA] ), L_abs( Bim_fx[1][chB] ) ) ); - outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); - move32(); -#endif } } *q_out = sub( add( q_A, q_B ), 31 ); @@ -4920,10 +4723,8 @@ static void matrixTransp2Mul_fx( Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ Word16 *q_B, -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx Word32 Ascale, Word32 Bscale, -#endif Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) @@ -4931,15 +4732,8 @@ static void matrixTransp2Mul_fx( Word16 chA, chB; Word16 min_q_shift; Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); -#ifndef FIX_1113_OPT_DIRAC_BIN_REND -#ifndef IVAS_ENH64_CADENCE_CHANGES - Word32 tmp1, tmp2; -#endif -#endif -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx IF( Ascale == 1 ) -#endif { min_q_shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); scale_sig32( Are_fx[0], size, min_q_shift ); @@ -4948,9 +4742,7 @@ static void matrixTransp2Mul_fx( move16(); } -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx IF( Bscale == 1 ) -#endif { min_q_shift = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 ); scale_sig32( Bre_fx[0], size, min_q_shift ); @@ -4973,7 +4765,6 @@ static void matrixTransp2Mul_fx( outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], W_extract_h( W_mac_32_32( W_mult_32_32( Are_fx[chA][0], L_negate( Bim_fx[chB][0] ) ), Are_fx[chA][1], L_negate( Bim_fx[chB][1] ) ) ) ); move32(); #else -#ifdef FIX_1113_OPT_DIRAC_BIN_REND outRe_fx[chA][chB] = Madd_32_32( Madd_32_32( Madd_32_32( Mpy_32_32( Are_fx[chA][0], Bre_fx[chB][0] ), Are_fx[chA][1], Bre_fx[chB][1] ), Aim_fx[chA][0], Bim_fx[chB][0] ), @@ -4984,75 +4775,6 @@ static void matrixTransp2Mul_fx( Are_fx[chA][0], Bim_fx[chB][0] ), Are_fx[chA][1], Bim_fx[chB][1] ); move32(); -#else - test(); - test(); - test(); - IF( ( Are_fx[chA][0] >= 0 && Bre_fx[chB][0] >= 0 ) || ( Are_fx[chA][0] < 0 && Bre_fx[chB][0] < 0 ) ) - tmp1 = Mpy_32_32( Are_fx[chA][0], Bre_fx[chB][0] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][0] ), L_abs( Bre_fx[chB][0] ) ) ); - test(); - test(); - test(); - IF( ( Are_fx[chA][1] >= 0 && Bre_fx[chB][1] >= 0 ) || ( Are_fx[chA][1] < 0 && Bre_fx[chB][1] < 0 ) ) - tmp2 = Mpy_32_32( Are_fx[chA][1], Bre_fx[chB][1] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][1] ), L_abs( Bre_fx[chB][1] ) ) ); - outRe_fx[chA][chB] = L_add( tmp1, tmp2 ); - move32(); - - test(); - test(); - test(); - IF( ( Aim_fx[chA][0] >= 0 && L_negate( Bim_fx[chB][0] ) >= 0 ) || ( Aim_fx[chA][0] < 0 && L_negate( Bim_fx[chB][0] ) < 0 ) ) - tmp1 = Mpy_32_32( Aim_fx[chA][0], -Bim_fx[chB][0] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][0] ), L_abs( -Bim_fx[chB][0] ) ) ); - test(); - test(); - test(); - IF( ( Aim_fx[chA][1] >= 0 && L_negate( Bim_fx[chB][1] ) >= 0 ) || ( Aim_fx[chA][1] < 0 && L_negate( Bim_fx[chB][1] ) < 0 ) ) - tmp2 = Mpy_32_32( Aim_fx[chA][1], -Bim_fx[chB][1] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][1] ), L_abs( -Bim_fx[chB][1] ) ) ); - outRe_fx[chA][chB] = L_sub( outRe_fx[chA][chB], L_add( tmp1, tmp2 ) ); - move32(); - - test(); - test(); - test(); - IF( ( Aim_fx[chA][0] >= 0 && Bre_fx[chB][0] >= 0 ) || ( Aim_fx[chA][0] < 0 && Bre_fx[chB][0] < 0 ) ) - tmp1 = Mpy_32_32( Aim_fx[chA][0], Bre_fx[chB][0] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][0] ), L_abs( Bre_fx[chB][0] ) ) ); - test(); - test(); - test(); - IF( ( Aim_fx[chA][1] >= 0 && Bre_fx[chB][1] >= 0 ) || ( Aim_fx[chA][1] < 0 && Bre_fx[chB][1] < 0 ) ) - tmp2 = Mpy_32_32( Aim_fx[chA][1], Bre_fx[chB][1] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Aim_fx[chA][1] ), L_abs( Bre_fx[chB][1] ) ) ); - outIm_fx[chA][chB] = L_add( tmp1, tmp2 ); - move32(); - - test(); - test(); - test(); - IF( ( Are_fx[chA][0] >= 0 && L_negate( Bim_fx[chB][0] ) >= 0 ) || ( Are_fx[chA][0] < 0 && L_negate( Bim_fx[chB][0] ) < 0 ) ) - tmp1 = Mpy_32_32( Are_fx[chA][0], -Bim_fx[chB][0] ); - ELSE - tmp1 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][0] ), L_abs( -Bim_fx[chB][0] ) ) ); - test(); - test(); - test(); - IF( ( Are_fx[chA][1] >= 0 && L_negate( Bim_fx[chB][1] ) >= 0 ) || ( Are_fx[chA][1] < 0 && L_negate( Bim_fx[chB][1] ) < 0 ) ) - tmp2 = Mpy_32_32( Are_fx[chA][1], -Bim_fx[chB][1] ); - ELSE - tmp2 = L_negate( Mpy_32_32( L_abs( Are_fx[chA][1] ), L_abs( -Bim_fx[chB][1] ) ) ); - outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); - move32(); -#endif #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ } } @@ -5127,15 +4849,6 @@ static void chol2x2_fx( } ELSE { -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - outRe[1][0] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[0][0], &exp ); - move32(); - q_re2 = add( sub( 31, exp ), sub( q_c, q_re1 ) ); - - outIm[1][0] = BASOP_Util_Divide3232_Scale_cadence( c_im, outRe[0][0], &exp ); - move32(); - q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) ); -#else Word32 denom; Word16 den_exp; Word32 my_outRe, my_outIm; @@ -5161,7 +4874,6 @@ static void chol2x2_fx( outIm[1][0] = Mpy_32_32( denom, my_outIm ); move32(); q_im = sub( q_im, den_exp ); -#endif } if ( outRe[1][0] == 0 ) { @@ -5180,16 +4892,11 @@ static void chol2x2_fx( // 4611686 = Q62 IF( e1 == 0 ) { -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - temp = BASOP_Util_Divide3232_Scale_cadence( temp, 4611686, &exp ); - q_tmp = add( sub( 31, exp ), sub( q_tmp, 62 ) ); -#else Word16 norm = norm_l( temp ); temp = L_shl( temp, norm ); q_tmp = add( q_tmp, norm ); temp = Mpy_32_32( temp, ONE_DIV_EPSILON_MANT ); q_tmp = sub( q_tmp, ONE_DIV_EPSILON_EXP ); -#endif } ELSE { @@ -5238,16 +4945,6 @@ static void chol2x2_fx( // 4611686 = Q62 IF( outRe[1][1] == 0 ) { -#if !defined( FIX_1072_REDUCE_DIVS ) - outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp ); - move32(); - q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) ); - - outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, 4611686, &exp ); - move32(); - q_im = add( sub( 31, exp ), sub( q_c, 62 ) ); - -#else // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp ); Word32 tmp1 = 1953125005; /* 1/4611686 Q62 */ exp = 9; @@ -5260,19 +4957,9 @@ static void chol2x2_fx( outIm[0][1] = Mpy_32_32( tmp1, -c_im ); move32(); q_im = add( sub( 31, exp ), sub( q_c, 62 ) ); -#endif } ELSE { -#if !defined( FIX_1072_REDUCE_DIVS ) - outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[1][1], &exp ); - move32(); - q_re2 = add( sub( 31, exp ), sub( q_c, q_re1 ) ); - - outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, outRe[1][1], &exp ); - move32(); - q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) ); -#else { // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[1][1], &exp ); Word32 tmp1 = BASOP_Util_Divide3232_Scale_cadence( 0x7FFFFFFF, outRe[1][1], &exp ); @@ -5285,7 +4972,6 @@ static void chol2x2_fx( move32(); q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) ); } -#endif } if ( outRe[0][1] == 0 ) { @@ -5450,15 +5136,10 @@ static void formulate2x2MixingMatrix_fx( // 4611686 = Q62 IF( maxEne_fx == 0 ) { -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC maxEneDiv_fx = ONE_DIV_EPSILON_MANT; move32(); q_maxEneDiv = 31 - ONE_DIV_EPSILON_EXP; move16(); -#else - maxEneDiv_fx = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, 4611686, &exp ); // 4611686 = 1e-12f in Q62 - q_maxEneDiv = add( sub( 31, exp ), sub( Q30, 62 ) ); -#endif } ELSE { @@ -5518,7 +5199,6 @@ static void formulate2x2MixingMatrix_fx( IF( temp == 0 ) { -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC IF( E_out1 == 0 ) { Ghat_fx[0] = 0; @@ -5532,10 +5212,6 @@ static void formulate2x2MixingMatrix_fx( exp = sub( exp, sub( q_eout, 62 ) ); Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp } -#else - temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62 - exp = sub( exp, sub( q_eout, 62 ) ); -#endif } ELSE { @@ -5543,20 +5219,14 @@ static void formulate2x2MixingMatrix_fx( temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, temp, &exp ); exp = sub( exp, sub( q_eout, sub( 31, exp_temp ) ) ); -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp -#endif } -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp -#endif move32(); temp = Mpy_32_32( E_in1, 2147484 ); // 2147484 = 0.001f in Q31 temp = L_max( temp, E_in2 ); // q_ein IF( temp == 0 ) { -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC IF( E_out2 == 0 ) { /* We can set hard-coded results */ Ghat_fx[1] = 0; @@ -5569,10 +5239,6 @@ static void formulate2x2MixingMatrix_fx( exp1 = sub( exp1, sub( q_eout, 62 ) ); Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1 } -#else - temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62 - exp1 = sub( exp1, sub( q_eout, 62 ) ); -#endif } ELSE { @@ -5580,13 +5246,8 @@ static void formulate2x2MixingMatrix_fx( temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, temp, &exp1 ); exp1 = sub( exp1, sub( q_eout, sub( 31, exp_temp ) ) ); -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1 -#endif } -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1 -#endif move32(); q_Ghat = sub( 31, s_max( exp, exp1 ) ); @@ -5635,13 +5296,10 @@ static void formulate2x2MixingMatrix_fx( IF( D_fx[0] == 0 ) { -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, 4611686, &exp ); // 4611686 = 1e-12 in Q62 - exp = sub( exp, sub( Q30, 62 ) ); -#else temp = ONE_DIV_EPSILON_MANT; /* Result of 1.0/eps with full precision */ + move32(); exp = ONE_DIV_EPSILON_EXP; -#endif + move16(); } ELSE { @@ -5651,24 +5309,16 @@ static void formulate2x2MixingMatrix_fx( div_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp move32(); - IF( D_fx[1] == 0 ) - { -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, 4611686, &exp1 ); // 4611686 = 1e-12 in Q62 - exp1 = sub( exp1, sub( Q30, 62 ) ); -#else - temp = ONE_DIV_EPSILON_MANT; /* Result of 1.0/eps with full precision */ - exp1 = ONE_DIV_EPSILON_EXP; -#endif - } - ELSE + // Sqrt(1) + div_fx[1] = L_add( 0, 2047986068 ); // Q = 31 - exp1 + exp1 = add( 0, 20 ); + + IF( D_fx[1] != 0 ) // This is the new code: replace div sqrt by isqrt { - temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, D_fx[1], &exp1 ); - exp1 = sub( exp1, sub( Q30, q_D ) ); + exp1 = sub( 31, q_D ); + div_fx[1] = ISqrt32( D_fx[1], &exp1 ); + move32(); } - div_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1 - move32(); - q_div = sub( 31, s_max( exp, exp1 ) ); div_fx[0] = L_shr( div_fx[0], sub( sub( 31, exp ), q_div ) ); // q_div @@ -5760,10 +5410,8 @@ static void formulate2x2MixingMatrix_fx( } matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx 1 /*int Ascale*/, 0 /*int Bscale*/, -#endif Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ @@ -5774,7 +5422,6 @@ static void formulate2x2MixingMatrix_fx( { IF( Sx_fx[chB] == 0 ) { -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC Pre_fx[chA][chB] = Mpy_32_32( Pre_fx[chA][chB], ONE_DIV_EPSILON_MANT ); // q_Pre[chA][chB] = add(sub(31, q_P), 31 - ONE_DIV_EPSILON_EXP); q_Pre[chA][chB] = sub( 62 - ONE_DIV_EPSILON_EXP, q_P ); @@ -5783,26 +5430,12 @@ static void formulate2x2MixingMatrix_fx( Pim_fx[chA][chB] = Mpy_32_32( Pim_fx[chA][chB], ONE_DIV_EPSILON_MANT ); // q_Pim[chA][chB] = add(sub(31, q_P), 31 - ONE_DIV_EPSILON_EXP); q_Pim[chA][chB] = sub( 62 - ONE_DIV_EPSILON_EXP, q_P ); -#else - Pre_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pre_fx[chA][chB], 4611686, &exp ); // 4611686 = 1e-12 in Q62 - q_Pre[chA][chB] = add( sub( q_P, 62 ), sub( 31, exp ) ); - Pim_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pim_fx[chA][chB], 4611686, &exp ); // 4611686 = 1e-12 in Q62 - q_Pim[chA][chB] = add( sub( q_P, 62 ), sub( 31, exp ) ); -#endif } ELSE { -#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC Word16 Pre_shift, Pim_shift; -#endif temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp ); -#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC - Pre_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pre_fx[chA][chB], temp, &exp ); - q_Pre[chA][chB] = add( sub( q_P, sub( 31, exp_temp ) ), sub( 31, exp ) ); - Pim_fx[chA][chB] = BASOP_Util_Divide3232_Scale_cadence( Pim_fx[chA][chB], temp, &exp ); - q_Pim[chA][chB] = add( sub( q_P, sub( 31, exp_temp ) ), sub( 31, exp ) ); -#else temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, temp, &exp ); Pre_shift = norm_l( Pre_fx[chA][chB] ); Pim_shift = norm_l( Pim_fx[chA][chB] ); @@ -5811,7 +5444,6 @@ static void formulate2x2MixingMatrix_fx( q_temp = add( sub( sub( q_P, exp ), sub( 31, Q30 ) ), exp_temp ); q_Pre[chA][chB] = add( q_temp, Pre_shift ); q_Pim[chA][chB] = add( q_temp, Pim_shift ); -#endif } if ( Pre_fx[chA][chB] == 0 ) { @@ -5914,10 +5546,8 @@ static void formulate2x2MixingMatrix_fx( matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, -#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx 1 /*int Ascale*/, 0 /*int Bscale*/, -#endif Mre_fx, Mim_fx, q_M ); return; } diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 1ffe0da7424b728fc644a9f70c40b1d3a50eb587..1afac99c4157d81f9bba3dcdb70fd94669950391 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -55,12 +55,10 @@ #define DIRAC_DUCK_ALPHA_FX 1717986944 /* Q31 */ #define ONE_M_DIRAC_DUCK_ALPHA 429496736 /* Q31 */ -#ifdef FIX_1110_OPTIM_DIRAC_DECORR_PROC /* Maximal useful q-format, represents range of 2^-126 (float min) */ #define MAX_Q_FX 157 -#endif /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ @@ -590,18 +588,6 @@ void ivas_dirac_dec_decorr_process_fx( Word16 decorr_buff_tot_len = imult1616( imult1616( shl( decorr_buffer_len, 1 ), max_band_decorr ), num_channels ); guarded_bits = 0; -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - FOR( Word16 i = 0; i < decorr_buff_tot_len; i++ ) - { - IF( h_freq_domain_decorr_ap_state->decorr_buffer_fx[i] != 0 ) - { - guarded_bits = s_max( find_guarded_bits_fx( 2 ), 3 ); - } - } - q_shift = sub( getScaleFactor32( h_freq_domain_decorr_ap_state->decorr_buffer_fx, decorr_buff_tot_len ), guarded_bits ); - Scale_sig32( h_freq_domain_decorr_ap_state->decorr_buffer_fx, decorr_buff_tot_len, q_shift ); - q_decorr_buf = add( q_decorr_buf, q_shift ); -#else Flag is_zero = is_zero_arr( h_freq_domain_decorr_ap_state->decorr_buffer_fx, decorr_buff_tot_len ); if ( is_zero == 0 ) { @@ -617,7 +603,6 @@ void ivas_dirac_dec_decorr_process_fx( q_decorr_buf = add( q_decorr_buf, q_shift ); } } -#endif q_shift = getScaleFactor32( aux_buffer_fx, imult1616( imult1616( 2, num_protos_dir ), max_band_decorr_temp ) ); Word16 buf_len = shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 ); @@ -681,15 +666,8 @@ void ivas_dirac_dec_decorr_process_fx( /* MA part of filter impulse response */ FOR( l = 0; l < filter_length; l++ ) { -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - frame_ma_fx[2 * l] = Mpy_32_16_1( input_real_fx, filter_coeff_num_real_fx[l] ); // Q_qux -3 = q_deorr - // frame_ma_fx[2 * l] = L_shr(frame_ma_fx[2 * l],3); // scaling to q_decorr_buf - frame_ma_fx[add( shl( l, 1 ), 1 )] = Mpy_32_16_1( input_imag_fx, filter_coeff_num_real_fx[l] ); // Q_qux - 3 = q_deorr - // frame_ma_fx[2 * l + 1] = L_shr(frame_ma_fx[2 * l + 1], 3); // scaling to q_decorr_buf -#else frame_ma_fx[2 * l] = Mpy_32_16_1( input_real_fx, filter_coeff_num_real_fx[l] ); // Q_qux -3 = q_deorr frame_ma_fx[2 * l + 1] = Mpy_32_16_1( input_imag_fx, filter_coeff_num_real_fx[l] ); // Q_qux - 3 = q_deorr -#endif move32(); move32(); } @@ -705,32 +683,14 @@ void ivas_dirac_dec_decorr_process_fx( filter_frame_real_fx = decorr_buffer_ptr_fx[0]; // q_decorr filter_frame_imag_fx = decorr_buffer_ptr_fx[1]; // q_decorr -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - decorr_buffer_ptr_fx += shl( decorr_buffer_step, 1 ); -#else Word16 decorr_buffer_step2x = shl( decorr_buffer_step, 1 ); decorr_buffer_ptr_fx += decorr_buffer_step2x; move16(); -#endif FOR( l = 1; l < filter_length; l++ ) { // q adjustment needed// -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - decorr_buffer_ptr_fx[0] = L_add( decorr_buffer_ptr_fx[0], frame_ma_fx[2 * l] ); // q_decorr - Word32 temp_1 = Mpy_32_16_1( filter_frame_real_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3 - temp_1 = L_shl( temp_1, 3 ); // q_decorr - decorr_buffer_ptr_fx[0] = L_sub( decorr_buffer_ptr_fx[0], temp_1 ); // q_deocor - decorr_buffer_ptr_fx[1] = L_add( decorr_buffer_ptr_fx[1], frame_ma_fx[add( shl( l, 1 ), 1 )] ); // q_decorr - Word32 temp_2 = Mpy_32_16_1( filter_frame_imag_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3 - temp_2 = L_shl( temp_2, 3 ); // q_decorr - decorr_buffer_ptr_fx[1] = L_sub( decorr_buffer_ptr_fx[1], temp_2 ); // q_decorr - decorr_buffer_ptr_fx += imult1616( 2, decorr_buffer_step ); - move32(); - move32(); - move32(); -#else Word32 temp_1 = Mpy_32_16_1( filter_frame_real_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3 temp_1 = L_shl( temp_1, 3 ); // q_decorr decorr_buffer_ptr_fx[0] = L_sub( L_add( decorr_buffer_ptr_fx[0], frame_ma_fx[2 * l] ), temp_1 ); // q_deocor @@ -743,7 +703,6 @@ void ivas_dirac_dec_decorr_process_fx( decorr_buffer_ptr_fx += decorr_buffer_step2x; move16(); -#endif } } } @@ -764,7 +723,6 @@ void ivas_dirac_dec_decorr_process_fx( e_direct_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); // scaling to get max precision for aux_buffer values// -#ifdef MSAN_FIX q_shift = Q31; move16(); offset = shl( max_band_decorr, 1 ); @@ -777,10 +735,6 @@ void ivas_dirac_dec_decorr_process_fx( { scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], offset, q_shift ); } -#else - q_shift = L_norm_arr( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels ); - Scale_sig32( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels, q_shift ); -#endif q_frame_f = add( q_frame_f, q_shift ); @@ -802,24 +756,8 @@ void ivas_dirac_dec_decorr_process_fx( q_direct_energy = q_aux_buffer; move16(); -#ifdef FIX_1110_OPTIM_DIRAC_DECORR_PROC /* Attention: this loop reports norm=0, whenever any data is 0. */ /* Therefore, useful left-shifts are skipped, accuracy is lost. */ -#endif -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - /* calculate the power of the decorrelated signal */ - FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) - { - offset1 = shl( imult1616( ch_idx, num_freq_bands ), 1 ); - offset2 = shl( imult1616( ch_idx, max_band_decorr ), 1 ); - FOR( Word16 i = 0; i < 2 * max_band_decorr; i++ ) - { - aux_64[add( offset2, i )] = W_mult0_32_32( frame_dec_fx[add( offset1, i )], frame_dec_fx[add( offset1, i )] ); - move64(); - norm = s_min( norm, W_norm( aux_64[add( offset2, i )] ) ); - } - } -#else /* calculate the power of the decorrelated signal */ Word64 *m64_aux = aux_64; move32(); @@ -849,7 +787,6 @@ void ivas_dirac_dec_decorr_process_fx( move32(); } norm = W_norm( min64 ); -#endif norm = sub( norm, 1 /*find_guarded_bits_fx( 2 )*/ ); FOR( Word16 i = 0; i < 2 * num_channels * max_band_decorr; i++ ) { @@ -866,34 +803,6 @@ void ivas_dirac_dec_decorr_process_fx( /* smooth energies */ -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - v_multc_fixed( aux_buffer_fx, ONE_M_DIRAC_DUCK_ALPHA, aux_buffer_fx, imult1616( num_channels, max_band_decorr ) ); // q_aux_buffer - - v_multc_fixed( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, DIRAC_DUCK_ALPHA_FX, h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ) ); // same-q - - v_add_fixed_me( aux_buffer_fx, sub( 31, q_aux_buffer ), h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, e_reverb_energy_smooth, h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, &e_reverb_energy_smooth, imult1616( num_channels, max_band_decorr ), 0 ); - h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = sub( 31, e_reverb_energy_smooth ); - - v_multc_fixed( direct_energy_fx, ONE_M_DIRAC_DUCK_ALPHA, direct_energy_fx, imult1616( num_protos_dir, max_band_decorr ) ); // same q - - v_multc_fixed( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, DIRAC_DUCK_ALPHA_FX, h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ) ); // same q - - v_add_fixed_me( direct_energy_fx, sub( 31, q_direct_energy ), h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, e_direct_energy_smooth, h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, &e_direct_energy_smooth, imult1616( num_protos_dir, max_band_decorr ), 0 ); - h_freq_domain_decorr_ap_state->q_direct_energy_smooth = sub( 31, e_direct_energy_smooth ); - move16(); - - // scaling energy buffers for better precision for higher values// - q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ) ); - Scale_sig32( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ), q_shift ); - h_freq_domain_decorr_ap_state->q_direct_energy_smooth = add( h_freq_domain_decorr_ap_state->q_direct_energy_smooth, q_shift ); - move16(); - - - q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ) ); - Scale_sig32( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ), q_shift ); - h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = add( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, q_shift ); - move16(); -#else Word16 len = imult1616( num_channels, max_band_decorr ); Word16 aux_e = sub( 31, q_aux_buffer ); Word16 max_e = s_max( aux_e, e_reverb_energy_smooth ); @@ -950,13 +859,11 @@ void ivas_dirac_dec_decorr_process_fx( } h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); h_freq_domain_decorr_ap_state->q_direct_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); -#endif e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); e_direct_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); // this step is b/c we are left shifting frame_dec_fx at the end of below for loop/ -#ifdef MSAN_FIX q_shift = Q31; move16(); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) @@ -969,10 +876,6 @@ void ivas_dirac_dec_decorr_process_fx( { Scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift ); } -#else - q_shift = sub( L_norm_arr( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels ), 2 ); - Scale_sig32( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels, q_shift ); -#endif q_frame_f = add( q_frame_f, q_shift ); FOR( ch_idx = 0; ch_idx < num_channels; ch_idx++ ) @@ -1006,13 +909,8 @@ void ivas_dirac_dec_decorr_process_fx( duck_gain = shl( duck_gain, sub( e_duck_gain, 1 ) ); // Q14 -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 1 ); // q_frame_f - frame_dec_fx_ptr[add( shl( band_idx, 1 ), 1 )] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[add( shl( band_idx, 1 ), 1 )], duck_gain ), 1 ); // q_frame_f -#else frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 1 ); // q_frame_f frame_dec_fx_ptr[2 * band_idx + 1] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx + 1], duck_gain ), 1 ); // q_frame_f -#endif move32(); move32(); } @@ -1029,13 +927,8 @@ void ivas_dirac_dec_decorr_process_fx( } */ duck_gain = shl_sat( duck_gain, sub( e_duck_gain, 1 ) ); // Q14 -#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC - frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 2 ); // q_frame_dec - frame_dec_fx_ptr[add( shl( band_idx, 1 ), 1 )] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[add( shl( band_idx, 1 ), 1 )], duck_gain ), 2 ); // q_frame_dec -#else frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 1 ); // q_frame_dec frame_dec_fx_ptr[2 * band_idx + 1] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx + 1], duck_gain ), 1 ); // q_frame_dec -#endif move32(); move32(); } @@ -1061,27 +954,19 @@ void ivas_dirac_dec_decorr_process_fx( q_shift = sf; move16(); // scaling it to sf -#ifdef MSAN_FIX FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift ); } -#else - Scale_sig32( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels, q_shift ); // scaling it to input q -#endif q_frame_f = add( q_frame_f, sf ); } ELSE IF( q_shift < 0 ) { // scaling it to input q -#ifdef MSAN_FIX FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift ); } -#else - Scale_sig32( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels, q_shift ); // scaling it to input q -#endif q_frame_f = q_input_frame; q_if_local = 0; move16(); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 1b4ee91b20b3edc92728aad7dcf97d6766a8c469..7b446a80e77b5a241d8c5d5494857461f6d1f885 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -305,8 +305,15 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } set32_fx( dirac_output_synthesis_state->reference_power_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); +#ifdef FIX_867_CLDFB_NRG_SCALE + dirac_output_synthesis_state->reference_power_smooth_prev_q[0] = Q31; + dirac_output_synthesis_state->reference_power_smooth_prev_q[1] = Q31; + move16(); + move16(); +#else dirac_output_synthesis_state->reference_power_smooth_prev_q = Q31; move16(); +#endif IF( ( dirac_output_synthesis_state->direction_smoothness_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { @@ -487,8 +494,15 @@ void ivas_dirac_dec_output_synthesis_init_fx( IF( h_dirac_output_synthesis_state->proto_power_smooth_prev_fx != NULL ) { set32_fx( h_dirac_output_synthesis_state->proto_power_smooth_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ) ); +#ifdef FIX_867_CLDFB_NRG_SCALE + h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] = Q31; + h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] = Q31; + move16(); + move16(); +#else h_dirac_output_synthesis_state->proto_power_smooth_prev_q = Q31; move16(); +#endif } set32_fx( h_dirac_output_synthesis_state->gains_dir_prev_fx, 0, size ); h_dirac_output_synthesis_state->gains_dir_prev_q = 0; @@ -623,9 +637,13 @@ void ivas_dirac_dec_output_synthesis_close_fx( *------------------------------------------------------------------------*/ void ivas_dirac_dec_output_synthesis_process_slot_fx( - const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ + const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ +#ifdef FIX_867_CLDFB_NRG_SCALE + const Word16 *q_reference_power, /* i : Estimated power Q */ +#else const Word16 q_reference_power, /* i : Estimated power Q */ - const Word32 *onset, /* i : onset filter Q31*/ +#endif + const Word32 *onset, /* i : onset filter Q31*/ const Word16 *azimuth, const Word16 *elevation, const Word32 *diffuseness, /* Q(q_diffuseness)*/ @@ -904,6 +922,74 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ +#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot + FOR( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses + move32(); + IF( reference_power[k + num_freq_bands] == 0 ) + { + sqr_inp = Mpy_32_32( diffuseness[k], c ); + sqr_exp = sub( 31 + 4, q_diffuseness ); + } + ELSE + { + Word16 diff_c_exp; + Word16 diff_aab_exp; + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) + { + mpy_a_a_b = Mpy_32_32( a, a ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + diff_aab_exp = sub( 31 + 62, add( h_dirac_output_synthesis_state->direct_responses_q, add( h_dirac_output_synthesis_state->direct_responses_q, q_diffuseness ) ) ); + diff_c_exp = sub( 31 + 4, q_diffuseness ); + + sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, diff_c_exp, mpy_diff_aab, diff_aab_exp, &sqr_exp ); /*q(31-sqr_exp)*/ + } + ELSE + { + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + diff_aab_exp = sub( sub( add( sub( 31 + 62, h_dirac_output_synthesis_state->direct_responses_q ), b_exp ), h_dirac_output_synthesis_state->direct_responses_q ), q_diffuseness ); + diff_c_exp = sub( 31 + 4, q_diffuseness ); + + sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, diff_c_exp, mpy_diff_aab, diff_aab_exp, &sqr_exp ); /*q(31-sqr_exp)*/ + } + } + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + + + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + move16(); + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); + } + } +#else FOR( ; k < num_freq_bands; k++ ) { a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses @@ -934,7 +1020,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 - q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 15, b_exp ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + q_diff_aab = add( add( h_dirac_output_synthesis_state->direct_responses_q, sub( sub( 15, b_exp ), 15 ) ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); q_diff_c = sub( q_diffuseness, 4 ); test(); @@ -985,6 +1071,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } +#endif } ELSE { @@ -1079,7 +1166,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { -#ifdef FIX_1072_SPEEDUP_gainpanning /*is there any difference in any bitstream?*/ Word16 temp_q1 = sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { @@ -1088,17 +1174,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); -#else - FOR( Word16 kk = 0; kk < tmp16; kk++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ - move32(); - } - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; - move16(); -#endif } -#ifdef FIX_1072_SPEEDUP_gainpanning Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { @@ -1108,11 +1184,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word32 aux; IF( temp_q1 < 0 ) { -#ifdef FIX_USAN_ISSUES Word32 temp_q1_equiv = L_lshl( (Word32) 0x80000000, temp_q1 ); -#else - Word32 temp_q1_equiv = L_lshl( 0x80000000, temp_q1 ); -#endif FOR( i = 0; i < num_freq_bands; i++ ) { aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); @@ -1142,25 +1214,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } -#else - FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult_fixed( h_dirac_output_synthesis_state->direct_power_factor_fx, - &h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); /*temp_q*/ - - IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) - { - Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ - } - - v_add_fixed( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], - num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ - } -#endif /*Diffuse gain*/ FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) @@ -1209,7 +1262,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( hDirACRend->proto_index_diff, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power, +#ifdef FIX_867_CLDFB_NRG_SCALE + q_reference_power, +#else &q_reference_power, +#endif h_dirac_output_synthesis_state->diffuse_responses_square_fx, onset, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, @@ -1222,9 +1279,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( /* process other PSDs only slot wise for 4 transport channels */ IF( EQ_16( dec_param_estim, TRUE ) ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + computeTargetPSDs_direct_fx( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_state->direct_power_factor_fx, reference_power, q_reference_power, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); + + computeTargetPSDs_diffuse_fx( num_channels_dir, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power, q_reference_power, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#else computeTargetPSDs_direct_fx( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_state->direct_power_factor_fx, reference_power, &q_reference_power, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); computeTargetPSDs_diffuse_fx( num_channels_dir, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power, &q_reference_power, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#endif } return; @@ -1987,6 +2050,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); +#ifndef FIX_867_CLDFB_NRG_SCALE // Scale cy_auto_diff_smooth_fx if required IF( diff_start_band != 0 ) { @@ -2004,6 +2068,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = q_com; move16(); } +#endif computeTargetPSDs_diffuse_subframe_fx( nchan_target_psds, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor_fx, @@ -2138,6 +2203,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( prevWeight = Mpy_32_32( L_sub( ONE_IN_Q31, DIRECTION_SMOOTHNESS_ALPHA_Q31 ), h_dirac_output_synthesis_state->reference_power_smooth_prev_fx[l] ); //(Q31, q_reference_power_smooth) -> q_reference_power_smooth +#ifdef FIX_867_CLDFB_NRG_SCALE + assert( q_reference_power_smooth[0] == h_dirac_output_synthesis_state->reference_power_smooth_prev_q[0] ); + assert( q_reference_power_smooth[1] == h_dirac_output_synthesis_state->reference_power_smooth_prev_q[1] ); +#else + assert( *q_reference_power_smooth == h_dirac_output_synthesis_state->reference_power_smooth_prev_q ); +#endif weightedDirectionSmoothness = L_add( Mpy_32_32( currWeight, instDirectionSmoothness ), Mpy_32_32( prevWeight, h_dirac_output_synthesis_state->direction_smoothness_prev_fx[l] ) ); //(q_reference_power_smooth, Q31) -> q_reference_power_smooth @@ -2145,6 +2216,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( exp = 0; move16(); + tmp = BASOP_Util_Divide3232_Scale( weightedDirectionSmoothness, L_add( sumWeight, EPSILON_FX ), &exp ); /*Q(15-exp)*/ smoothedDirectionSmoothness = L_shl_sat( L_deposit_l( tmp ), add( sub( Q31, Q15 ), exp ) ); // Q31 @@ -2187,6 +2259,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_power_smooth_prev ) = L_add( *( p_power_smooth_prev ), Mpy_32_32( g1, ( *p_power_smooth ) ) ); //(Q31, q_proto_power_smooth) -> q_proto_power_smooth move32(); +#ifdef FIX_867_CLDFB_NRG_SCALE + assert( h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] == h_dirac_output_synthesis_state->proto_power_smooth_q[0] ); + assert( h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] == h_dirac_output_synthesis_state->proto_power_smooth_q[1] ); +#else + assert( h_dirac_output_synthesis_state->proto_power_smooth_prev_q == h_dirac_output_synthesis_state->proto_power_smooth_q ); +#endif IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) ) { p_power_smooth_prev++; @@ -2210,6 +2288,61 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } // Move proto_power_smooth_fx to common Q-factor + +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 min_exp2 = -64; + min_exp = MIN_16; + move16(); + move16(); + Word16 q_tmp2 = Q31; + q_tmp = Q31; + move16(); + move16(); + + FOR( k = 0; k < num_protos_dir; k++ ) + { + FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ ) + { + min_exp = s_max( min_exp, exp_arr[k * num_freq_bands + l] ); + } + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + min_exp2 = s_max( min_exp2, exp_arr[k * num_freq_bands + l] ); + } + } + + p_power_smooth = h_dirac_output_synthesis_state->proto_power_smooth_fx; + + FOR( k = 0; k < num_protos_dir; k++ ) + { + FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ ) + { + *p_power_smooth = L_shr( *p_power_smooth, sub( min_exp, exp_arr[k * num_freq_bands + l] ) ); /*(31-(exp-(31-q_proto_power_smooth)))->(31-(min_exp-(31-q_proto_power_smooth)))*/ + move32(); + p_power_smooth++; + } + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + *p_power_smooth = L_shr( *p_power_smooth, sub( min_exp2, exp_arr[k * num_freq_bands + l] ) ); /*(31-(exp-(31-q_proto_power_smooth)))->(31-(min_exp-(31-q_proto_power_smooth)))*/ + move32(); + p_power_smooth++; + } + } + + // Update the Q-factor + h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] = s_min( h_dirac_output_synthesis_state->proto_power_smooth_q[0], h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] ); + h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] = s_min( h_dirac_output_synthesis_state->proto_power_smooth_q[1], h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] ); + move16(); + move16(); + + q_tmp = add( sub( Q31, min_exp ), sub( Q31, h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] ) ); + q_tmp2 = add( sub( Q31, min_exp2 ), sub( Q31, h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] ) ); + + h_dirac_output_synthesis_state->proto_power_smooth_q[0] = q_tmp; + h_dirac_output_synthesis_state->proto_power_smooth_q[1] = q_tmp2; + move16(); + move16(); +#else min_exp = MIN_16; move16(); q_tmp = Q31; @@ -2246,6 +2379,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); h_dirac_output_synthesis_state->proto_power_smooth_q = q_tmp; move16(); +#endif /*Direct gains and diffuse gains on number of output channels*/ p_power_diff_smooth_prev = h_dirac_output_synthesis_state->proto_power_diff_smooth_prev_fx; @@ -2293,6 +2427,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( FOR( k = 0; k < nchan_out_woLFE; k++ ) { Word32 power_smooth_temp; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx; +#endif p_power_smooth = h_dirac_output_synthesis_state->proto_power_smooth_fx + i_mult( proto_direct_index[k], num_freq_bands ); // q_proto_power_smooth FOR( l = 0; l < h_dirac_output_synthesis_params->max_band_decorr; l++ ) { @@ -2300,18 +2437,28 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( g1 = alpha[l]; // Q31 move32(); g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 + assert( q_cy_auto_dir_smooth_local[k] == q_cy_auto_dir_smooth_prev_local[k] ); *( p_cy_auto_dir_smooth_prev ) = L_add( Mpy_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ), Mpy_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); // (Q31, q_cy_auto_dir_smooth_prev_local) -> q_cy_auto_dir_smooth_prev_local move32(); + assert( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth == h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev ); *( p_cy_cross_dir_smooth_prev ) = L_add( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ), Mpy_32_32( g2, ( *( p_cy_cross_dir_smooth_prev ) ) ) ); // (Q31, q_cy_cross_dir_smooth_prev) -> q_cy_cross_dir_smooth_prev move32(); power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) L_tmp = Mpy_32_32( power_smooth_temp, ( *( p_cy_auto_dir_smooth_prev++ ) ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 +#ifdef FIX_867_CLDFB_NRG_SCALE + qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q[qidx], norm_l( *p_power_smooth ) ), + q_cy_auto_dir_smooth_prev_local[k] ), + Q31 ) ); + +#else exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), q_cy_auto_dir_smooth_prev_local[k] ), Q31 ) ); +#endif p_power_smooth++; *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) @@ -2395,9 +2542,16 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( ( p_cy_cross_dir_smooth++ ); power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); L_tmp = Mpy_32_32( power_smooth_temp, L_tmp ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 +#ifdef FIX_867_CLDFB_NRG_SCALE + qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q[qidx], norm_l( *p_power_smooth ) ), + add( q_cy_auto_dir_smooth_prev_local[k], q_tmp ) ), + Q31 ) ); +#else exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), add( q_cy_auto_dir_smooth_prev_local[k], q_tmp ) ), Q31 ) ); +#endif *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) move32(); @@ -2446,9 +2600,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); } ( p_cy_auto_diff_smooth_prev++ ); +#ifdef FIX_867_CLDFB_NRG_SCALE + exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q[qidx], norm_l( *p_power_smooth ) ), + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ), + Q31 ) ); +#else exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ), Q31 ) ); +#endif p_power_smooth++; *( p_gains_diff ) = Sqrt32( L_tmp, &exp ); /*31-exp*/ @@ -3045,11 +3205,19 @@ void ivas_dirac_dec_compute_directional_responses_fx( } ELSE { +#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx + ivas_dirac_dec_get_response_fx_29( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order ); +#else ivas_dirac_dec_get_response_fx( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_hoa ); +#endif IF( hodirac_flag ) { +#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx + ivas_dirac_dec_get_response_fx_29( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order ); +#else ivas_dirac_dec_get_response_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); +#endif } } @@ -3913,21 +4081,36 @@ static void computeTargetPSDs_direct_fx( /* estimate direct and diffuse power */ v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 common1_q = s_min( *q_cy_auto_dir_smooth, s_min( q_reference_power[0], q_reference_power[1] ) ); + Word16 common2_q = s_min( *q_cy_cross_dir_smooth, s_min( q_reference_power[0], q_reference_power[1] ) ); +#else Word16 common1_q = s_min( *q_cy_auto_dir_smooth, *q_reference_power ); Word16 common2_q = s_min( *q_cy_cross_dir_smooth, *q_reference_power ); +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); - v_mult_fixed( direct_power, &direct_responses_square[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - scale_sig32( aux_buffer_res, num_freq_bands, sub( common1_q, *q_reference_power ) ); /* Q(common1_q) */ + v_mult_fixed( direct_power, &direct_responses_square[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifdef FIX_867_CLDFB_NRG_SCALE + scale_sig32( aux_buffer_res, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( common1_q, q_reference_power[0] ) ); /* Q(common1_q) */ + scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( common1_q, q_reference_power[1] ) ); /* Q(common1_q) */ +#else + scale_sig32( aux_buffer_res, num_freq_bands, sub( common1_q, *q_reference_power ) ); /* Q(common1_q) */ +#endif scale_sig32( &cy_auto_dir_smooth[cur_idx], num_freq_bands, sub( common1_q, *q_cy_auto_dir_smooth ) ); /* Q(common1_q) */ v_add_fixed( &cy_auto_dir_smooth[cur_idx], aux_buffer_res, &cy_auto_dir_smooth[cur_idx], num_freq_bands, Q1 ); /* Q(common1_q) - Q1 */ - v_mult_fixed( direct_power, &direct_responses[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - scale_sig32( aux_buffer_res, num_freq_bands, sub( common2_q, *q_reference_power ) ); /* Q(common2_q) */ + v_mult_fixed( direct_power, &direct_responses[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifdef FIX_867_CLDFB_NRG_SCALE + scale_sig32( aux_buffer_res, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( common2_q, q_reference_power[0] ) ); /* Q(common2_q) */ + scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( common2_q, q_reference_power[1] ) ); /* Q(common2_q) */ +#else + scale_sig32( aux_buffer_res, num_freq_bands, sub( common2_q, *q_reference_power ) ); /* Q(common2_q) */ +#endif scale_sig32( &cy_cross_dir_smooth[cur_idx], num_freq_bands, sub( common2_q, *q_cy_cross_dir_smooth ) ); /* Q(common2_q) */ v_add_fixed( &cy_cross_dir_smooth[cur_idx], aux_buffer_res, &cy_cross_dir_smooth[cur_idx], num_freq_bands, Q1 ); /* Q(common2_q) - Q1 */ } @@ -3955,14 +4138,21 @@ static void computeTargetPSDs_direct_subframe_fx( Word32 *cy_cross_dir_smooth, /*q_cy_cross_dir_smooth*/ Word16 *q_cy_cross_dir_smooth ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 ch_idx, cur_idx, q_tmp; + Word32 L_tmp[CLDFB_NO_CHANNELS_MAX]; + Word16 q_cy_auto_dir_smooth_local[2]; +#else Word16 ch_idx, cur_idx, i, q_tmp; Word64 W_tmp[CLDFB_NO_CHANNELS_MAX], W_max; set64_fx( W_tmp, 0, CLDFB_NO_CHANNELS_MAX ); +#endif /* segment auxiliary buffer */ Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ /* estimate direct and diffuse power */ +#ifndef FIX_867_CLDFB_NRG_SCALE FOR( i = 0; i < num_freq_bands; i++ ) { direct_power[i] = Mpy_32_32( direct_power_factor[i], reference_power[i] ); @@ -3974,11 +4164,15 @@ static void computeTargetPSDs_direct_subframe_fx( move32(); } } +#else + v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands ); +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); +#ifndef FIX_867_CLDFB_NRG_SCALE W_max = 0; move64(); FOR( i = 0; i < num_freq_bands; i++ ) @@ -3991,6 +4185,21 @@ static void computeTargetPSDs_direct_subframe_fx( } } q_tmp = W_norm( W_max ); +#ifdef FIX_867_CLDFB_NRG_SCALE + FOR( i = 0; i < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); i++ ) + { + cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power[0]+q_tmp*/ + move32(); + } + Word16 q_tmp2 = sub( q_tmp, sub( q_reference_power[1], q_reference_power[0] ) ); + FOR( i = CLDFB_NO_CHANNELS_HALF; i < num_freq_bands; i++ ) + { + cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp2 ) ); /*q_reference_power[1]+q_tmp*/ + move32(); + } + q_cy_auto_dir_smooth[ch_idx] = add( q_reference_power[0], q_tmp ); + move16(); +#else FOR( i = 0; i < num_freq_bands; i++ ) { cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power+q_tmp*/ @@ -3998,11 +4207,34 @@ static void computeTargetPSDs_direct_subframe_fx( } q_cy_auto_dir_smooth[ch_idx] = add( *q_reference_power, q_tmp ); move16(); +#endif +#else + q_tmp = L_norm_arr( &direct_responses_square[cur_idx], num_freq_bands ); + Copy_Scale_sig32( &direct_responses_square[cur_idx], L_tmp, num_freq_bands, q_tmp ); + v_mult_fixed( direct_power, L_tmp, &cy_auto_dir_smooth[cur_idx], num_freq_bands ); // (q_reference_power, q_tmp) -> q_reference_power + q_tmp + + q_cy_auto_dir_smooth_local[0] = add( add( q_reference_power[0], q_tmp ), L_norm_arr( cy_auto_dir_smooth + cur_idx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + q_cy_auto_dir_smooth_local[1] = add( add( q_reference_power[1], q_tmp ), L_norm_arr( cy_auto_dir_smooth + cur_idx + CLDFB_NO_CHANNELS_HALF, s_max( sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 0 ) ) ); + q_cy_auto_dir_smooth[ch_idx] = s_min( q_cy_auto_dir_smooth_local[0], q_cy_auto_dir_smooth_local[1] ); + move16(); + + Scale_sig32( cy_auto_dir_smooth + cur_idx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_cy_auto_dir_smooth[ch_idx], add( q_reference_power[0], q_tmp ) ) ); + Scale_sig32( cy_auto_dir_smooth + cur_idx + CLDFB_NO_CHANNELS_HALF, s_max( sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 0 ), sub( q_cy_auto_dir_smooth[ch_idx], add( q_reference_power[1], q_tmp ) ) ); + +#endif v_mult_fixed( direct_power, &direct_responses[cur_idx], &cy_cross_dir_smooth[cur_idx], num_freq_bands ); // (q_reference_power, Q31) -> q_reference_power +#ifdef FIX_867_CLDFB_NRG_SCALE + Scale_sig32( &cy_cross_dir_smooth[cur_idx] + CLDFB_NO_CHANNELS_HALF, s_max( sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), 0 ), sub( q_reference_power[0], q_reference_power[1] ) ); +#endif } +#ifdef FIX_867_CLDFB_NRG_SCALE + *q_cy_cross_dir_smooth = q_reference_power[0]; + move16(); +#else *q_cy_cross_dir_smooth = *q_reference_power; move16(); +#endif return; } @@ -4028,15 +4260,24 @@ static void computeTargetPSDs_diffuse_fx( /* estimate direct and diffuse power */ v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 common_q = s_min( *q_cy_auto_diff_smooth, s_min( q_reference_power[0], q_reference_power[1] ) ); +#else Word16 common_q = s_min( *q_cy_auto_diff_smooth, *q_reference_power ); +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); - v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - scale_sig32( aux_buffer_res, sub( num_freq_bands, start_band ), sub( common_q, *q_reference_power ) ); /* Q(common_q) */ + v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifdef FIX_867_CLDFB_NRG_SCALE + scale_sig32( aux_buffer_res, s_min( sub( num_freq_bands, start_band ), CLDFB_NO_CHANNELS_HALF ), sub( common_q, q_reference_power[0] ) ); /* Q(common_q) */ + scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( sub( num_freq_bands, start_band ), CLDFB_NO_CHANNELS_HALF ) ), sub( common_q, q_reference_power[1] ) ); /* Q(common_q) */ +#else + scale_sig32( aux_buffer_res, sub( num_freq_bands, start_band ), sub( common_q, *q_reference_power ) ); /* Q(common_q) */ +#endif scale_sig32( &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), sub( common_q, *q_cy_auto_diff_smooth ) ); /* Q(common_q) */ v_add_fixed( &cy_auto_diff_smooth[cur_idx + start_band], aux_buffer_res, &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), Q1 ); /* Q(common_q) - Q1 */ } @@ -4062,20 +4303,46 @@ static void computeTargetPSDs_diffuse_subframe_fx( { Word16 ch_idx, cur_idx; Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* segment auxiliary buffer; size: num_freq_bands. */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 q_cy_auto_diff_smooth_new, q_diffuse_power; +#endif /* estimate direct and diffuse power */ v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); // (Q31, q_reference_power) -> q_reference_power +#ifdef FIX_867_CLDFB_NRG_SCALE + q_diffuse_power = s_min( q_reference_power[0], q_reference_power[1] ); + Scale_sig32( diffuse_power, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_diffuse_power, q_reference_power[0] ) ); + Scale_sig32( diffuse_power + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_diffuse_power, q_reference_power[1] ) ); + q_cy_auto_diff_smooth_new = q_diffuse_power; + IF( LT_16( *q_cy_auto_diff_smooth, q_diffuse_power ) ) + { + Scale_sig32( diffuse_power, num_freq_bands, sub( *q_cy_auto_diff_smooth, q_cy_auto_diff_smooth_new ) ); + q_cy_auto_diff_smooth_new = *q_cy_auto_diff_smooth; + move16(); + } +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( GT_16( *q_cy_auto_diff_smooth, q_diffuse_power ) ) + { + Scale_sig32( &cy_auto_diff_smooth[cur_idx], start_band, sub( q_diffuse_power, *q_cy_auto_diff_smooth ) ); + } +#endif v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power } +#ifdef FIX_867_CLDFB_NRG_SCALE + *q_cy_auto_diff_smooth = q_cy_auto_diff_smooth_new; + move16(); +#else *q_cy_auto_diff_smooth = *q_reference_power; move16(); +#endif return; } @@ -4099,14 +4366,23 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( /* segment auxiliary buffer */ Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 q_common, q_reference_power_min_one[2]; + q_reference_power_min_one[0] = sub( q_reference_power[0], Q1 ); + q_reference_power_min_one[1] = sub( q_reference_power[1], Q1 ); +#else Word16 q_common, q_reference_power_min_one; q_reference_power_min_one = sub( *q_reference_power, Q1 ); +#endif /* estimate direct and diffuse power */ v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_decorr_freq_bands ); // (Q31, q_reference_power) -> q_reference_power +#ifdef FIX_867_CLDFB_NRG_SCALE + q_common = s_min( *q_cy_auto_diff_smooth, s_min( q_reference_power_min_one[0], q_reference_power_min_one[1] ) ); +#else IF( GT_16( *q_cy_auto_diff_smooth, q_reference_power_min_one ) ) { q_common = q_reference_power_min_one; @@ -4117,6 +4393,7 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( q_common = *q_cy_auto_diff_smooth; move16(); } +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) @@ -4133,6 +4410,22 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, Q1 ); // Q30 v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( NE_16( q_common, q_reference_power_min_one[0] ) ) + { + scale_sig32( aux_buffer_res, s_min( num_decorr_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_common, q_reference_power_min_one[0] ) ); // q_common + } + IF( NE_16( q_common, q_reference_power_min_one[1] ) ) + { + scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_decorr_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_common, q_reference_power_min_one[1] ) ); // q_common + } + IF( NE_16( q_common, *q_cy_auto_diff_smooth ) ) + { + scale_sig32( &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, sub( q_common, *q_cy_auto_diff_smooth ) ); // q_common + } + v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_common - Q1) + scale_sig32( &cy_auto_diff_smooth[cur_idx + num_decorr_freq_bands], sub( num_freq_bands, num_decorr_freq_bands ), sub( sub( q_common, Q1 ), *q_cy_auto_diff_smooth ) ); // (q_common - Q1) +#else IF( NE_16( q_common, q_reference_power_min_one ) ) { scale_sig32( aux_buffer_res, num_decorr_freq_bands, sub( q_common, q_reference_power_min_one ) ); // q_common @@ -4143,6 +4436,7 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( } v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_common - Q1) scale_sig32( &cy_auto_diff_smooth[cur_idx + num_decorr_freq_bands], sub( num_freq_bands, num_decorr_freq_bands ), sub( sub( q_common, Q1 ), *q_cy_auto_diff_smooth ) ); // (q_common - Q1) +#endif } /* Q adjustment */ diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 4e0d3ab71e1f9eba35f4b6b6f05e73752ca4f5cf..f67f3761bee66257e79a5fc22dce5e97b9af76c5 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -778,17 +778,26 @@ ivas_error ivas_dirac_alloc_mem_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef MSAN_FIX set_zero_fx( hDirAC_mem->frame_dec_f_fx, 2 * num_outputs_diff * num_freq_bands ); -#endif hDirAC_mem->frame_dec_f_len = imult1616( imult1616( 2, num_outputs_diff ), num_freq_bands ); } } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx = hDirAC_mem->proto_power_smooth_fx; +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = Q31; + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = Q31; + move16(); + move16(); + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = Q31; + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = Q31; + move16(); + move16(); +#else hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = Q31; move16(); hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = Q31; move16(); +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx = hDirAC_mem->proto_power_diff_smooth_fx; hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = hDirAC_mem->proto_power_diff_smooth_q; move16(); @@ -813,12 +822,7 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len = size_ho; move16(); -#ifdef MSAN_FIX set_zero_fx( hDirAC_mem->cy_cross_dir_smooth_fx, size_ho ); -#else - set_zero_fx( hDirAC_mem->cy_cross_dir_smooth_fx, size ); - hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len = size_ho; -#endif IF( NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { @@ -870,9 +874,7 @@ ivas_error ivas_dirac_alloc_mem_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = imult1616( imult1616( 2 * MAX_PARAM_SPATIAL_SUBFRAMES, num_protos_dir ), num_freq_bands ); -#ifdef MSAN_FIX set_zero_fx( hDirAC_mem->proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len ); -#endif move16(); hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q = Q31; move16(); @@ -896,9 +898,7 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirAC_mem->proto_diffuse_buffer_f_len = imult1616( imult1616( 2 * MAX_PARAM_SPATIAL_SUBFRAMES, num_outputs_diff ), num_freq_bands ); } -#ifdef MSAN_FIX set_zero_fx( hDirAC_mem->proto_diffuse_buffer_f_fx, hDirAC_mem->proto_diffuse_buffer_f_len ); -#endif } } hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx = hDirAC_mem->proto_direct_buffer_f_fx; @@ -951,19 +951,28 @@ ivas_error ivas_dirac_alloc_mem_fx( hDirAC_mem->reference_power_len = imult1616( 2, num_freq_bands ); move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirAC_mem->reference_power_q[0] = Q31; + hDirAC_mem->reference_power_q[1] = Q31; + move16(); + move16(); + hDirAC_mem->reference_power_smooth_q[0] = Q31; + hDirAC_mem->reference_power_smooth_q[1] = Q31; + move16(); + move16(); +#else hDirAC_mem->reference_power_q = Q31; move16(); hDirAC_mem->reference_power_smooth_q = Q31; move16(); +#endif IF( hDirACRend->proto_signal_decorr_on ) { IF( ( hDirAC_mem->onset_filter_fx = (Word32 *) malloc( sizeof( Word32 ) * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef MSAN_FIX set_zero_fx( hDirAC_mem->onset_filter_fx, imult1616( num_outputs_diff, num_freq_bands ) ); -#endif } } } @@ -985,9 +994,7 @@ ivas_error ivas_dirac_alloc_mem_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } -#ifdef MSAN_FIX set_zero_fx( hDirAC_mem->onset_filter_fx, imult1616( 2, num_freq_bands ) ); -#endif } } @@ -1481,8 +1488,14 @@ void protoSignalComputation_shd_fx( *proto_direct_buffer_f_q = add( q_cldfb, min_q_shift ); move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + reference_power_q[qidx] = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); + move16(); +#else *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); move16(); +#endif Word16 shift = sub( *proto_direct_buffer_f_q, q_cldfb ); FOR( k = 1; k < 4; k++ ) @@ -1517,8 +1530,15 @@ void protoSignalComputation_shd_fx( } *proto_direct_buffer_f_q = q_cldfb; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_q[0] = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + reference_power_q[1] = reference_power_q[0]; + move16(); + move16(); +#else *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); +#endif } /* Additional transport channels = planar SBA components of degree higher than 1*/ @@ -1580,7 +1600,11 @@ void protoSignalComputation1_fx( { Word16 l, k, idx; Word32 *p_proto_buffer_fx; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 proto_power_smooth_fx_q[2], min_q_shift, q_shift; +#else Word16 proto_power_smooth_fx_q, min_q_shift, q_shift; +#endif Word32 re, im; min_q_shift = Q31; @@ -1603,17 +1627,48 @@ void protoSignalComputation1_fx( q_shift = sub( q_shift, find_guarded_bits_fx( 2 ) ); Scale_sig32( proto_power_smooth_fx, num_freq_bands, q_shift ); /*proto_power_smooth_q+q_shift*/ +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_q[0] = add( proto_power_smooth_q[0], q_shift ); + proto_power_smooth_q[1] = add( proto_power_smooth_q[1], q_shift ); + proto_power_smooth_fx_q[0] = proto_power_smooth_q[0]; + proto_power_smooth_fx_q[1] = proto_power_smooth_q[1]; + move16(); + move16(); +#else *proto_power_smooth_q = add( *proto_power_smooth_q, q_shift ); proto_power_smooth_fx_q = *proto_power_smooth_q; move16(); +#endif FOR( l = 0; l < num_freq_bands; l++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); +#endif re = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift im = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift reference_power_fx[l] = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 move32(); +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_q[qidx] = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + move16(); + + IF( LT_16( reference_power_q[qidx], proto_power_smooth_q[qidx] ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( proto_power_smooth_q[qidx], reference_power_q[qidx] ) ), reference_power_fx[l] ); // reference_power_q + move32(); + proto_power_smooth_fx_q[qidx] = reference_power_q[qidx]; + move16(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( reference_power_fx[l], sub( reference_power_q[qidx], proto_power_smooth_q[qidx] ) ) ); // proto_power_smooth_q + move32(); + proto_power_smooth_fx_q[qidx] = proto_power_smooth_q[qidx]; + move16(); + } +#else *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); @@ -1631,6 +1686,7 @@ void protoSignalComputation1_fx( proto_power_smooth_fx_q = *proto_power_smooth_q; move16(); } +#endif idx = 2 * l; p_proto_buffer_fx[idx] = RealBuffer_fx[0][0][l]; // q_cldfb @@ -1652,8 +1708,15 @@ void protoSignalComputation1_fx( move16(); *proto_direct_buffer_f_q = q_cldfb; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_q[0] = proto_power_smooth_fx_q[0]; + proto_power_smooth_q[1] = proto_power_smooth_fx_q[1]; + move16(); + move16(); +#else *proto_power_smooth_q = proto_power_smooth_fx_q; move16(); +#endif return; } @@ -1699,15 +1762,29 @@ void protoSignalComputation2_fx( Word32 a_fx, b_fx, a2_fx, b2_fx; Word16 interpolatorSpaced_fx, interpolatorDmx_fx; Word32 tempSpaced_fx, tempDmx_fx; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 q_shift, min_q_shift[2], exp, q_temp[2], temp_q_shift, q_temp2; +#else Word16 q_shift, min_q_shift, exp, q_temp, temp_q_shift, q_temp2; +#endif Word32 temp; Word64 W_tmp1, W_tmp2; Word64 reference_power_64fx[CLDFB_NO_CHANNELS_MAX]; Word16 q_reference_power_64fx; Word16 head_room, q_Left_Right_power; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 num_proto = 3; +#endif /* Calculate maximum possible shift for the buffers RealBuffer_fx and ImagBuffer_fx */ +#ifdef FIX_867_CLDFB_NRG_SCALE + min_q_shift[0] = Q31; + min_q_shift[1] = Q31; + move16(); + move16(); +#else min_q_shift = Q31; move16(); +#endif temp_q_shift = Q31; move16(); q_sum_total_ratio = Q31; @@ -1722,21 +1799,71 @@ void protoSignalComputation2_fx( /* Calculate the max shift possible for the buffers RealBuffer_fx and ImagBuffer_fx */ FOR( l = 0; l < 2; l++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ) ), L_norm_arr( ImagBuffer_fx[l][0], s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ) ) ); + min_q_shift[0] = s_min( min_q_shift[0], q_shift ); + q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0] + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ), L_norm_arr( ImagBuffer_fx[l][0] + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + min_q_shift[1] = s_min( min_q_shift[1], q_shift ); +#if ( MASA_SUM_FREQ_RANGE_BINS > CLDFB_NO_CHANNELS_HALF ) +#error MASA_SUM_FREQ_RANGE_BINS if greater than CLDFB_NO_CHANNELS_HALF, this does not work +#endif +#else q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], num_freq_bands ), L_norm_arr( ImagBuffer_fx[l][0], num_freq_bands ) ); min_q_shift = s_min( min_q_shift, q_shift ); - -#ifdef MSAN_FIX +#endif q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ), L_norm_arr( ImagBuffer_fx[l][0], s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ); -#else - q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], MASA_SUM_FREQ_RANGE_BINS ), L_norm_arr( ImagBuffer_fx[l][0], MASA_SUM_FREQ_RANGE_BINS ) ); -#endif // MSAN_FIX temp_q_shift = s_min( temp_q_shift, q_shift ); } - min_q_shift = sub( min_q_shift, 2 ); // guard bits +#ifdef FIX_867_CLDFB_NRG_SCALE + min_q_shift[0] = sub( min_q_shift[0], 2 ); // guard bits + min_q_shift[1] = sub( min_q_shift[1], 2 ); // guard bits +#else + min_q_shift = sub( min_q_shift, 2 ); // guard bits +#endif temp_q_shift = sub( temp_q_shift, 2 ); // guard bits /* Upscaling of the buffer proto_power_smooth_fx */ +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( isloudspeaker ) + { + num_proto = 3; + q_shift = L_norm_arr( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ); + q_shift = s_min( q_shift, L_norm_arr( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + q_shift = s_min( q_shift, L_norm_arr( proto_power_smooth_fx + num_freq_bands + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + scale_sig32( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + scale_sig32( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + scale_sig32( proto_power_smooth_fx + num_freq_bands + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + } + ELSE + { + num_proto = 2; + q_shift = L_norm_arr( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ); + q_shift = s_min( q_shift, L_norm_arr( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + scale_sig32( proto_power_smooth_fx, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + scale_sig32( proto_power_smooth_fx + num_freq_bands, s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + } + q_proto_power_smooth[0] = add( q_proto_power_smooth[0], sub( q_shift, 1 ) ); + move16(); + IF( isloudspeaker ) + { + q_shift = L_norm_arr( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + q_shift = s_min( q_shift, L_norm_arr( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + q_shift = s_min( q_shift, L_norm_arr( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + } + ELSE + { + q_shift = L_norm_arr( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + q_shift = s_min( q_shift, L_norm_arr( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + scale_sig32( proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + num_freq_bands, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 + } + q_proto_power_smooth[1] = add( q_proto_power_smooth[1], sub( q_shift, 1 ) ); + move16(); +#else IF( isloudspeaker ) { q_shift = getScaleFactor32( proto_power_smooth_fx, i_mult( 3, num_freq_bands ) ); @@ -1749,20 +1876,35 @@ void protoSignalComputation2_fx( } *q_proto_power_smooth = add( *q_proto_power_smooth, sub( q_shift, 1 ) ); move16(); +#endif IF( isloudspeaker ) { p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 3 ); // q_proto_direct_buffer_f +#ifdef FIX_867_CLDFB_NRG_SCALE + q_temp[0] = sub( add( add( q_cldfb, min_q_shift[0] ), add( q_cldfb, min_q_shift[0] ) ), 31 ); + q_temp[1] = sub( add( add( q_cldfb, min_q_shift[1] ), add( q_cldfb, min_q_shift[1] ) ), 31 ); +#else q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); +#endif FOR( l = 0; l < num_freq_bands; l++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift +#else re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift +#endif Real_aux_fx = L_add( re1, re2 ); // q_cldfb+min_q_shift Imag_aux_fx = L_add( im1, im2 ); // q_cldfb+min_q_shift @@ -1779,14 +1921,26 @@ void protoSignalComputation2_fx( temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -1797,14 +1951,26 @@ void protoSignalComputation2_fx( temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -1814,14 +1980,26 @@ void protoSignalComputation2_fx( move32(); temp = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + ( 2 * num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[l + ( 2 * num_freq_bands )], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l + ( 2 * num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[l + ( 2 * num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + ( 2 * num_freq_bands )] = L_add( proto_power_smooth_fx[l + ( 2 * num_freq_bands )], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l + ( 2 * num_freq_bands )] = L_add( proto_power_smooth_fx[l + ( 2 * num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -1892,19 +2070,39 @@ void protoSignalComputation2_fx( } } +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 total_shift[2], q_temp_total; + /* total_shift shift required to get common Q of sum power values */ + total_shift[0] = shl( s_max( 0, sub( min_q_shift[0], min_q_shift[1] ) ), 1 ); + total_shift[1] = shl( s_max( 0, sub( min_q_shift[1], min_q_shift[0] ) ), 1 ); + min_q_shift[0] = sub( min_q_shift[0], idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); + min_q_shift[1] = sub( min_q_shift[1], idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); + q_temp[0] = sub( add( add( q_cldfb, min_q_shift[0] ), add( q_cldfb, min_q_shift[0] ) ), 31 ); + q_temp[1] = sub( add( add( q_cldfb, min_q_shift[1] ), add( q_cldfb, min_q_shift[1] ) ), 31 ); + q_temp_total = s_min( q_temp[0], q_temp[1] ); +#else min_q_shift = sub( min_q_shift, idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); +#endif q_temp2 = sub( add( add( q_cldfb, temp_q_shift ), add( q_cldfb, temp_q_shift ) ), 31 ); head_room = 63; move16(); FOR( l = 0; l < num_freq_bands; l++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift +#else re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift +#endif W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); W_tmp2 = W_add( W_mult0_32_32( re2, re2 ), W_mult0_32_32( im2, im2 ) ); @@ -1912,14 +2110,30 @@ void protoSignalComputation2_fx( head_room = s_min( head_room, W_norm( W_add( W_tmp1, W_tmp2 ) ) ); } head_room = sub( head_room, find_guarded_bits_fx( num_freq_bands ) ); + +#ifdef FIX_867_CLDFB_NRG_SCALE +#if ( MASA_SUM_FREQ_RANGE_BINS > CLDFB_NO_CHANNELS_HALF ) +#error MASA_SUM_FREQ_RANGE_BINS must be less than CLDFB_NO_CHANNELS_HALF +#endif + q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift[0] ), 1 ), sub( head_room, 32 ) ); +#else q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift ), 1 ), sub( head_room, 32 ) ); +#endif FOR( l = 0; l < num_freq_bands; l++ ) { - re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift - im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift - re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift - im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+min_q_shift +#else + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift +#endif /* Compute sum signal */ Real_aux_fx = L_add( re1, re2 ); // q_cldfb+min_q_shift @@ -1929,6 +2143,7 @@ void protoSignalComputation2_fx( // Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); // 2*(q_cldfb+min_q_shift) Left_power_fx = W_extract_h( W_shl( W_tmp1, head_room ) ); // q_Left_Right_power + // Right_power_fx = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); W_tmp2 = W_add( W_mult0_32_32( re2, re2 ), W_mult0_32_32( im2, im2 ) ); // 2*(q_cldfb+min_q_shift) Right_power_fx = W_extract_h( W_shl( W_tmp2, head_room ) ); // q_Left_Right_power @@ -1937,23 +2152,41 @@ void protoSignalComputation2_fx( reference_power_64fx[l] = W_add( W_tmp1, W_tmp2 ); // 2*(q_cldfb+min_q_shift) move64(); +#ifdef FIX_867_CLDFB_NRG_SCALE + Left_power_fx = L_shr( Left_power_fx, total_shift[qidx] ); + Right_power_fx = L_shr( Right_power_fx, total_shift[qidx] ); left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // q_Left_Right_power right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // q_Left_Right_power // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); - total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power + total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], sub( head_room, total_shift[qidx] ) ) ) ); // q_Left_Right_power +#else + left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // q_Left_Right_power + right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // q_Left_Right_power + // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); + total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power +#endif IF( GT_16( l, MASA_HI_FREQ_START_BIN ) ) { left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // q_Left_Right_power right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // q_Left_Right_power - // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); + // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); +#ifdef FIX_867_CLDFB_NRG_SCALE + total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], sub( head_room, total_shift[qidx] ) ) ) ); // q_Left_Right_power +#else total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power +#endif } IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) { - re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift - im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift +#ifdef FIX_867_CLDFB_NRG_SCALE + re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift[0] ) ); // q_cldfb+temp_q_shift + im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift[0] ) ); // q_cldfb+temp_q_shift +#else + re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift + im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift +#endif sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); // 2*(q_cldfb+temp_q_shift)-31 temp = Mpy_32_32( a_fx, sum_power_fx ); // 2*(q_cldfb+temp_q_shift)-31 @@ -1969,7 +2202,20 @@ void protoSignalComputation2_fx( move32(); } - temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 +#ifdef FIX_867_CLDFB_NRG_SCALE + temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], add( 31, total_shift[qidx] ) ) ) ); // 2*(q_cldfb+min_q_shift) -31 + IF( LT_16( q_temp_total, stereo_type_detect->q_total_power ) ) + { + stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp_total ) ) ); // q_temp + move32(); + } + ELSE + { + stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp_total, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power + move32(); + } +#else + temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_total_power ) ) { stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp ) ) ); // q_temp @@ -1980,6 +2226,7 @@ void protoSignalComputation2_fx( stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power move32(); } +#endif test(); IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) ) @@ -1996,7 +2243,11 @@ void protoSignalComputation2_fx( { sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) move32(); +#ifdef FIX_867_CLDFB_NRG_SCALE + q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp_total ) ) ); +#else q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); +#endif sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); // q15 move32(); } @@ -2008,6 +2259,22 @@ void protoSignalComputation2_fx( ImagSubtract_fx = L_sub( im1, im2 ); // q_cldfb+min_q_shift temp = Madd_32_32( Mpy_32_32( RealSubtract_fx, RealSubtract_fx ), ImagSubtract_fx, ImagSubtract_fx ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + assert( qidx == 0 ); + IF( LT_16( q_temp[qidx], stereo_type_detect->q_subtract_power_y ) ) + { + stereo_type_detect->subtract_power_y_fx = L_add( L_shr( stereo_type_detect->subtract_power_y_fx, sub( stereo_type_detect->q_subtract_power_y, q_temp[qidx] ) ), temp ); // q_temp + move32(); + stereo_type_detect->q_subtract_power_y = q_temp[qidx]; + move16(); + } + ELSE + { + stereo_type_detect->subtract_power_y_fx = L_add( stereo_type_detect->subtract_power_y_fx, L_shr( temp, sub( q_temp[qidx], stereo_type_detect->q_subtract_power_y ) ) ); // stereo_type_detect->q_subtract_power_y + move32(); + } + +#else IF( LT_16( q_temp, stereo_type_detect->q_subtract_power_y ) ) { stereo_type_detect->subtract_power_y_fx = L_add( L_shr( stereo_type_detect->subtract_power_y_fx, sub( stereo_type_detect->q_subtract_power_y, q_temp ) ), temp ); // q_temp @@ -2020,6 +2287,7 @@ void protoSignalComputation2_fx( stereo_type_detect->subtract_power_y_fx = L_add( stereo_type_detect->subtract_power_y_fx, L_shr( temp, sub( q_temp, stereo_type_detect->q_subtract_power_y ) ) ); // stereo_type_detect->q_subtract_power_y move32(); } +#endif } /* Compute protos (and their power) for direct sound rendering */ @@ -2033,14 +2301,26 @@ void protoSignalComputation2_fx( Imag_aux_fx = Madd_32_16( Mpy_32_16_1( Imag_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Imag_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift) -31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2055,14 +2335,26 @@ void protoSignalComputation2_fx( tempDmx_fx = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 temp = Madd_32_16( Mpy_32_16_1( tempSpaced_fx, interpolatorSpaced_fx ), tempDmx_fx, interpolatorDmx_fx ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2079,14 +2371,26 @@ void protoSignalComputation2_fx( Real_aux_fx = L_shr( Real_aux_fx, 1 ); // q_cldfb+min_q_shift Imag_aux_fx = L_shr( Imag_aux_fx, 1 ); // q_cldfb+min_q_shift temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2098,14 +2402,26 @@ void protoSignalComputation2_fx( ELSE { temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2118,14 +2434,26 @@ void protoSignalComputation2_fx( ELSE { temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2161,14 +2489,26 @@ void protoSignalComputation2_fx( } temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } } @@ -2191,14 +2531,26 @@ void protoSignalComputation2_fx( move32(); temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } } @@ -2220,14 +2572,26 @@ void protoSignalComputation2_fx( move32(); temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31 +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } } @@ -2249,8 +2613,13 @@ void protoSignalComputation2_fx( stereo_type_detect->q_sum_power = s_min( stereo_type_detect->q_sum_power, q_temp2 ); move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp_total ); + move16(); +#else stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp ); move16(); +#endif q_sum_total_ratio = Q15; move16(); @@ -2333,6 +2702,18 @@ void protoSignalComputation2_fx( // 20480 = 10 in Q11 lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 +#ifdef FIX_867_CLDFB_NRG_SCALE + stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); + move32(); + stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power ); + move16(); + stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); + move32(); + stereo_type_detect->q_right_hi_power = sub( 31, stereo_type_detect->q_right_hi_power ); + move16(); + stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); + move32(); +#else stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); move32(); stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power ); @@ -2343,6 +2724,7 @@ void protoSignalComputation2_fx( move16(); stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); move32(); +#endif stereo_type_detect->q_total_hi_power = sub( 31, stereo_type_detect->q_total_hi_power ); move16(); @@ -2392,14 +2774,27 @@ void protoSignalComputation2_fx( { p_proto_buffer_fx = proto_direct_buffer_f_fx + ( slot_index * num_freq_bands * 4 ); // q_proto_direct_buffer_f +#ifdef FIX_867_CLDFB_NRG_SCALE + q_temp[0] = sub( add( add( q_cldfb, min_q_shift[0] ), add( q_cldfb, min_q_shift[0] ) ), 31 ); + q_temp[1] = sub( add( add( q_cldfb, min_q_shift[1] ), add( q_cldfb, min_q_shift[1] ) ), 31 ); +#else q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); +#endif FOR( l = 0; l < num_freq_bands; l++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 qidx = s_min( 1, s_max( 0, sub( l, CLDFB_NO_CHANNELS_HALF - 1 ) ) ); + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+ min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+ min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift[qidx] ); // q_cldfb+ min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift[qidx] ); // q_cldfb+ min_q_shift +#else re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+ min_q_shift re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+ min_q_shift im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+ min_q_shift im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+ min_q_shift +#endif Real_aux_fx = L_add( re1, re2 ); // q_cldfb+ min_q_shift Imag_aux_fx = L_add( im1, im2 ); // q_cldfb+ min_q_shift @@ -2408,14 +2803,26 @@ void protoSignalComputation2_fx( reference_power_64fx[l] = W_add( W_mult0_32_32( Real_aux_fx, Real_aux_fx ), W_mult0_32_32( Imag_aux_fx, Imag_aux_fx ) ); // q_temp move64(); +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // q_temp +#else proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( W_extract_l( W_shr( reference_power_64fx[l], 31 ) ), sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( W_extract_l( W_shr( reference_power_64fx[l], 31 ) ), sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2430,14 +2837,26 @@ void protoSignalComputation2_fx( move32(); temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // q_temp +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) ) +#else IF( LT_16( q_temp, *q_proto_power_smooth ) ) +#endif { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp +#endif move32(); } ELSE { +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth +#else proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth +#endif move32(); } @@ -2456,6 +2875,44 @@ void protoSignalComputation2_fx( move32(); } } +#ifdef FIX_867_CLDFB_NRG_SCALE + q_reference_power_64fx = shl( add( q_cldfb, min_q_shift[0] ), 1 ); + + Word16 norm_shift = 63; + move16(); + FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ ) + { + IF( reference_power_64fx[l] ) + { + norm_shift = s_min( norm_shift, W_norm( reference_power_64fx[l] ) ); + } + } + FOR( l = 0; l < s_min( num_freq_bands, CLDFB_NO_CHANNELS_HALF ); l++ ) + { + reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); // q_reference_power_64fx+norm_shift-32 + move32(); + } + q_reference_power[0] = sub( add( q_reference_power_64fx, norm_shift ), 32 ); + move16(); + + q_reference_power_64fx = shl( add( q_cldfb, min_q_shift[1] ), 1 ); + norm_shift = 63; + move16(); + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + IF( reference_power_64fx[l] ) + { + norm_shift = s_min( norm_shift, W_norm( reference_power_64fx[l] ) ); + } + } + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); // q_reference_power_64fx+norm_shift-32 + move32(); + } + q_reference_power[1] = sub( add( q_reference_power_64fx, norm_shift ), 32 ); + move16(); +#else q_reference_power_64fx = shl( add( q_cldfb, min_q_shift ), 1 ); Word16 norm_shift = 63; move16(); @@ -2473,13 +2930,60 @@ void protoSignalComputation2_fx( } *q_reference_power = sub( add( q_reference_power_64fx, norm_shift ), 32 ); move16(); +#endif +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( GT_16( min_q_shift[0], min_q_shift[1] ) ) + { + FOR( l = 0; l < i_mult( num_proto, num_freq_bands ); l += num_freq_bands ) + { + Scale_sig32( proto_frame_f_fx + shl( l, 1 ), shl( s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ), 1 ), sub( min_q_shift[1], min_q_shift[0] ) ); + } + *q_proto_frame_f = add( q_cldfb, min_q_shift[1] ); + move16(); + } + ELSE + { + FOR( l = 0; l < i_mult( num_proto, num_freq_bands ); l += num_freq_bands ) + { + Scale_sig32( proto_frame_f_fx + shl( add( l, CLDFB_NO_CHANNELS_HALF ), 1 ), shl( s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), 1 ), sub( min_q_shift[0], min_q_shift[1] ) ); + } + *q_proto_frame_f = add( q_cldfb, min_q_shift[0] ); + move16(); + } + IF( GT_16( min_q_shift[0], min_q_shift[1] ) ) + { + FOR( l = 0; l < i_mult( num_proto, num_freq_bands ); l += num_freq_bands ) + { + Scale_sig32( p_proto_buffer_fx + shl( l, 1 ), shl( s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ), 1 ), sub( min_q_shift[1], min_q_shift[0] ) ); + } + *q_proto_direct_buffer_f = add( q_cldfb, min_q_shift[1] ); + move16(); + } + ELSE + { + FOR( l = 0; l < i_mult( num_proto, num_freq_bands ); l += num_freq_bands ) + { + Scale_sig32( p_proto_buffer_fx + shl( add( l, CLDFB_NO_CHANNELS_HALF ), 1 ), shl( s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), 1 ), sub( min_q_shift[0], min_q_shift[1] ) ); + } + *q_proto_direct_buffer_f = add( q_cldfb, min_q_shift[0] ); + move16(); + } +#else *q_proto_frame_f = add( q_cldfb, min_q_shift ); move16(); *q_proto_direct_buffer_f = add( q_cldfb, min_q_shift ); move16(); +#endif +#ifdef FIX_867_CLDFB_NRG_SCALE + q_proto_power_smooth[0] = s_min( q_proto_power_smooth[0], q_temp[0] ); + q_proto_power_smooth[1] = s_min( q_proto_power_smooth[1], q_temp[1] ); + move16(); + move16(); +#else *q_proto_power_smooth = s_min( *q_proto_power_smooth, q_temp ); move16(); +#endif return; } @@ -2515,6 +3019,9 @@ void protoSignalComputation4_fx( Word32 sq_tmp_fx; Word32 *p_proto_buffer_fx; Word16 min_q_shift, q_shift; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 min_q_shift2, q_shift2; +#endif Word32 re, im; Word16 proto_power_smooth_fx_q, sq_tmp_q; @@ -2522,6 +3029,12 @@ void protoSignalComputation4_fx( move16(); q_shift = Q31; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + min_q_shift2 = Q31; + move16(); + q_shift2 = Q31; + move16(); +#endif sq_tmp_q = 0; move16(); @@ -2530,16 +3043,53 @@ void protoSignalComputation4_fx( /* calculate the shift possible for both RealBuffer_fx and ImagBuffer_fx buffers*/ FOR( k = 0; k < s_max( 4, nchan_transport ); k++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + q_shift = L_norm_arr( RealBuffer_fx[k][0], s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ) ); + min_q_shift = s_min( q_shift, min_q_shift ); + q_shift = L_norm_arr( ImagBuffer_fx[k][0], s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ) ); + min_q_shift = s_min( q_shift, min_q_shift ); + q_shift2 = L_norm_arr( RealBuffer_fx[k][0] + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + min_q_shift2 = s_min( q_shift2, min_q_shift2 ); + q_shift2 = L_norm_arr( ImagBuffer_fx[k][0] + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + min_q_shift2 = s_min( q_shift2, min_q_shift2 ); +#else q_shift = L_norm_arr( RealBuffer_fx[k][0], num_freq_bands ); min_q_shift = s_min( q_shift, min_q_shift ); q_shift = L_norm_arr( ImagBuffer_fx[k][0], num_freq_bands ); min_q_shift = s_min( q_shift, min_q_shift ); +#endif } q_shift = min_q_shift; min_q_shift = sub( min_q_shift, find_guarded_bits_fx( i_mult( 2, 4 ) ) ); +#ifdef FIX_867_CLDFB_NRG_SCALE + q_shift2 = min_q_shift2; + min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( i_mult( 2, 4 ) ) ); +#endif FOR( k = 0; k < 4; k++ ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + FOR( l = 0; l < s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ); l++ ) + { + re = L_shl( RealBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift + + sq_tmp_fx = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 + + reference_power_fx[l] = Madd_32_16( reference_power_fx[l], sq_tmp_fx, 16384 /*0.5 in Q15*/ ); // 2*(q_cldfb+min_q_shift)-31 + move32(); + } + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + re = L_shl( RealBuffer_fx[k][0][l], min_q_shift2 ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[k][0][l], min_q_shift2 ); // q_cldfb+min_q_shift + + sq_tmp_fx = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 + + reference_power_fx[l] = Madd_32_16( reference_power_fx[l], sq_tmp_fx, 16384 /*0.5 in Q15*/ ); // 2*(q_cldfb+min_q_shift)-31 + move32(); + } +#else FOR( l = 0; l < num_freq_bands; l++ ) { re = L_shl( RealBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift @@ -2550,12 +3100,24 @@ void protoSignalComputation4_fx( reference_power_fx[l] = Madd_32_16( reference_power_fx[l], sq_tmp_fx, 16384 /*0.5 in Q15*/ ); // 2*(q_cldfb+min_q_shift)-31 move32(); } +#endif } +#ifdef FIX_867_CLDFB_NRG_SCALE + sq_tmp_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + reference_power_q[0] = sq_tmp_q; + move16(); + sq_tmp_q = sub( add( add( q_cldfb, min_q_shift2 ), add( q_cldfb, min_q_shift2 ) ), 31 ); + reference_power_q[1] = sq_tmp_q; + move16(); + + min_q_shift = sub( s_min( q_shift, q_shift2 ), find_guarded_bits_fx( 2 ) ); +#else sq_tmp_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); *reference_power_q = sub( add( sq_tmp_q, Q15 ), 15 ); move16(); min_q_shift = sub( q_shift, find_guarded_bits_fx( 2 ) ); +#endif /*For decorrelated diffuseness*/ FOR( l = 0; l < num_outputs_diff; l++ ) @@ -2638,8 +3200,15 @@ void protoSignalComputation4_fx( *proto_direct_buffer_f_q = *proto_frame_f_q; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + proto_power_smooth_q[0] = proto_power_smooth_fx_q; + proto_power_smooth_q[1] = proto_power_smooth_fx_q; + move16(); + move16(); +#else *proto_power_smooth_q = proto_power_smooth_fx_q; move16(); +#endif return; } @@ -2775,13 +3344,8 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( Word16 new_diff_e = s_max( diff_e, old_diff_e ); Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx, diffuse_start, sub( old_diff_e, new_diff_e ) ); // 31-new_diff_e -#ifdef MSAN_FIX Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + diffuse_start, i_mult( shl( num_freq_bands_diff, 1 ), hDirACRend->hOutSetup.nchan_out_woLFE ), sub( diff_e, new_diff_e ) ); // 31-new_diff_e -#else - Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + diffuse_start, - sub( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_len, diffuse_start ), sub( diff_e, new_diff_e ) ); -#endif h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q = sub( 31, new_diff_e ); move16(); @@ -2972,10 +3536,8 @@ void ivas_masa_init_stereotype_detection_fx( move16(); stereo_type_detect->target_power_y_smooth_fx = 0; move32(); -#ifdef MSAN_FIX stereo_type_detect->q_target_power_y_smooth = 31; move16(); -#endif stereo_type_detect->lr_total_bb_ratio_db_fx = 0; move32(); @@ -3707,7 +4269,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_fix, DirAC_mem.reference_power_q, slot_idx, nchan_transport, +#else reference_power_fix, &DirAC_mem.reference_power_q, slot_idx, nchan_transport, +#endif hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, 0, q_cldfb ); @@ -3720,12 +4286,49 @@ static void ivas_masa_ext_dirac_render_sf_fx( protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, &hDirACRend->proto_frame_f_q, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_fix, DirAC_mem.reference_power_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else reference_power_fix, &DirAC_mem.reference_power_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect, q_cldfb ); proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_smooth_q[0], DirAC_mem.reference_power_q[0] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[0] = DirAC_mem.reference_power_smooth_q[0]; + move16(); + } + IF( LT_16( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; + move16(); + } +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -3738,6 +4341,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); @@ -3753,9 +4357,15 @@ static void ivas_masa_ext_dirac_render_sf_fx( &hDirACRend->proto_frame_f_q, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_fix, DirAC_mem.reference_power_q, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else reference_power_fix, &DirAC_mem.reference_power_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif hDirACRend->hOutSetup.is_loudspeaker_setup, slot_idx, hSpatParamRendCom->num_freq_bands, @@ -3763,6 +4373,39 @@ static void ivas_masa_ext_dirac_render_sf_fx( proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_smooth_q[0], DirAC_mem.reference_power_q[0] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[0] = DirAC_mem.reference_power_smooth_q[0]; + move16(); + } + IF( LT_16( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[1]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; + move16(); + } + +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -3775,6 +4418,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); @@ -3787,9 +4431,15 @@ static void ivas_masa_ext_dirac_render_sf_fx( &hDirACRend->proto_frame_f_q, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, +#ifdef FIX_867_CLDFB_NRG_SCALE + reference_power_fix, DirAC_mem.reference_power_q, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#else reference_power_fix, &DirAC_mem.reference_power_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, +#endif slot_idx, hDirACRend->num_protos_diff, hSpatParamRendCom->num_freq_bands, q_cldfb ); @@ -3797,6 +4447,38 @@ static void ivas_masa_ext_dirac_render_sf_fx( proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + IF( LT_16( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_smooth_q[0], DirAC_mem.reference_power_q[0] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[0] = DirAC_mem.reference_power_smooth_q[0]; + move16(); + } + IF( LT_16( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; + move16(); + } +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -3809,6 +4491,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q @@ -3928,10 +4611,21 @@ static void ivas_masa_ext_dirac_render_sf_fx( IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, -1 ); // DirAC_mem.reference_power_q-1 +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_q[0] = sub( DirAC_mem.reference_power_q[0], 1 ); + DirAC_mem.reference_power_q[1] = sub( DirAC_mem.reference_power_q[1], 1 ); + move16(); + move16(); + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0]; + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; + move16(); + move16(); +#else DirAC_mem.reference_power_q = sub( DirAC_mem.reference_power_q, 1 ); move16(); DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); +#endif v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); // DirAC_mem.reference_power_smooth_q } } @@ -4042,10 +4736,19 @@ static void ivas_masa_ext_dirac_render_sf_fx( Word16 reference_power_temp_q = getScaleFactor32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len ); scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, reference_power_temp_q ); /*DirAC_mem.reference_power_q + reference_power_temp_q*/ +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_q[0] = add( DirAC_mem.reference_power_q[0], reference_power_temp_q ); + DirAC_mem.reference_power_q[1] = add( DirAC_mem.reference_power_q[1], reference_power_temp_q ); + move16(); + DirAC_mem.reference_power_smooth_q[0] = add( DirAC_mem.reference_power_q[0], reference_power_temp_q ); + DirAC_mem.reference_power_smooth_q[1] = add( DirAC_mem.reference_power_q[1], reference_power_temp_q ); + move16(); +#else DirAC_mem.reference_power_q = add( DirAC_mem.reference_power_q, reference_power_temp_q ); move16(); DirAC_mem.reference_power_smooth_q = add( DirAC_mem.reference_power_q, reference_power_temp_q ); move16(); +#endif Word16 q_cy_auto_diff_smooth = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len ); Scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len, q_cy_auto_diff_smooth ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth+ q_cy_auto_diff_smooth @@ -4076,12 +4779,40 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); } +#ifdef FIX_867_CLDFB_NRG_SCALE + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ); + move16(); + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); + move16(); + + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ); + move16(); + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); + move16(); +#else Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); move16(); Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); move16(); +#endif Word16 proto_power_diff_smooth_prev_temp_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len ); Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, proto_power_diff_smooth_prev_temp_q ); // hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q + proto_power_diff_smooth_prev_temp_q @@ -4104,6 +4835,27 @@ static void ivas_masa_ext_dirac_render_sf_fx( /*Buffer rescaling*/ +#ifdef FIX_867_CLDFB_NRG_SCALE + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + FOR( i = 0; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + } + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); + move16(); + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ); + move16(); + DirAC_mem.reference_power_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); + move16(); + DirAC_mem.reference_power_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ); + move16(); + DirAC_mem.reference_power_smooth_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); + move16(); + DirAC_mem.reference_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ); + move16(); +#else Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), DirAC_mem.reference_power_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) @@ -4113,6 +4865,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); DirAC_mem.reference_power_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ); move16(); +#endif ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, @@ -4121,12 +4874,51 @@ static void ivas_masa_ext_dirac_render_sf_fx( hSpatParamRendCom->subframe_nbslots[subframe_idx], diffuseness_vector_fx, reference_power_smooth_fx, +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_smooth_q, +#else &DirAC_mem.reference_power_smooth_q, +#endif ONE_IN_Q31, 0, &q_cldfb ); hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q; move16(); +#ifdef FIX_867_CLDFB_NRG_SCALE + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = DirAC_mem.reference_power_smooth_q[0]; + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] = DirAC_mem.reference_power_smooth_q[1]; + move16(); + IF( LT_16( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_smooth_q[0] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( DirAC_mem.reference_power_smooth_q[0], DirAC_mem.reference_power_q[0] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[0] = DirAC_mem.reference_power_smooth_q[0]; + move16(); + } + IF( LT_16( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ) + { + FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + } + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; + move16(); + } + ELSE + { + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; + move16(); + } +#else hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = DirAC_mem.reference_power_smooth_q; move16(); IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) @@ -4141,6 +4933,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif } /*-----------------------------------------------------------------* @@ -4215,11 +5008,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // q_cldfb } Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, 0, hMasaExtRend->cldfbSynRend[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, hMasaExtRend->cldfbSynRend[idx_in] ); -#else /* OPT_SBA_AVOID_SPAR_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, hMasaExtRend->cldfbSynRend[idx_in] ); -#endif /* OPT_SBA_AVOID_SPAR_RESCALE */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 idx_in++; } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index f3b4d175551867a1866ac1c6bdd7601e0fcdea4f..cfdd431167d350a0d184b6b098b8122fa4836a23 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -753,12 +753,8 @@ void ivas_mcmasa_param_est_ana_fx( /* Direction estimation */ computeIntensityVector_ana_fx( hMcMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ) -#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC - , - NULL -#endif - ); /* Q direction_vector_fx = Q30*/ + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), + NULL ); /* Q direction_vector_fx = Q30*/ /* Power and intensity estimation for diffuseness */ computeIntensityVector_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, num_freq_bands, intensity_even_real_fx ); /*2*inp_q-31*/ diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 01e35efe1711b619d8dd6dfc821e79639d355904..30bf8f00aaac87f2bbee5753662ab91eea5e3ad1 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -393,9 +393,7 @@ static void GenerateITD_fx( Word16 num_az_idx, num_ev_idx; Word16 BM_idx[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ]; Word16 itdMod_e; -#ifdef MSAN_FIX set16_fx( AzIdx, 0, HRTF_MODEL_BSPLINE_NUM_COEFFS ); -#endif // MSAN_FIX /* Wrap the requested azimuth to the range of the BSplines */ azim_fx = L_add( azim_fx, model->azimKSeq_fx[0] ); diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 5787ded3f45254dc9ffa2bd706c747e51a257c52..7e35b80b2c0c2eefa628c9266a19555fd25ca8cc 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -573,10 +573,8 @@ static void TDREND_SRC_SPATIAL_Init_fx( TDREND_SPATIAL_VecInit_fx( SrcSpatial_p->Front_p_fx + nC * 3, 0, 0, ONE_IN_Q30 ); /*Assuming Q30*/ } -#ifdef MSAN_FIX SrcSpatial_p->q_Pos_p = Q31; move16(); -#endif /* Source directional attenuation */ SrcSpatial_p->DirAttenEnabled = FALSE; // Q0 diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 8beb5a0ecfd10a2b42e5a935127c62d97da94e05..3b01f62ca0af91b601d6b42e79f8426dfdd906c1 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -1,9 +1,7 @@ #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" -#ifdef FIX_DISCLAIMER #include -#endif Word16 ivas_get_nchan_buffers_dec_ivas_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -161,7 +159,6 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( return nchan_out_buff; } -#ifdef FIX_DISCLAIMER /*---------------------------------------------------------------------* * get_channel_config() * @@ -272,4 +269,3 @@ ivas_error get_channel_config( return IVAS_ERR_OK; } -#endif diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index b365aa7672b1cab749b56f8ccfb24751dc394115..a72e7ec3db7046d5a5411d7e4b4f04c3f08d7259 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -81,12 +81,10 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( const Word32 ivas_total_brate /* i : total IVAS bitrate */ ); -#ifdef FIX_DISCLAIMER ivas_error get_channel_config( const AUDIO_CONFIG config, /* i : audio configuration */ Word8 *str /* o : string with the configuration name */ ); -#endif /*----------------------------------------------------------------------------------* @@ -462,7 +460,11 @@ void ivas_dirac_dec_output_synthesis_close_fx( void ivas_dirac_dec_output_synthesis_process_slot_fx( const Word32 *reference_power, /* i : Estimated power */ +#ifdef FIX_867_CLDFB_NRG_SCALE + const Word16 *q_reference_power, /* i : Estimated power */ +#else const Word16 q_reference_power, /* i : Estimated power */ +#endif const Word32 *onset, /* i : onset filter */ const Word16 *azimuth, const Word16 *elevation, diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 870f8795dd4ab6fd0d1a45dbf17205e15df3fda5..9b149940c08947d8a2548fe6ba486729f34fd7fa 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1529,9 +1529,7 @@ ivas_error ivas_reverb_open_fx( params.pDsr_fx = params.pRt60_fx + nr_fc_fft_filter; params.pFc_fx = &pState->fft_filter_color_0.fft_spectrum_fx[0]; params.pHrtf_inter_aural_coherence_fx = &pState->fft_filter_color_1.fft_spectrum_fx[0]; -#ifdef MSAN_FIX set32_fx( pState->fft_filter_color_1.fft_spectrum_fx, 0, RV_FILTER_MAX_FFT_SIZE ); -#endif /* Note: these temp buffers can only be used before the final step of the FFT filter design : */ /* before calls to ivas_reverb_calc_correl_filters(...) or to ivas_reverb_calc_color_filters(...) */ @@ -1647,18 +1645,11 @@ ivas_error ivas_reverb_open_fx( IF( pState->do_corr_filter ) { /* Computing correlation filters on the basis of target IA coherence */ -#ifdef MSAN_FIX FOR( i = 0; i < shl( sub( nr_fc_fft_filter, 1 ), 1 ); i++ ) { pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 ); /*Scaling signal down to 30*/ move32(); } -#else - FOR( i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++ ) - { - pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 ); /*Scaling signal down to 30*/ - } -#endif // MSAN_FIX Word32 *pHrtf_inter_aural_coherence_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 ) ); FOR( i = 0; i < nr_fc_fft_filter; i++ ) diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 727a212be5ac8726ce5aeb8b574ffc01c709d812..91a60eac8f31c80e99cacdd352ccaa931f28da07 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -2319,12 +2319,10 @@ void SHrotmatgen_fx( Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; -#ifdef MSAN_FIX FOR( i = 0; i < HEADROT_SHMAT_DIM; i++ ) { set16_fx( R_lm1[i], 0, HEADROT_SHMAT_DIM ); } -#endif Word16 R_l[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; Word32 result; SHrotmat[0][0] = ONE_IN_Q14; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 028afd9d7686ae7d895c5acfc426e9b076bc8946..fc434df90f13b3895fb624b1324563570c560ecb 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -228,8 +228,13 @@ typedef struct dirac_dec_stack_mem Word32 *cy_auto_diff_smooth_fx; Word32 *reference_power_fx; +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 reference_power_q[2]; + Word16 reference_power_smooth_q[2]; +#else Word16 reference_power_q; Word16 reference_power_smooth_q; +#endif Word16 reference_power_len; Word32 *onset_filter_fx; /* Q31 */ @@ -277,7 +282,11 @@ typedef struct dirac_output_synthesis_state_structure /* Temporal smoothing memories */ Word32 *reference_power_smooth_prev_fx; /* Q(reference_power_smooth_prev_q) */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 reference_power_smooth_prev_q[2]; +#else Word16 reference_power_smooth_prev_q; +#endif Word32 *direction_smoothness_prev_fx; /* Q31 */ /* only pointer to local buffers */ @@ -295,10 +304,18 @@ typedef struct dirac_output_synthesis_state_structure Word16 diff_dir_power_factor_len; Word32 *proto_power_smooth_fx; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 proto_power_smooth_q[2]; +#else Word16 proto_power_smooth_q; +#endif Word16 proto_power_smooth_len; Word32 *proto_power_smooth_prev_fx; /* Smoothed power of the prototype signals of the previous synthesis block. Size: num_freq_bands*num_channels. */ +#ifdef FIX_867_CLDFB_NRG_SCALE + Word16 proto_power_smooth_prev_q[2]; +#else Word16 proto_power_smooth_prev_q; +#endif Word16 proto_power_smooth_prev_len; Word32 *proto_power_diff_smooth_fx; @@ -667,21 +684,12 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 ****filterStatesLeftReal_fx; Word32 ****filterStatesLeftImag_fx; -#ifdef OPT_BASOP_ADD_v1 Word16 *Q_filterStates; -#else - Word16 ****Q_filterStatesLeft; -#endif #else Word32 ***filterStatesLeftReal_fx; Word32 ***filterStatesLeftImag_fx; -#ifdef OPT_BASOP_ADD_v1 Word16 Q_filterStatesLeft; -#else /* OPT_BASOP_ADD_v1 */ - Word16 ***Q_filterStatesLeft; -#endif /* OPT_BASOP_ADD_v1 */ -#endif /* SPLIT_REND_WITH_HEAD_ROT */ - +#endif Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; @@ -839,8 +847,8 @@ typedef struct ivas_combined_orientation_struct #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Rmat_prev_fx[MAX_HEAD_ROT_POSES][3][3]; #else - Word32 Rmat_prev_fx[3][3]; -#endif /* Q30 */ + Word32 Rmat_prev_fx[3][3]; /* Q30 */ +#endif Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ Word16 q_chEneIIR; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 5babc6af9419079b537d723dff2cd171bd81a4d2..62bee3a6bb4782c3afe3e3001f51a727bfa5cfd8 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -9388,10 +9388,10 @@ void IVAS_REND_cldfbSynthesis_wrapper( { Scale_sig32( h_cldfb->cldfb_state_fx, h_cldfb->p_filter_length, sub( sub( Q_cldfb, 1 ), h_cldfb->Q_cldfb_state ) ); -#ifdef OPT_SBA_AVOID_SPAR_RESCALE - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, 0, h_cldfb ); // Q_cldfb - 1 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, 0, 0, h_cldfb ); // Q_cldfb - 1 #else - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, 0, h_cldfb ); // Q_cldfb - 1 #endif *Q_out = sub( Q_cldfb, 1 ); move16(); @@ -10317,8 +10317,15 @@ static void intermidiate_ext_dirac_render( IF( to_fix ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0] = Q31; + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1] = Q31; + move16(); + move16(); +#else DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31; move16(); +#endif move16(); FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { @@ -10447,14 +10454,65 @@ static void intermidiate_ext_dirac_render( IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { +#ifdef FIX_867_CLDFB_NRG_SCALE + tmp = 0; + move16(); + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + } + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */ + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], tmp ); + move16(); + tmp = 0; + move16(); + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + } + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */ + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], tmp ); + move16(); +#else tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */ hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, tmp ); move16(); +#endif +#ifdef FIX_867_CLDFB_NRG_SCALE + tmp = 0; + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ) ) ); + } + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, s_min( CLDFB_NO_CHANNELS_HALF, hSpatParamRendCom->num_freq_bands ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */ + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ); + move16(); + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) ); + } + FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */ + } + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); + move16(); +#else tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q + tmp) */ hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); move16(); +#endif } tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len ); @@ -10492,7 +10550,6 @@ static void intermidiate_ext_dirac_render( } } -#ifdef FIX_DISCLAIMER static ivas_error printConfigInfo_rend( IVAS_REND_HANDLE hIvasRend /* i : IVAS renderer handle */ ) @@ -10585,4 +10642,3 @@ void IVAS_REND_PrintDisclaimer( void ) return; } -#endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index c3d6ca703251c8b6ce11414b263b63b9da5b7847..54903bc5c0f0660e5729385353bd998c158f228d 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -405,7 +405,6 @@ void IVAS_REND_cldfbSynthesis_wrapper( #endif -#ifdef FIX_DISCLAIMER /* Disclaimer and info printing */ void IVAS_REND_PrintInputConfig( @@ -419,7 +418,6 @@ ivas_error IVAS_REND_PrintConfig( void IVAS_REND_PrintDisclaimer( void ); -#endif /* clang-format on */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index e667dcfe5179500d1f08c3310dd27ead8b4dc2bc..c2e3d8a2ae53745336dfedd66904388a85fd7355 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1201,11 +1201,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { memcpy( f_tmp_ntaps_sba, hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); -#ifdef MSAN_FIX floatToFixed_arrL( f_tmp_ntaps_sba, ( *hHRTF )->rightHRIRImag_HOA3_fx[i][j], Q29, BINAURAL_NTAPS_SBA ); -#else - floatToFixed_arrL( f_tmp_ntaps_sba, ( *hHRTF )->rightHRIRReal_HOA3_fx[i][j], Q29, BINAURAL_NTAPS_SBA ); -#endif } } }